gorig-cli 1.0.24 → 1.0.26

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.
Files changed (74) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +129 -40
  3. package/commands/create.js +267 -112
  4. package/commands/doc.js +21 -8
  5. package/commands/init.js +316 -255
  6. package/commands/skill.js +55 -17
  7. package/package.json +1 -1
  8. package/templates/config.go.ejs +6 -5
  9. package/templates/config.yaml.ejs +3 -38
  10. package/templates/controller.go.ejs +11 -42
  11. package/templates/crud.controller.go.ejs +71 -0
  12. package/templates/crud.doc.md.ejs +60 -0
  13. package/templates/crud.dto.go.ejs +103 -0
  14. package/templates/crud.integration.init_test.go.ejs +17 -0
  15. package/templates/crud.integration_test.go.ejs +66 -0
  16. package/templates/crud.model.go.ejs +25 -0
  17. package/templates/crud.module.README.md.ejs +70 -0
  18. package/templates/crud.mongo.config.yaml.ejs +19 -0
  19. package/templates/crud.mysql.config.yaml.ejs +14 -0
  20. package/templates/crud.router.go.ejs +18 -0
  21. package/templates/crud.service.go.ejs +179 -0
  22. package/templates/crud.test.go.ejs +52 -0
  23. package/templates/dto.go.ejs +16 -0
  24. package/templates/gitignore.ejs +18 -49
  25. package/templates/hello.controller.go.ejs +19 -0
  26. package/templates/hello.router.go.ejs +12 -0
  27. package/templates/hello.service.go.ejs +31 -0
  28. package/templates/hello.test.go.ejs +34 -0
  29. package/templates/init.go.ejs +1 -27
  30. package/templates/main.go.ejs +2 -5
  31. package/templates/model.go.ejs +3 -4
  32. package/templates/project.README.md.ejs +35 -0
  33. package/templates/router.go.ejs +4 -8
  34. package/templates/service.go.ejs +25 -77
  35. package/templates/skills/gorig-backend/SKILL.md +89 -0
  36. package/templates/skills/gorig-backend/agents/openai.yaml +4 -0
  37. package/templates/skills/gorig-backend/assets/api-doc-template.md +59 -0
  38. package/templates/skills/gorig-backend/assets/gorig.gitignore +65 -0
  39. package/templates/skills/gorig-backend/assets/module-readme-template.md +58 -0
  40. package/templates/skills/gorig-backend/references/advanced-data-access.md +275 -0
  41. package/templates/skills/gorig-backend/references/auth-security.md +194 -0
  42. package/templates/skills/gorig-backend/references/business-scenarios.md +155 -0
  43. package/templates/skills/gorig-backend/references/cache.md +301 -0
  44. package/templates/skills/gorig-backend/references/capability-matrix.md +37 -0
  45. package/templates/skills/gorig-backend/references/configuration.md +48 -0
  46. package/templates/skills/gorig-backend/references/framework-api.md +190 -0
  47. package/templates/skills/gorig-backend/references/messaging.md +143 -0
  48. package/templates/skills/gorig-backend/references/onboarding-files.md +46 -0
  49. package/templates/skills/gorig-backend/references/outbound-http.md +162 -0
  50. package/templates/skills/gorig-backend/references/persistent-crud.md +332 -0
  51. package/templates/skills/gorig-backend/references/project-bootstrap.md +128 -0
  52. package/templates/skills/gorig-backend/references/scheduled-tasks.md +231 -0
  53. package/templates/skills/gorig-backend/references/service-lifecycle.md +51 -0
  54. package/templates/skills/gorig-backend/references/source-map.md +43 -0
  55. package/templates/skills/gorig-backend/references/source-policy.md +58 -0
  56. package/templates/skills/gorig-backend/references/sse.md +121 -0
  57. package/templates/skills/gorig-backend/references/testing.md +171 -0
  58. package/templates/skills/gorig-backend/scripts/check-source-links.sh +48 -0
  59. package/templates/skills/gorig-backend/scripts/detect-gorig-context.sh +67 -0
  60. package/templates/skills/gorig-backend/scripts/verify-basic-project.sh +108 -0
  61. package/npm_publish copy.sh +0 -65
  62. package/templates/internal.go.ejs +0 -49
  63. package/templates/req.go.ejs +0 -8
  64. package/templates/resp.go.ejs +0 -8
  65. package/templates/service.pub.go.ejs +0 -22
  66. package/templates/skills/claude/gorig-backend/SKILL.md +0 -766
  67. package/templates/skills/claude/gorig-backend/assets/api-doc-template.md +0 -50
  68. package/templates/skills/claude/gorig-backend/assets/module-readme-template.md +0 -46
  69. package/templates/skills/claude/gorig-backend/references/onboarding-files.md +0 -44
  70. package/templates/skills/codex/gorig-backend/SKILL.md +0 -766
  71. package/templates/skills/codex/gorig-backend/agents/openai.yaml +0 -4
  72. package/templates/skills/codex/gorig-backend/assets/api-doc-template.md +0 -50
  73. package/templates/skills/codex/gorig-backend/assets/module-readme-template.md +0 -46
  74. package/templates/skills/codex/gorig-backend/references/onboarding-files.md +0 -44
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 jom
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,58 +1,134 @@
1
- # Gorig CLI
1
+ # Gorig CLI: Project Generator and AI Skill Installer
2
2
 
