@dforge-core/dforge-cli 0.1.0-rc.3 → 0.1.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/README.md CHANGED
@@ -17,9 +17,7 @@ macOS arm64/x64, Linux x64/arm64, Windows x64/arm64.
17
17
  ## Commands
18
18
 
19
19
  ```bash
20
- # Scaffold a new module interactively (asks for code/displayName/dependencies/
21
- # preset/initial entity). Generates manifest with a real UUID, writes the
22
- # minimum file set so the module installs cleanly.
20
+ # Scaffold a new module interactively (see `Scaffolding a new module` below).
23
21
  dforge-cli init module ./my-module
24
22
 
25
23
  # Package a module directory into a .dforge archive
@@ -41,6 +39,58 @@ DFORGE_URL=https://app.example.com DFORGE_TOKEN=<jwt> \
41
39
  dforge-cli dbml-import --from-dbml ./schema.dbml
42
40
  ```
43
41
 
42
+ ## Scaffolding a new module
43
+
44
+ ```bash
45
+ dforge-cli init module ./my-module
46
+ ```
47
+
48
+ Walks you through an interactive setup and writes a fresh module that's
49
+ ready to `pack` and `install`.
50
+
51
+ ### What it asks
52
+
53
+ | Prompt | Default | Notes |
54
+ |---|---|---|
55
+ | Module code | (none) | `^[a-z][a-z0-9_-]*$` — becomes the DB schema name and `module_cd` |
56
+ | Display name | titlecased `code` | shown in the UI |
57
+ | Description | (empty) | optional |
58
+ | Author name | `git config user.name` | optional |
59
+ | License | `MIT` | |
60
+ | Version | `0.1.0` | semver |
61
+ | DB schema version | `0.0.1` | bumped when you alter physical columns |
62
+ | Dependencies | `admin`, `metadata` | toggle which system modules you depend on |
63
+ | Preset | Minimal | see below |
64
+ | First entity name | (none) | `^[a-z][a-z0-9_]*$` — table/entity code |
65
+ | First entity label | titlecased name | display label |
66
+ | Traits | `identity + audit` | see below |
67
+
68
+ `moduleId` (the immutable UUID) is auto-generated with `crypto.randomUUID()` — no prompt.
69
+
70
+ ### Presets
71
+
72
+ - **Minimal** — manifest + one entity + minimum UI (`data_views`, `folders`, `menus`, `actions`) + one admin role. ~8 files. Installs as-is; you add fields/views/roles from there.
73
+ - **Minimal + add more entities interactively** — same as Minimal, then loops to add additional entities (name + label + traits per entity) so you don't have to re-run.
74
+ - **Full template** — Minimal plus `settings.json`, `translations/en-US.json`, a `seed-data/01-<entity>.json` per entity, and a `logic/actions/` stub directory. Use this when you want the typical optional files scaffolded for you to fill in (or delete).
75
+
76
+ ### Entity traits
77
+
78
+ The "traits" choice controls which built-in columns the entity gets for free — both rendered by the platform, no need to declare in `fields`:
79
+
80
+ - **identity only** — primary key only. Use for lookup tables that don't need audit columns.
81
+ - **identity + audit** (recommended) — primary key + `created_date` + `last_updated` + `created_by` + `last_updated_by`. Standard for any business entity.
82
+
83
+ You can change traits later by editing the entity JSON.
84
+
85
+ ### After scaffold
86
+
87
+ ```bash
88
+ cd ./my-module
89
+ dforge-cli module install --path . --code <tenant> # full validation + install
90
+ ```
91
+
92
+ The first install runs the full server-side validator (manifest, FK targets, package-filter SQL, migration safety) — fix anything it flags, then re-run.
93
+
44
94
  ## Auth
45
95
 
46
96
  The remote `module install --url` and `marketplace publish` flows need a JWT