3
- Gorig CLI is a scaffolding tool based on Node.js, used for quickly creating the project structure and modules based on the Gorig framework for Go.
3
+ `gorig-cli` is the command-line entry point for Gorig backend development. It creates runnable Gorig projects, generates feature modules, builds persistence-backed CRUD services, produces API documentation, and installs the `gorig-backend` skill for Codex and Claude.
4
+
5
+ Use it when you want generated code to follow the same Gorig structure and framework conventions instead of starting from ad hoc scaffolding.
6
+
7
+ Main Gorig framework repository: [https://github.com/jom-io/gorig](https://github.com/jom-io/gorig)
8
+
9
+ ## What It Does
10
+
11
+ | Capability | Description |
12
+ |---|---|
13
+ | Project bootstrap | Create a locally runnable Gorig service with `_cmd`, environment configs, domain registration, example routes, and tests. |
14
+ | Module generation | Add flat feature modules under `domain/<module>/` using Router -> Controller -> Service -> Model boundaries. |
15
+ | Persistent CRUD | Generate MySQL or MongoDB CRUD modules backed by Gorig `domainx/dx`, with tests, docs, and non-secret config skeletons. |
16
+ | API documentation | Generate OpenAPI/Redoc documentation for generated HTTP modules. |
17
+ | AI skill installation | Install the bundled `gorig-backend` skill so Codex or Claude can work with Gorig projects using framework-aware rules. |
18
+ | Framework development | Generate projects against a local Gorig checkout with `--gorig-replace` when developing the framework itself. |
4
19
 
5
20
  ## Installation
6
21
 
7
- Install globally using npm:
22
+ Run without installing globally:
23
+
24
+ ```sh
25
+ npx gorig-cli@latest <command>
26
+ ```
27
+
28
+ Or install globally:
8
29
 
9
30
  ```sh
10
31
  npm install -g gorig-cli
32
+ gorig-cli <command>
11
33
  ```
12
34
 
13
- Or run directly using npx:
35
+ ## Create a New Backend
14
36
 
15
37
  ```sh
16
- npx gorig-cli@latest <command>
38
+ npx gorig-cli@latest init my-new-project --no-start
17
39
  ```
18
40
 
19
- ## Quick Start
41
+ Or with a global install:
20
42
 
21
- ### Initialize a New Project
43
+ ```sh
44
+ gorig-cli init my-new-project --no-start
45
+ ```
22
46
 
23
- Use the `init` command to create a new project:
47
+ The generated project includes:
48
+
49
+ - one `_cmd` entry point
50
+ - `local`, `dev`, and `prod` configuration
51
+ - `domain/init.go` registration
52
+ - an example `domain/hello` module
53
+ - tests under `test/`
54
+ - no required MySQL, MongoDB, or Redis dependency in the basic profile
55
+
56
+ Useful automation options:
24
57
 
25
58
  ```sh
26
- gorig-cli init my-new-project
59
+ gorig-cli init my-new-project \
60
+ --module example.com/my-new-project \
61
+ --gorig-version latest \
62
+ --port 9527 \
63
+ --no-start
27
64
  ```
28
65
 
29
- Or use npx:
66
+ For framework development against a local checkout:
30
67
 
31
68
  ```sh
32
- npx gorig-cli@latest init my-new-project
69
+ gorig-cli init my-new-project \
70
+ --gorig-replace ../gorig \
71
+ --no-start \
72
+ --no-git
33
73
  ```
34
74
 
35
- This will create a new project in the current directory, including basic files and directories like `_cmd/main.go`, `domain/init.go`, `cron/cron.go`, etc.
75
+ Use `--force` only when an existing non-empty destination may be replaced. Use `--start` to start immediately; otherwise initialization is non-interactive and does not start the service.
36
76
 
37
- ### Create a New Module
77
+ ## Add a Module
38
78
 
39
- Use the `create` command in the project root directory to create a new module:
79
+ Run from the generated project root:
80
+
81
+ ```sh
82
+ npx gorig-cli@latest create user
83
+ ```
84
+
85
+ Or with a global install:
40
86
 
41
87
  ```sh
42
88
  gorig-cli create user
43
89
  ```
44
90
 
45
- Or use npx:
91
+ This creates:
92
+
93
+ ```text
94
+ domain/user/
95
+ ├── router.go
96
+ ├── controller.go
97
+ ├── service.go
98
+ ├── dto.go
99
+ └── model/
100
+ └── user.go
101
+ ```
102
+
103
+ The generated basic routes are `GET /user/info` and `POST /user/echo`.
104
+
105
+ ## Generate Persistent CRUD
106
+
107
+ Choose the storage backend explicitly:
46
108
 
47
109
  ```sh
48
- npx gorig-cli@latest create user
110
+ # MySQL CRUD module, with HTTP routes enabled by default
111
+ gorig-cli create order --crud --db mysql --db-name Main
112
+
113
+ # MongoDB CRUD module
114
+ gorig-cli create order --crud --db mongo --db-name main
115
+
116
+ # Service/model CRUD only, without router/controller/doc HTTP adapter
117
+ gorig-cli create order --crud --db mysql --no-http
49
118
  ```
50
119
 
51
- This will create a module named `user` in the project, including folders like `api/`, `internal/`, `model/`, and necessary code.
120
+ Persistent CRUD generation currently supports MySQL and MongoDB. The generated code compiles without a live database, but effect-level create/list/page/update/delete verification requires a matching development database configuration.
52
121
 
53
- ### Generate API Documentation
122
+ The CRUD generator preserves existing named connections and adds non-secret configuration skeletons to `_bin/local.yaml`, `_bin/dev.yaml`, `_bin/prod.yaml`, and `test/_bin/local.yaml`.
54
123
 
55
- Use the `doc` command to generate OpenAPI documentation:
124
+ After filling local values or exporting the documented `GORIG_...` variables, run:
125
+
126
+ ```sh
127
+ go test -tags=integration,mysql ./test/... -v
128
+ go test -tags=integration,mongo ./test/... -v
129
+ ```
130
+
131
+ ## Generate API Documentation
56
132
 
57
133
  ```sh
58
134
  # Generate documentation for all modules
@@ -69,47 +145,60 @@ npx gorig-cli@latest doc
69
145
  npx gorig-cli@latest doc user
70
146
  ```
71
147
 
72
- After generating the documentation, you can access it through:
148
+ After generating documentation, access it through:
149
+
150
+ ```text
73
151
  http://127.0.0.1:8080/redoc.html
152
+ ```
74
153
 
75
- ### Install Gorig Skill
154
+ ## Install Gorig Backend Skill
76
155
 
77
- Use the `skill` command to install the bundled `gorig-backend` skill for Codex or Claude:
156
+ The CLI bundles the `gorig-backend` skill for Codex and Claude. Install it when you want AI agents to implement, review, test, or troubleshoot Gorig projects with framework-aware rules.
78
157
 
79
158
  ```sh
80
- # Install both Codex and Claude user-level skills
81
- gorig-cli skill install all
82
-
83
- # Install only the Codex skill
159
+ # Codex global skill
84
160
  gorig-cli skill install codex
85
161
 
86
- # Install Claude user-level skill
87
- gorig-cli skill install claude user
162
+ # Codex and Claude global skills
163
+ gorig-cli skill install all
88
164
 
89
- # Install Claude project-level skill into the current repository
90
- gorig-cli skill install claude project
165
+ # Codex skill stored in the current repository
166
+ gorig-cli skill install codex project
91
167
  ```
92
168
 
93
- Or use npx:
169
+ The install scope defaults to `user`. Use `project` only when the skill should be stored in the current repository.
94
170
 
95
- ```sh
96
- npx gorig-cli@latest skill install all
97
- npx gorig-cli@latest skill install codex
98
- npx gorig-cli@latest skill install claude user
99
- npx gorig-cli@latest skill install claude project
171
+ Example prompts:
172
+
173
+ ```text
174
+ Use the gorig-backend skill to add a MySQL order CRUD module with tests and API docs.
100
175
  ```
101
176
 
102
- ### Run the Project
177
+ ```text
178
+ Use the gorig-backend skill to review startup, routing, config, and middleware usage.
179
+ ```
180
+
181
+ ```text
182
+ Use the gorig-backend skill to add login, protected routes, logout, and security tests.
183
+ ```
103
184
 
104
- After entering the project directory, you can run the project using the following commands:
185
+ ## Run the Project
105
186
 
106
187
  ```sh
107
188
  cd my-new-project
108
- go run _cmd/main.go
189
+ GORIG_SYS_MODE=local go run ./_cmd
109
190
  ```
110
191
 
111
192
  Or run it after building:
112
193
 
113
194
  ```sh
114
- go build -o my-new-project _cmd/main.go && ./my-new-project
195
+ go build -o my-new-project _cmd/main.go
196
+ GORIG_SYS_MODE=local ./my-new-project
115
197
  ```
198
+
199
+ ## Verification Notes
200
+
201
+ - Basic project generation is dependency-light and should build without MySQL, MongoDB, or Redis.
202
+ - Persistent CRUD is generated for MySQL and MongoDB.
203
+ - Database and Redis behavior should be verified against configured development infrastructure.
204
+ - Remote deployment or production mutation should be performed only after explicit authorization.