package/dist/lib.d.mts ADDED
@@ -0,0 +1,66 @@
1
+ type Preset = "minimal" | "minimal-plus" | "full";
2
+ type Traits = "identity" | "identity+audit";
3
+ interface EntitySpec {
4
+ name: string;
5
+ label: string;
6
+ traits: Traits;
7
+ }
8
+ interface ScaffoldOpts {
9
+ path: string;
10
+ code: string;
11
+ displayName: string;
12
+ description: string;
13
+ author: string;
14
+ license: string;
15
+ version: string;
16
+ dbSchemaVersion: string;
17
+ dependencies: string[];
18
+ preset: Preset;
19
+ entities: EntitySpec[];
20
+ }
21
+ interface Manifest {
22
+ packageFormat: number;
23
+ moduleId: string;
24
+ code: string;
25
+ version: string;
26
+ dbSchemaVersion: string;
27
+ displayName: string;
28
+ description?: string;
29
+ author?: {
30
+ name: string;
31
+ };
32
+ license?: string;
33
+ dependencies?: Record<string, string>;
34
+ entities: Record<string, string>;
35
+ created?: string;
36
+ updated?: string;
37
+ }
38
+ interface Entity {
39
+ description: string;
40
+ dbObject: string;
41
+ toString: string;
42
+ traits: string[];
43
+ fields: Record<string, unknown>;
44
+ }
45
+ interface DataView {
46
+ viewType: string;
47
+ label: string;
48
+ dataSources: Array<{
49
+ entityCode: string;
50
+ columns: string[];
51
+ }>;
52
+ }
53
+
54
+ declare function buildManifest(opts: ScaffoldOpts, moduleId: string): Manifest;
55
+ declare function buildEntity(entity: EntitySpec): Entity;
56
+ declare function buildDataViews(entities: EntitySpec[]): Record<string, DataView>;
57
+ declare function buildFolders(opts: ScaffoldOpts): Record<string, unknown>;
58
+ declare function buildMenus(opts: ScaffoldOpts): Record<string, unknown>;
59
+ declare function buildRoles(opts: ScaffoldOpts): Record<string, unknown>;
60
+ declare function buildActions(): Record<string, unknown>;
61
+ declare function buildSettings(): Record<string, unknown>;
62
+ declare function buildTranslations(opts: ScaffoldOpts): Record<string, string>;
63
+ declare function buildSeedData(): unknown[];
64
+ declare function buildGitignore(): string;
65
+
66
+ export { type DataView, type Entity, type EntitySpec, type Manifest, type Preset, type ScaffoldOpts, type Traits, buildActions, buildDataViews, buildEntity, buildFolders, buildGitignore, buildManifest, buildMenus, buildRoles, buildSeedData, buildSettings, buildTranslations };
package/dist/lib.d.ts ADDED
@@ -0,0 +1,66 @@
1
+ type Preset = "minimal" | "minimal-plus" | "full";
2
+ type Traits = "identity" | "identity+audit";
3
+ interface EntitySpec {
4
+ name: string;
5
+ label: string;
6
+ traits: Traits;
7
+ }
8
+ interface ScaffoldOpts {
9
+ path: string;
10
+ code: string;
11
+ displayName: string;
12
+ description: string;
13
+ author: string;
14
+ license: string;
15
+ version: string;
16
+ dbSchemaVersion: string;
17
+ dependencies: string[];
18
+ preset: Preset;
19
+ entities: EntitySpec[];
20
+ }
21
+ interface Manifest {
22
+ packageFormat: number;
23
+ moduleId: string;
24
+ code: string;
25
+ version: string;
26
+ dbSchemaVersion: string;
27
+ displayName: string;
28
+ description?: string;
29
+ author?: {
30
+ name: string;
31
+ };
32
+ license?: string;
33
+ dependencies?: Record<string, string>;
34
+ entities: Record<string, string>;
35
+ created?: string;
36
+ updated?: string;
37
+ }
38
+ interface Entity {
39
+ description: string;
40
+ dbObject: string;
41
+ toString: string;
42
+ traits: string[];
43
+ fields: Record<string, unknown>;
44
+ }
45
+ interface DataView {
46
+ viewType: string;
47
+ label: string;
48
+ dataSources: Array<{
49
+ entityCode: string;
50
+ columns: string[];
51
+ }>;
52
+ }
53
+
54
+ declare function buildManifest(opts: ScaffoldOpts, moduleId: string): Manifest;
55
+ declare function buildEntity(entity: EntitySpec): Entity;
56
+ declare function buildDataViews(entities: EntitySpec[]): Record<string, DataView>;
57
+ declare function buildFolders(opts: ScaffoldOpts): Record<string, unknown>;
58
+ declare function buildMenus(opts: ScaffoldOpts): Record<string, unknown>;
59
+ declare function buildRoles(opts: ScaffoldOpts): Record<string, unknown>;
60
+ declare function buildActions(): Record<string, unknown>;
61
+ declare function buildSettings(): Record<string, unknown>;
62
+ declare function buildTranslations(opts: ScaffoldOpts): Record<string, string>;
63
+ declare function buildSeedData(): unknown[];
64
+ declare function buildGitignore(): string;
65
+
66
+ export { type DataView, type Entity, type EntitySpec, type Manifest, type Preset, type ScaffoldOpts, type Traits, buildActions, buildDataViews, buildEntity, buildFolders, buildGitignore, buildManifest, buildMenus, buildRoles, buildSeedData, buildSettings, buildTranslations };
package/dist/lib.js ADDED
@@ -0,0 +1,178 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/lib.ts
21
+ var lib_exports = {};
22
+ __export(lib_exports, {
23
+ buildActions: () => buildActions,
24
+ buildDataViews: () => buildDataViews,
25
+ buildEntity: () => buildEntity,
26
+ buildFolders: () => buildFolders,
27
+ buildGitignore: () => buildGitignore,
28
+ buildManifest: () => buildManifest,
29
+ buildMenus: () => buildMenus,
30
+ buildRoles: () => buildRoles,
31
+ buildSeedData: () => buildSeedData,
32
+ buildSettings: () => buildSettings,
33
+ buildTranslations: () => buildTranslations
34
+ });
35
+ module.exports = __toCommonJS(lib_exports);
36
+
37
+ // src/init/templates.ts
38
+ function buildManifest(opts, moduleId) {
39
+ const today = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
40
+ const manifest = {
41
+ packageFormat: 1,
42
+ moduleId,
43
+ code: opts.code,
44
+ version: opts.version,
45
+ dbSchemaVersion: opts.dbSchemaVersion,
46
+ displayName: opts.displayName,
47
+ entities: Object.fromEntries(
48
+ opts.entities.map((e) => [e.name, `./entities/${e.name}.json`])
49
+ ),
50
+ created: today,
51
+ updated: today
52
+ };
53
+ if (opts.description) manifest.description = opts.description;
54
+ if (opts.author) manifest.author = { name: opts.author };
55
+ if (opts.license) manifest.license = opts.license;
56
+ if (opts.dependencies.length > 0) {
57
+ manifest.dependencies = Object.fromEntries(
58
+ opts.dependencies.map((d) => [d, ">=0.0.1"])
59
+ );
60
+ }
61
+ return manifest;
62
+ }
63
+ function buildEntity(entity) {
64
+ const traits = entity.traits === "identity+audit" ? ["identity", "audit"] : ["identity"];
65
+ return {
66
+ description: entity.label,
67
+ dbObject: entity.name,
68
+ toString: "{id}",
69
+ traits,
70
+ fields: {}
71
+ };
72
+ }
73
+ function buildDataViews(entities) {
74
+ const views = {};
75
+ for (const e of entities) {
76
+ views[e.name] = {
77
+ viewType: "grid",
78
+ label: e.label,
79
+ dataSources: [
80
+ {
81
+ entityCode: e.name,
82
+ columns: []
83
+ }
84
+ ]
85
+ };
86
+ }
87
+ return views;
88
+ }
89
+ function buildFolders(opts) {
90
+ return {
91
+ [opts.code]: {
92
+ label: opts.displayName,
93
+ description: opts.description || opts.displayName,
94
+ icon: "bi-folder",
95
+ color: "#2196F3",
96
+ entities: Object.fromEntries(
97
+ opts.entities.map((e) => [
98
+ e.name,
99
+ { viewName: e.name, quickAdd: true }
100
+ ])
101
+ )
102
+ }
103
+ };
104
+ }
105
+ function buildMenus(opts) {
106
+ return {
107
+ [opts.code]: {
108
+ label: opts.displayName,
109
+ icon: "bi-folder",
110
+ children: Object.fromEntries(
111
+ opts.entities.map((e) => [
112
+ e.name,
113
+ {
114
+ itemType: "V",
115
+ label: e.label,
116
+ dataViewCode: e.name
117
+ }
118
+ ])
119
+ )
120
+ }
121
+ };
122
+ }
123
+ function buildRoles(opts) {
124
+ const rights = {};
125
+ for (const e of opts.entities) rights[e.name] = "SIUDC";
126
+ return {
127
+ [`${opts.code}.admin`]: {
128
+ description: `${opts.displayName} administrators`,
129
+ rights
130
+ }
131
+ };
132
+ }
133
+ function buildActions() {
134
+ return {};
135
+ }
136
+ function buildSettings() {
137
+ return {};
138
+ }
139
+ function buildTranslations(opts) {
140
+ const t = {};
141
+ t[`module.${opts.code}.label`] = opts.displayName;
142
+ if (opts.description) t[`module.${opts.code}.description`] = opts.description;
143
+ for (const e of opts.entities) {
144
+ t[`entity.${e.name}.label`] = e.label;
145
+ t[`view.${e.name}.label`] = e.label;
146
+ t[`menu.${e.name}.label`] = e.label;
147
+ }
148
+ return t;
149
+ }
150
+ function buildSeedData() {
151
+ return [];
152
+ }
153
+ function buildGitignore() {
154
+ return [
155
+ "# Built module package archives",
156
+ "*.dforge",
157
+ "",
158
+ "# Editor / OS noise",
159
+ "node_modules/",
160
+ ".DS_Store",
161
+ "*.swp",
162
+ ""
163
+ ].join("\n");
164
+ }
165
+ // Annotate the CommonJS export names for ESM import in node:
166
+ 0 && (module.exports = {
167
+ buildActions,
168
+ buildDataViews,
169
+ buildEntity,
170
+ buildFolders,
171
+ buildGitignore,
172
+ buildManifest,
173
+ buildMenus,
174
+ buildRoles,
175
+ buildSeedData,
176
+ buildSettings,
177
+ buildTranslations
178
+ });
package/dist/lib.mjs ADDED
@@ -0,0 +1,141 @@
1
+ // src/init/templates.ts
2
+ function buildManifest(opts, moduleId) {
3
+ const today = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
4
+ const manifest = {
5
+ packageFormat: 1,
6
+ moduleId,
7
+ code: opts.code,
8
+ version: opts.version,
9
+ dbSchemaVersion: opts.dbSchemaVersion,
10
+ displayName: opts.displayName,
11
+ entities: Object.fromEntries(
12
+ opts.entities.map((e) => [e.name, `./entities/${e.name}.json`])
13
+ ),
14
+ created: today,
15
+ updated: today
16
+ };
17
+ if (opts.description) manifest.description = opts.description;
18
+ if (opts.author) manifest.author = { name: opts.author };
19
+ if (opts.license) manifest.license = opts.license;
20
+ if (opts.dependencies.length > 0) {
21
+ manifest.dependencies = Object.fromEntries(
22
+ opts.dependencies.map((d) => [d, ">=0.0.1"])
23
+ );
24
+ }
25
+ return manifest;
26
+ }
27
+ function buildEntity(entity) {
28
+ const traits = entity.traits === "identity+audit" ? ["identity", "audit"] : ["identity"];
29
+ return {
30
+ description: entity.label,
31
+ dbObject: entity.name,
32
+ toString: "{id}",
33
+ traits,
34
+ fields: {}
35
+ };
36
+ }
37
+ function buildDataViews(entities) {
38
+ const views = {};
39
+ for (const e of entities) {
40
+ views[e.name] = {
41
+ viewType: "grid",
42
+ label: e.label,
43
+ dataSources: [
44
+ {
45
+ entityCode: e.name,
46
+ columns: []
47
+ }
48
+ ]
49
+ };
50
+ }
51
+ return views;
52
+ }
53
+ function buildFolders(opts) {
54
+ return {
55
+ [opts.code]: {
56
+ label: opts.displayName,
57
+ description: opts.description || opts.displayName,
58
+ icon: "bi-folder",
59
+ color: "#2196F3",
60
+ entities: Object.fromEntries(
61
+ opts.entities.map((e) => [
62
+ e.name,
63
+ { viewName: e.name, quickAdd: true }
64
+ ])
65
+ )
66
+ }
67
+ };
68
+ }
69
+ function buildMenus(opts) {
70
+ return {
71
+ [opts.code]: {
72
+ label: opts.displayName,
73
+ icon: "bi-folder",
74
+ children: Object.fromEntries(
75
+ opts.entities.map((e) => [
76
+ e.name,
77
+ {
78
+ itemType: "V",
79
+ label: e.label,
80
+ dataViewCode: e.name
81
+ }
82
+ ])
83
+ )
84
+ }
85
+ };
86
+ }
87
+ function buildRoles(opts) {
88
+ const rights = {};
89
+ for (const e of opts.entities) rights[e.name] = "SIUDC";
90
+ return {
91
+ [`${opts.code}.admin`]: {
92
+ description: `${opts.displayName} administrators`,
93
+ rights
94
+ }
95
+ };
96
+ }
97
+ function buildActions() {
98
+ return {};
99
+ }
100
+ function buildSettings() {
101
+ return {};
102
+ }
103
+ function buildTranslations(opts) {
104
+ const t = {};
105
+ t[`module.${opts.code}.label`] = opts.displayName;
106
+ if (opts.description) t[`module.${opts.code}.description`] = opts.description;
107
+ for (const e of opts.entities) {
108
+ t[`entity.${e.name}.label`] = e.label;
109
+ t[`view.${e.name}.label`] = e.label;
110
+ t[`menu.${e.name}.label`] = e.label;
111
+ }
112
+ return t;
113
+ }
114
+ function buildSeedData() {
115
+ return [];
116
+ }
117
+ function buildGitignore() {
118
+ return [
119
+ "# Built module package archives",
120
+ "*.dforge",
121
+ "",
122
+ "# Editor / OS noise",
123
+ "node_modules/",
124
+ ".DS_Store",
125
+ "*.swp",
126
+ ""
127
+ ].join("\n");
128
+ }
129
+ export {
130
+ buildActions,
131
+ buildDataViews,
132
+ buildEntity,
133
+ buildFolders,
134
+ buildGitignore,
135
+ buildManifest,
136
+ buildMenus,
137
+ buildRoles,
138
+ buildSeedData,
139
+ buildSettings,
140
+ buildTranslations
141
+ };
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@dforge-core/dforge-cli",
3
- "version": "0.1.0-rc.3",
4
- "description": "dForge CLI \u2014 validate, pack, publish, and install dForge modules. Distributes a single-file native binary per platform via optionalDependencies (esbuild-style).",
3
+ "version": "0.1.0-rc.5",
4
+ "description": "dForge CLI - validate, pack, publish, and install dForge modules. Distributes a single-file native binary per platform via optionalDependencies (esbuild-style).",
5
5
  "license": "MIT",
6
6
  "homepage": "https://github.com/iash44/dForge-core",
7
7
  "repository": {
8
8
  "type": "git",
9
- "url": "https://github.com/dforge-core/dforge-cli.git"
9
+ "url": "git+https://github.com/dforge-core/dforge-cli.git"
10
10
  },
11
11
  "bin": {
12
12
  "dforge-cli": "dist/cli.js"
@@ -16,6 +16,14 @@
16
16
  "README.md"
17
17
  ],
18
18
  "main": "dist/cli.js",
19
+ "exports": {
20
+ ".": "./dist/cli.js",
21
+ "./templates": {
22
+ "types": "./dist/lib.d.ts",
23
+ "import": "./dist/lib.mjs",
24
+ "require": "./dist/lib.js"
25
+ }
26
+ },
19
27
  "engines": {
20
28
  "node": ">=18"
21
29
  },