@codenotch/codenotch.cli 1.0.33 → 1.0.35

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 (99) hide show
  1. package/dist/commands/index.js +2 -0
  2. package/dist/commands/index.js.map +1 -1
  3. package/dist/commands/project/new.js +227 -1
  4. package/dist/commands/project/new.js.map +1 -1
  5. package/dist/commands/validation/ValidationUtils.d.ts +28 -0
  6. package/dist/commands/validation/ValidationUtils.js +182 -0
  7. package/dist/commands/validation/ValidationUtils.js.map +1 -0
  8. package/dist/commands/validation/files/AppManifestValidator.d.ts +6 -0
  9. package/dist/commands/validation/files/AppManifestValidator.js +93 -0
  10. package/dist/commands/validation/files/AppManifestValidator.js.map +1 -0
  11. package/dist/commands/validation/files/BpmnValidator.d.ts +5 -0
  12. package/dist/commands/validation/files/BpmnValidator.js +32 -0
  13. package/dist/commands/validation/files/BpmnValidator.js.map +1 -0
  14. package/dist/commands/validation/files/DbSchemaValidator.d.ts +5 -0
  15. package/dist/commands/validation/files/DbSchemaValidator.js +16 -0
  16. package/dist/commands/validation/files/DbSchemaValidator.js.map +1 -0
  17. package/dist/commands/validation/files/DocumentValidator.d.ts +5 -0
  18. package/dist/commands/validation/files/DocumentValidator.js +12 -0
  19. package/dist/commands/validation/files/DocumentValidator.js.map +1 -0
  20. package/dist/commands/validation/files/I18nValidator.d.ts +5 -0
  21. package/dist/commands/validation/files/I18nValidator.js +13 -0
  22. package/dist/commands/validation/files/I18nValidator.js.map +1 -0
  23. package/dist/commands/validation/files/JsonValidator.d.ts +5 -0
  24. package/dist/commands/validation/files/JsonValidator.js +13 -0
  25. package/dist/commands/validation/files/JsonValidator.js.map +1 -0
  26. package/dist/commands/validation/files/ManifestCacheValidator.d.ts +5 -0
  27. package/dist/commands/validation/files/ManifestCacheValidator.js +121 -0
  28. package/dist/commands/validation/files/ManifestCacheValidator.js.map +1 -0
  29. package/dist/commands/validation/files/ManifestValidator.d.ts +5 -0
  30. package/dist/commands/validation/files/ManifestValidator.js +14 -0
  31. package/dist/commands/validation/files/ManifestValidator.js.map +1 -0
  32. package/dist/commands/validation/files/ScriptValidator.d.ts +12 -0
  33. package/dist/commands/validation/files/ScriptValidator.js +128 -0
  34. package/dist/commands/validation/files/ScriptValidator.js.map +1 -0
  35. package/dist/commands/validation/files/TableValidator.d.ts +5 -0
  36. package/dist/commands/validation/files/TableValidator.js +19 -0
  37. package/dist/commands/validation/files/TableValidator.js.map +1 -0
  38. package/dist/commands/validation/validate.d.ts +2 -0
  39. package/dist/commands/validation/validate.js +245 -0
  40. package/dist/commands/validation/validate.js.map +1 -0
  41. package/dist/utils/BuildUtils.d.ts +23 -4
  42. package/dist/utils/BuildUtils.js +46 -16
  43. package/dist/utils/BuildUtils.js.map +1 -1
  44. package/dist/utils/FileUtils.d.ts +13 -0
  45. package/dist/utils/FileUtils.js +30 -0
  46. package/dist/utils/FileUtils.js.map +1 -1
  47. package/dist/utils/I18nUtils.js +0 -2
  48. package/dist/utils/I18nUtils.js.map +1 -1
  49. package/package.json +14 -6
  50. package/.github/copilot-instructions.md +0 -3
  51. package/bin/cli.js +0 -3
  52. package/docs/ARCHITECTURE.md +0 -179
  53. package/docs/TODO.md +0 -18
  54. package/src/bin/cli.ts +0 -4
  55. package/src/commands/index.ts +0 -13
  56. package/src/commands/project/compile.ts +0 -20
  57. package/src/commands/project/deploy.ts +0 -11
  58. package/src/commands/project/index.ts +0 -28
  59. package/src/commands/project/inspect.ts +0 -12
  60. package/src/commands/project/new.ts +0 -11
  61. package/src/commands/project/open.ts +0 -21
  62. package/src/commands/project/package.ts +0 -20
  63. package/src/commands/project/refresh.ts +0 -13
  64. package/src/commands/project/remove.ts +0 -12
  65. package/src/commands/project/shared.ts +0 -9
  66. package/src/commands/project/start.ts +0 -24
  67. package/src/commands/project/test.ts +0 -15
  68. package/src/commands/react/build.ts +0 -12
  69. package/src/commands/react/index.ts +0 -12
  70. package/src/commands/react/serve.ts +0 -13
  71. package/src/commands/runtime/clear.ts +0 -11
  72. package/src/commands/runtime/index.ts +0 -24
  73. package/src/commands/runtime/info.ts +0 -47
  74. package/src/commands/runtime/latest.ts +0 -18
  75. package/src/commands/runtime/portal.ts +0 -20
  76. package/src/commands/runtime/start.ts +0 -16
  77. package/src/commands/runtime/stop.ts +0 -13
  78. package/src/commands/runtime/update.ts +0 -12
  79. package/src/commands/system/index.ts +0 -9
  80. package/src/commands/system/info.ts +0 -23
  81. package/src/commands/system/read.ts +0 -25
  82. package/src/index.ts +0 -22
  83. package/src/models/Codenotch.ts +0 -361
  84. package/src/models/DbModels.ts +0 -428
  85. package/src/models/OpenApiModels.ts +0 -145
  86. package/src/utils/BuildUtils.ts +0 -739
  87. package/src/utils/ConsoleUtils.ts +0 -22
  88. package/src/utils/FileUtils.ts +0 -266
  89. package/src/utils/GitHubAuthUtils.ts +0 -83
  90. package/src/utils/I18nUtils.ts +0 -58
  91. package/src/utils/OpenAPIUtils.ts +0 -285
  92. package/src/utils/OsUtils.ts +0 -32
  93. package/src/utils/ProjectCompilationUtils.ts +0 -1002
  94. package/src/utils/ProjectUtils.ts +0 -151
  95. package/src/utils/RuntimeUtils.ts +0 -743
  96. package/src/utils/ServeUtils.ts +0 -175
  97. package/src/utils/ShellUtils.ts +0 -26
  98. package/src/utils/StringUtils.ts +0 -80
  99. package/tsconfig.json +0 -35
package/package.json CHANGED
@@ -1,8 +1,11 @@
1
1
  {
2
2
  "name": "@codenotch/codenotch.cli",
3
- "version": "1.0.33",
3
+ "version": "1.0.35",
4
4
  "description": "A CLI tool for code management",
5
5
  "main": "dist/index.js",
6
+ "files": [
7
+ "dist"
8
+ ],
6
9
  "bin": {
7
10
  "codenotch-cli": "./dist/bin/cli.js",
8
11
  "cn": "./dist/bin/cli.js"
@@ -15,7 +18,10 @@
15
18
  "prebuild": "npm run clean",
16
19
  "prepare": "npm run build",
17
20
  "pack:check": "npm pack --dry-run",
18
- "release": "npm run build && npm run pack:check && npm publish"
21
+ "release": "npm run build && npm run pack:check && npm publish",
22
+ "test": "vitest run",
23
+ "test:watch": "vitest",
24
+ "test:coverage": "vitest run --coverage"
19
25
  },
20
26
  "keywords": [
21
27
  "cli",
@@ -32,8 +38,8 @@
32
38
  "access": "public"
33
39
  },
34
40
  "dependencies": {
35
- "@codenotch/codenotch.core": "1.0.2",
36
- "@codenotch/codenotch.core.workflow": "1.0.3",
41
+ "@codenotch/codenotch.core": "1.0.20",
42
+ "@codenotch/codenotch.core.workflow": "1.0.21",
37
43
  "@octokit/auth-oauth-device": "^8.0.3",
38
44
  "@types/express": "^5.0.6",
39
45
  "adm-zip": "^0.5.17",
@@ -46,7 +52,8 @@
46
52
  "fs-extra": "^10.0.0",
47
53
  "js2xmlparser": "^5.0.0",
48
54
  "node-fetch": "^3.3.2",
49
- "papaparse": "^5.3.1"
55
+ "papaparse": "^5.3.1",
56
+ "typescript": "^5.9.3"
50
57
  },
51
58
  "devDependencies": {
52
59
  "@types/adm-zip": "^0.5.8",
@@ -55,9 +62,10 @@
55
62
  "@types/json-schema": "^7.0.6",
56
63
  "@types/node": "^20.19.34",
57
64
  "@types/papaparse": "^5.3.1",
65
+ "@vitest/coverage-v8": "^4.1.10",
58
66
  "rimraf": "^5.0.0",
59
67
  "ts-node": "^10.9.2",
60
68
  "tsx": "^4.21.0",
61
- "typescript": "^5.9.3"
69
+ "vitest": "^4.1.10"
62
70
  }
63
71
  }
@@ -1,3 +0,0 @@
1
- Always read `docs/ARCHITECTURE.md` before answering questions about this codebase. It contains the project overview, module map, public API, and core data flow.
2
-
3
- Update the `docs/ARCHITECTURE.md` file if you make any significant changes to the codebase, especially if they affect the public API or core data flow. The architecture document should always reflect the current state of the codebase.
package/bin/cli.js DELETED
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- import '../index.js';
@@ -1,179 +0,0 @@
1
- # Codenotch CLI — Architecture (agent-oriented)
2
-
3
- > Fast-orientation map for AI agents. Optimized for finding the right file quickly, not human onboarding prose.
4
-
5
- ## Purpose
6
-
7
- `codenotch-cli` (binaries `codenotch-cli` and `cn`) is a Node.js/TypeScript command-line tool for the **Codenotch platform**. It manages a local **runtime** (downloaded from GitHub releases of `EchinoHub/service-core`), compiles/packages Codenotch projects (manifest + BPMN processes + AUML/React apps + data tables) into deployable zips, deploys them to the runtime, and builds/serves React applications embedded in projects.
8
-
9
- ## Tech stack & runtime
10
-
11
- | Aspect | Detail |
12
- |--------|--------|
13
- | Language | TypeScript (`strict`), target ES2022, module CommonJS |
14
- | Runtime | Node.js (>= types/node 20), needs Node on PATH |
15
- | Compiler | `tsc` → `dist/` (`rootDir: src`, `outDir: dist`) |
16
- | CLI framework | `commander` v12 |
17
- | Build | `npm run build` (runs `prebuild` → `clean` via `rimraf`) |
18
- | Dev | `npm run dev` (`tsx src/index.ts`) |
19
- | Start | `npm start` (`node dist/index.js`) |
20
- | Install locally | `npm run build` then `npm link` |
21
-
22
- ## Entry points & dispatch
23
-
24
- | File | Role |
25
- |------|------|
26
- | [src/index.ts](src/index.ts) | **Real entry point, bootstrap only.** Loads `.env` from CLI root, creates the `commander` program (name/description/version), calls `registerAllCommands`, ends with `program.parse()`. |
27
- | [src/commands/index.ts](src/commands/index.ts) | `registerAllCommands(program)`: registers each command sector in `--help` order (system → react → runtime → project). |
28
- | [src/bin/cli.ts](src/bin/cli.ts) | Thin shim: `import '../index.js'`. Compiled to `dist/bin/cli.js`, the published `bin` target. |
29
- | [bin/cli.js](bin/cli.js) | Source-tree shim mirroring the above (`import '../index.js'`). |
30
- | `package.json` `bin` | Maps `codenotch-cli` and `cn` → `dist/bin/cli.js`. |
31
-
32
- Flow: `cn <cmd>` → `dist/bin/cli.js` → `dist/index.js` → `registerAllCommands` → commander parses argv → matched `.action()` → delegates to a `*Utils` static method.
33
-
34
- ## Command tree (defined under [src/commands/](src/commands))
35
-
36
- One folder per sector, one file per command. Each command file exports a `register*(parent: Command)` function; each sector's `index.ts` creates the command group and calls them.
37
-
38
- | Command | File | Delegates to |
39
- |---------|------|-------------|
40
- | `info` | [system/info.ts](src/commands/system/info.ts) | inline (system info) |
41
- | `read` | [system/read.ts](src/commands/system/read.ts) | inline (readline test) |
42
- | `react serve [dir]` | [react/serve.ts](src/commands/react/serve.ts) | `ServeUtils.serveApp` |
43
- | `react build [file]` | [react/build.ts](src/commands/react/build.ts) | `BuildUtils.buildApp` |
44
- | `runtime info\|status` | [runtime/info.ts](src/commands/runtime/info.ts) | `RuntimeUtils.isRuntimeInstalled/getRuntimeVersion/...` |
45
- | `runtime update\|install` | [runtime/update.ts](src/commands/runtime/update.ts) | `RuntimeUtils.installLatestRuntime` |
46
- | `runtime start\|stop\|clear` | [runtime/start.ts](src/commands/runtime/start.ts), [stop.ts](src/commands/runtime/stop.ts), [clear.ts](src/commands/runtime/clear.ts) | `RuntimeUtils.startRuntime/stopRuntime/clearRuntime` |
47
- | `runtime latest` | [runtime/latest.ts](src/commands/runtime/latest.ts) | `RuntimeUtils.getLatestRuntimeRelease` |
48
- | `portal` (root command) | [runtime/portal.ts](src/commands/runtime/portal.ts) | `RuntimeUtils.getRuntimeBaseUrl` + `OsUtils.openInBrowser` |
49
- | `project inspect` | [project/inspect.ts](src/commands/project/inspect.ts) | `ProjectUtils.inspectProject` |
50
- | `project open` | [project/open.ts](src/commands/project/open.ts) | `ProjectUtils.getProjectServiceName` + browser |
51
- | `project start` | [project/start.ts](src/commands/project/start.ts) | `RuntimeUtils.startProject` |
52
- | `project refresh\|patch` | [project/refresh.ts](src/commands/project/refresh.ts) | `RuntimeUtils.patchProject` (TODO, stubbed) |
53
- | `project test` | [project/test.ts](src/commands/project/test.ts) | `RuntimeUtils.testProject` |
54
- | `project compile` | [project/compile.ts](src/commands/project/compile.ts) | `ProjectCompilationUtils.compileProject` |
55
- | `project package\|build` | [project/package.ts](src/commands/project/package.ts) | `ProjectUtils.packageProject` |
56
- | `project deploy [service] [zip]` | [project/deploy.ts](src/commands/project/deploy.ts) | `RuntimeUtils.deployProject` |
57
- | `project new` | [project/new.ts](src/commands/project/new.ts) | TODO stub |
58
- | `project remove` | [project/remove.ts](src/commands/project/remove.ts) | `RuntimeUtils.removeProject` |
59
-
60
- Planned commands (validate, query, …) are tracked in [docs/TODO.md](docs/TODO.md).
61
-
62
- ## Layers
63
-
64
- ```mermaid
65
- flowchart TD
66
- Entry[src/index.ts bootstrap] --> CLI[src/commands commander wiring]
67
- CLI --> Utils
68
- subgraph Utils[src/utils]
69
- RU[RuntimeUtils]
70
- PU[ProjectUtils]
71
- PCU[ProjectCompilationUtils]
72
- BU[BuildUtils]
73
- SU[ServeUtils]
74
- end
75
- Utils --> Models[src/models]
76
- RU --> GH[GitHubAuthUtils]
77
- PCU --> OAPI[OpenAPIUtils]
78
- PCU --> I18N[I18nUtils]
79
- Utils --> FU[FileUtils]
80
- Utils --> Sh[ShellUtils]
81
- Utils --> OS[OsUtils]
82
- ```
83
-
84
- - **Commands layer** ([src/commands/](src/commands)) — commander wiring only: one folder per sector (`system/`, `react/`, `runtime/`, `project/`), one file per command. No business logic.
85
- - **Utils layer** ([src/utils/](src/utils)) — all real logic lives here as `abstract class` with `static` methods.
86
- - **Models layer** ([src/models/](src/models)) — plain TS interfaces/classes describing manifests, DB tables, and OpenAPI.
87
-
88
- ## Directory map
89
-
90
- | Path | Responsibility |
91
- |------|---------------|
92
- | [src/index.ts](src/index.ts) | Bootstrap: `.env`, program creation, `registerAllCommands`, `parse`. |
93
- | [src/bin/cli.ts](src/bin/cli.ts) | Published bin shim → imports `index`. |
94
- | [bin/cli.js](bin/cli.js) | Source-tree bin shim. |
95
- | [src/commands/index.ts](src/commands/index.ts) | `registerAllCommands`: registers all sectors in `--help` order. |
96
- | [src/commands/system/](src/commands/system) | Root-level misc commands: `info`, `read`. |
97
- | [src/commands/react/](src/commands/react) | `react` group: `build`, `serve`. |
98
- | [src/commands/runtime/](src/commands/runtime) | `runtime` group: `info`, `update`, `start`, `stop`, `clear`, `latest` + root `portal`. |
99
- | [src/commands/project/](src/commands/project) | `project` group: `inspect`, `open`, `start`, `refresh`, `test`, `compile`, `package`, `deploy`, `new`, `remove`. |
100
- | [src/commands/project/shared.ts](src/commands/project/shared.ts) | `withProjectPathOption` helper + `IProjectCommandOptions` (shared `-p, --project-path`). |
101
- | [src/utils/RuntimeUtils.ts](src/utils/RuntimeUtils.ts) | Install/update/start/stop/clear runtime; meta (`runtime.json`/`runtime.pid`) in `~/.codenotch` (or `CODENOTCH_PATH`); start/test/deploy/remove projects; admin token. |
102
- | [src/utils/ProjectUtils.ts](src/utils/ProjectUtils.ts) | `packageProject` (copy→compile→zip in tmp), `getManifest`, `getProjectServiceName`, `inspectProject`. Reads `manifest.json`. |
103
- | [src/utils/ProjectCompilationUtils.ts](src/utils/ProjectCompilationUtils.ts) | Core compiler: generate `ProjectManifest`, DB schema XML, OpenAPI; parse BPMN via `@echino/codenotch.core.workflow`; **in-place** file mutation. |
104
- | [src/utils/BuildUtils.ts](src/utils/BuildUtils.ts) | `cn react build`: finds workspace manifest, scaffolds Vite/TS/index for a React app, fetches tenant/env vars, builds. |
105
- | [src/utils/ServeUtils.ts](src/utils/ServeUtils.ts) | `cn react serve`: Express static server with SPA fallback; reads AUML/env variables. |
106
- | [src/utils/OpenAPIUtils.ts](src/utils/OpenAPIUtils.ts) | Generate OpenAPI 3.0 spec from compiled processes/variables. |
107
- | [src/utils/I18nUtils.ts](src/utils/I18nUtils.ts) | Parse `*.i18n.csv` files (papaparse) and merge translations by key. |
108
- | [src/utils/GitHubAuthUtils.ts](src/utils/GitHubAuthUtils.ts) | GitHub OAuth device flow (`@octokit/auth-oauth-device`); token cached in OS keychain (`cross-keychain`); honors `GITHUB_TOKEN`. |
109
- | [src/utils/FileUtils.ts](src/utils/FileUtils.ts) | Filesystem helpers: zip (`adm-zip`), copy/move/delete folders, recursive file listing, path normalize. |
110
- | [src/utils/ShellUtils.ts](src/utils/ShellUtils.ts) | `exec(location, command)` wrapper around `child_process.exec`. |
111
- | [src/utils/OsUtils.ts](src/utils/OsUtils.ts) | OS abstraction: `openInBrowser` (platform-specific). |
112
- | [src/utils/ConsoleUtils.ts](src/utils/ConsoleUtils.ts) | Chalk-styled console helpers (`check`, `checkWarning`, `proposeCommand`, `proposeOpenUri`). |
113
- | [src/utils/StringUtils.ts](src/utils/StringUtils.ts) | String/path helpers: `firstUpper`, `toRelativePath`, `normalizePath`, `getNameWithoutExtention`. |
114
- | [src/models/Codenotch.ts](src/models/Codenotch.ts) | `ProjectManifest` + sub-types (apis, applications, react apps, processes, datastores, roles…), `IScenarioProjectManifest`, `ApplicationManifest`/PWA/AUML, `IWorkspaceCache`, `ProjectState`. |
115
- | [src/models/DbModels.ts](src/models/DbModels.ts) | `TableDefinition`, `FieldTypes` enum, field/relation interfaces → used to emit DB schema XML. |
116
- | [src/models/OpenApiModels.ts](src/models/OpenApiModels.ts) | `OpenAPISpec` (OpenAPI 3.0), `APIInfo`, parameter/response interfaces. |
117
-
118
- ## Key flows
119
-
120
- ### CLI command → execution
121
- 1. `cn project package` → commander matches in [src/commands/project/package.ts](src/commands/project/package.ts).
122
- 2. `.action()` reads `--project-path` (default `process.cwd()`) and `--output-path`.
123
- 3. Calls `ProjectUtils.packageProject(projectPath, outputPath)`.
124
-
125
- ### Package a project ([ProjectUtils.packageProject](src/utils/ProjectUtils.ts))
126
- `mkdtemp` → `FileUtils.copyFolder` (excludes `.git/node_modules/dist/build/out`) → `ProjectCompilationUtils.compileProject` (in-place on the copy) → `FileUtils.zipFolder` → cleanup tmp. Returns `CompilationResult { errors, warnings }`.
127
-
128
- ### Compile ([ProjectCompilationUtils.compileProject](src/utils/ProjectCompilationUtils.ts))
129
- Builds `CompilationContext` → `generateManifest` (scans files, parses BPMN via `@echino/codenotch.core.workflow`) → `OpenApiUtils.generateOpenApi` → `generateDbSchema` (XML via `js2xmlparser` from `DbModels`). Writes `manifest.json`, `openapi.json`, `dbschema.xml`.
130
-
131
- ### Runtime lifecycle ([RuntimeUtils](src/utils/RuntimeUtils.ts))
132
- Install dir = `CODENOTCH_PATH` or `~/.codenotch`. `installLatestRuntime` authenticates via `GitHubAuthUtils.getToken`, downloads release asset, decompresses (`decompress`). State tracked in `runtime.pid` + `runtime.json`. `startRuntime` spawns the executable; project ops talk to it over HTTP (`getRuntimeBaseUrl`, default `http://127.0.0.1:5005`).
133
-
134
- ## Conventions & patterns
135
-
136
- - **Static utility classes**: every util is `export default abstract class XxxUtils` (or named export) with only `static` methods. No instances, no DI.
137
- - **Command → Util delegation**: command files ([src/commands/](src/commands)) stay thin; logic lives in utils.
138
- - **Command registration**: each command file exports `register<Name>(parent: Command)`; each sector `index.ts` exports `register<Sector>Commands(program)`; file names are lowercase and mirror the command name (`runtime/start.ts` ↔ `cn runtime start`).
139
- - **Project path option**: shared via `withProjectPathOption(command)` helper ([src/commands/project/shared.ts](src/commands/project/shared.ts)); defaults to `process.cwd()`.
140
- - **Error handling**: user-facing failures print `chalk.red(...)` then `process.exit(1)`; deeper code throws `Error` with wrapped messages.
141
- - **Output styling**: `chalk` everywhere; structured helpers in `ConsoleUtils`. Many commands support `--json` for machine output.
142
- - **i18n**: CSV-based (`*.i18n.csv`) parsed by `I18nUtils`; embedded into compiled AUML output.
143
- - **OS/shell abstraction**: `OsUtils` (browser/platform), `ShellUtils` (exec), `FileUtils`/`StringUtils` (paths, normalized with `FileUtils.slash()`).
144
- - **Config**: `.env` loaded from CLI root in `index.ts` (`dotenv`). Key vars: `CODENOTCH_PATH`, `GITHUB_TOKEN`.
145
- - **TODOs**: several commands are stubbed (`project new`, `project refresh/patch`); planned commands are listed in [docs/TODO.md](docs/TODO.md).
146
-
147
- ## External integrations
148
-
149
- | Dependency | Used for | Where |
150
- |-----------|----------|-------|
151
- | `commander` | CLI parsing/dispatch | [src/index.ts](src/index.ts), [src/commands/](src/commands) |
152
- | `@octokit/auth-oauth-device` + `cross-keychain` | GitHub device-flow auth, token in OS keychain | [src/utils/GitHubAuthUtils.ts](src/utils/GitHubAuthUtils.ts) |
153
- | `@echino/codenotch.core.workflow` | BPMN → workflow model parsing | [src/utils/ProjectCompilationUtils.ts](src/utils/ProjectCompilationUtils.ts) |
154
- | `express` | Static/SPA dev server | [src/utils/ServeUtils.ts](src/utils/ServeUtils.ts) |
155
- | `adm-zip` | Zip project package | [src/utils/FileUtils.ts](src/utils/FileUtils.ts) |
156
- | `decompress` | Extract downloaded runtime | [src/utils/RuntimeUtils.ts](src/utils/RuntimeUtils.ts) |
157
- | `node-fetch` / global `fetch` | HTTP to GitHub & runtime | RuntimeUtils, BuildUtils, GitHubAuthUtils |
158
- | `js2xmlparser` | DB schema XML emit | [src/utils/ProjectCompilationUtils.ts](src/utils/ProjectCompilationUtils.ts) |
159
- | `papaparse` | Parse i18n CSV | [src/utils/I18nUtils.ts](src/utils/I18nUtils.ts) |
160
- | `chalk` | Colored output | everywhere |
161
- | `fs-extra` | Extended FS ops | [src/utils/BuildUtils.ts](src/utils/BuildUtils.ts) |
162
- | `dotenv` | Load `.env` | [src/index.ts](src/index.ts) |
163
-
164
- ## "Where to look" index
165
-
166
- | Task | Start here |
167
- |------|-----------|
168
- | Add/modify a CLI command or option | [src/commands/](src/commands) — folder = sector, file = command; new sector → register it in [src/commands/index.ts](src/commands/index.ts) |
169
- | Planned/upcoming commands | [docs/TODO.md](docs/TODO.md) |
170
- | Change runtime install/start/stop/deploy | [src/utils/RuntimeUtils.ts](src/utils/RuntimeUtils.ts) |
171
- | Change how projects are compiled/packaged | [src/utils/ProjectCompilationUtils.ts](src/utils/ProjectCompilationUtils.ts), [src/utils/ProjectUtils.ts](src/utils/ProjectUtils.ts) |
172
- | OpenAPI generation | [src/utils/OpenAPIUtils.ts](src/utils/OpenAPIUtils.ts), [src/models/OpenApiModels.ts](src/models/OpenApiModels.ts) |
173
- | DB schema / table types | [src/utils/ProjectCompilationUtils.ts](src/utils/ProjectCompilationUtils.ts), [src/models/DbModels.ts](src/models/DbModels.ts) |
174
- | React app build/serve | [src/utils/BuildUtils.ts](src/utils/BuildUtils.ts), [src/utils/ServeUtils.ts](src/utils/ServeUtils.ts) |
175
- | GitHub auth issues | [src/utils/GitHubAuthUtils.ts](src/utils/GitHubAuthUtils.ts) |
176
- | Manifest shape / project model | [src/models/Codenotch.ts](src/models/Codenotch.ts) |
177
- | i18n CSV handling | [src/utils/I18nUtils.ts](src/utils/I18nUtils.ts) |
178
- | File/zip/path helpers | [src/utils/FileUtils.ts](src/utils/FileUtils.ts), [src/utils/StringUtils.ts](src/utils/StringUtils.ts) |
179
- | Build/dev/start scripts | `package.json` `scripts` |
package/docs/TODO.md DELETED
@@ -1,18 +0,0 @@
1
- # TODO — upcoming commands
2
-
3
- - validate bpmn
4
- - validate .table
5
- - validate .jschema
6
- - validate manifest.json
7
- - validate i18n
8
- - validate full projet
9
- - generate manifest.cache.json
10
- - query table (sioql on local cluster)
11
- - query document (sioql on local cluster)
12
- - **get npmrc token ? (until codenotch-react fully public )
13
- - auto generate bpmn diagram
14
- - generate db schema
15
- - compile :
16
- - generate db schema
17
- - auto generate bpmn diagram
18
- - generate manifest.cache.json
package/src/bin/cli.ts DELETED
@@ -1,4 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- // Redirection vers le fichier principal
4
- import '../index.js';
@@ -1,13 +0,0 @@
1
- import { Command } from 'commander';
2
- import { registerSystemCommands } from './system';
3
- import { registerReactCommands } from './react';
4
- import { registerRuntimeCommands } from './runtime';
5
- import { registerProjectCommands } from './project';
6
-
7
- // Registration order defines the order in `--help`
8
- export function registerAllCommands(program: Command) {
9
- registerSystemCommands(program);
10
- registerReactCommands(program);
11
- registerRuntimeCommands(program);
12
- registerProjectCommands(program);
13
- }
@@ -1,20 +0,0 @@
1
- import { Command } from 'commander';
2
- import chalk from 'chalk';
3
- import ProjectCompilationUtils from '../../utils/ProjectCompilationUtils';
4
- import { IProjectCommandOptions, withProjectPathOption } from './shared';
5
-
6
- export function registerCompile(project: Command) {
7
- withProjectPathOption(project
8
- .command('compile')
9
- .description('Compile the project, modify the source files in-place'))
10
- .action(async (options: IProjectCommandOptions) => {
11
- const compilation = await ProjectCompilationUtils.compileProject(options.projectPath);
12
- if (compilation.errors.length > 0) {
13
- console.error(chalk.red("Compilation failed with errors:"));
14
- compilation.errors.forEach(err => console.error(chalk.red(`- ${err}`)));
15
- }
16
- else {
17
- console.log(chalk.green(`Project compiled successfully`));
18
- }
19
- });
20
- }
@@ -1,11 +0,0 @@
1
- import { Command } from 'commander';
2
- import RuntimeUtils from '../../utils/RuntimeUtils';
3
-
4
- export function registerDeploy(project: Command) {
5
- project
6
- .command('deploy [service] [zip]')
7
- .description('Deploy the project package to the runtime')
8
- .action(async (service: string, zip: string) => {
9
- await RuntimeUtils.deployProject(service, zip);
10
- });
11
- }
@@ -1,28 +0,0 @@
1
- import { Command } from 'commander';
2
- import { registerInspect } from './inspect';
3
- import { registerOpen } from './open';
4
- import { registerStart } from './start';
5
- import { registerRefresh } from './refresh';
6
- import { registerTest } from './test';
7
- import { registerCompile } from './compile';
8
- import { registerPackage } from './package';
9
- import { registerDeploy } from './deploy';
10
- import { registerNew } from './new';
11
- import { registerRemove } from './remove';
12
-
13
- export function registerProjectCommands(program: Command) {
14
- const project = program
15
- .command('project') //TODO name subject to change
16
- .description('Project specific commands, run these commands inside a project folder or specify the project path');
17
-
18
- registerInspect(project);
19
- registerOpen(project);
20
- registerStart(project);
21
- registerRefresh(project);
22
- registerTest(project);
23
- registerCompile(project);
24
- registerPackage(project);
25
- registerDeploy(project);
26
- registerNew(project);
27
- registerRemove(project);
28
- }
@@ -1,12 +0,0 @@
1
- import { Command } from 'commander';
2
- import ProjectUtils from '../../utils/ProjectUtils';
3
- import { IProjectCommandOptions, withProjectPathOption } from './shared';
4
-
5
- export function registerInspect(project: Command) {
6
- withProjectPathOption(project
7
- .command('inspect')
8
- .description('Parse the project and display its structure and configuration'))
9
- .action(async (options: IProjectCommandOptions) => {
10
- await ProjectUtils.inspectProject(options.projectPath);
11
- });
12
- }
@@ -1,11 +0,0 @@
1
- import { Command } from 'commander';
2
- import { IProjectCommandOptions, withProjectPathOption } from './shared';
3
-
4
- export function registerNew(project: Command) {
5
- withProjectPathOption(project
6
- .command('new')
7
- .description('Create a new project'))
8
- .action(async (options: IProjectCommandOptions) => {
9
- console.log("TODO Not implemented yet");
10
- });
11
- }
@@ -1,21 +0,0 @@
1
- import { Command } from 'commander';
2
- import chalk from 'chalk';
3
- import RuntimeUtils from '../../utils/RuntimeUtils';
4
- import ProjectUtils from '../../utils/ProjectUtils';
5
- import { OsUtils } from '../../utils/OsUtils';
6
- import { IProjectCommandOptions, withProjectPathOption } from './shared';
7
-
8
- export function registerOpen(project: Command) {
9
- withProjectPathOption(project
10
- .command('open')
11
- .description('Open the index page of the project in the default browser'))
12
- .action(async (options: IProjectCommandOptions) => {
13
- if ((await RuntimeUtils.isRuntimeRunning()) === false) {
14
- console.log(chalk.yellow(`Codenotch runtime is not running`));
15
- return;
16
- }
17
- const basePath = await RuntimeUtils.getRuntimeBaseUrl();
18
- const serviceName = await ProjectUtils.getProjectServiceName(options.projectPath);
19
- OsUtils.openInBrowser(`${basePath}/${serviceName}`);
20
- });
21
- }
@@ -1,20 +0,0 @@
1
- import { Command } from 'commander';
2
- import chalk from 'chalk';
3
- import path from 'path';
4
- import ProjectUtils from '../../utils/ProjectUtils';
5
- import { IProjectCommandOptions, withProjectPathOption } from './shared';
6
-
7
- export function registerPackage(project: Command) {
8
- withProjectPathOption(project
9
- .command('package')
10
- .alias('build')
11
- .description('Compile and package the project, output a zip file')
12
- .option('-o, --output-path <path>', 'output path for the build zip file')
13
- .option('-i, --ignore-errors', 'ignore compilation errors and proceed with packaging', false))
14
- .action(async (options: IProjectCommandOptions & { outputPath?: string, ignoreErrors?: boolean }) => {
15
- const outputPath = options.outputPath ?? path.join(options.projectPath, "build.zip");
16
- const ignoreErrors = options.ignoreErrors ?? false;
17
- await ProjectUtils.packageProject(options.projectPath, outputPath, ignoreErrors);
18
- console.log(chalk.green(`Project built successfully at ${outputPath}`));
19
- });
20
- }
@@ -1,13 +0,0 @@
1
- import { Command } from 'commander';
2
- import { IProjectCommandOptions, withProjectPathOption } from './shared';
3
-
4
- export function registerRefresh(project: Command) {
5
- withProjectPathOption(project
6
- .command('refresh')
7
- .alias('patch')
8
- .description('Sync the project with the runtime, deploy changes and restart if needed'))
9
- .action(async (options: IProjectCommandOptions) => {
10
- console.log("TODO Not implemented yet");
11
- //await RuntimeUtils.patchProject(options.projectPath);
12
- });
13
- }
@@ -1,12 +0,0 @@
1
- import { Command } from 'commander';
2
- import RuntimeUtils from '../../utils/RuntimeUtils';
3
- import { IProjectCommandOptions, withProjectPathOption } from './shared';
4
-
5
- export function registerRemove(project: Command) {
6
- withProjectPathOption(project
7
- .command('remove')
8
- .description('Uninstall the project and erase its data (use with caution)'))
9
- .action(async (options: IProjectCommandOptions) => {
10
- await RuntimeUtils.removeProject(options.projectPath);
11
- });
12
- }
@@ -1,9 +0,0 @@
1
- import { Command } from 'commander';
2
-
3
- // These commands apply to a project, default to current directory
4
- export type IProjectCommandOptions = {
5
- projectPath: string;
6
- };
7
-
8
- export const withProjectPathOption = (command: Command): Command =>
9
- command.option('-p, --project-path <path>', 'path to the project directory (default current directory)', process.cwd());
@@ -1,24 +0,0 @@
1
- import { Command } from 'commander';
2
- import RuntimeUtils from '../../utils/RuntimeUtils';
3
- import ProjectUtils from '../../utils/ProjectUtils';
4
- import { OsUtils } from '../../utils/OsUtils';
5
- import { IProjectCommandOptions, withProjectPathOption } from './shared';
6
-
7
- export function registerStart(project: Command) {
8
- withProjectPathOption(project
9
- .command('start')
10
- .description('Build, deploy and start the local project')
11
- .option('-q, --quiet', 'do not open the project in the browser after starting', false)
12
- //TODO expose runtime start args here ?
13
- //TODO --watch (auto apply chnages with patch without restarting the runtime, for development purposes)
14
- )
15
- .action(async (options: IProjectCommandOptions & { quiet: boolean }) => {
16
- await RuntimeUtils.startProject(options.projectPath);
17
-
18
- if (!options.quiet) {
19
- const basePath = await RuntimeUtils.getRuntimeBaseUrl();
20
- const serviceName = await ProjectUtils.getProjectServiceName(options.projectPath);
21
- OsUtils.openInBrowser(`${basePath}/${serviceName}`);
22
- }
23
- });
24
- }
@@ -1,15 +0,0 @@
1
- import { Command } from 'commander';
2
- import RuntimeUtils from '../../utils/RuntimeUtils';
3
- import { IProjectCommandOptions, withProjectPathOption } from './shared';
4
-
5
- export function registerTest(project: Command) {
6
- withProjectPathOption(project
7
- .command('test')
8
- .description('Run tests for the project')
9
- .option('-f, --file-filter <pattern>', 'filter test files by pattern')
10
- .option('-t, --name-filter <pattern>', 'filter tests by name pattern')
11
- .option('--in-place', 'if compilation is needed, compile and modify files directly in the project folder', false))
12
- .action(async (options: IProjectCommandOptions & { fileFilter?: string, nameFilter?: string, inPlace?: boolean }) => {
13
- await RuntimeUtils.testProject(options.projectPath, options.fileFilter, options.nameFilter, options.inPlace);
14
- });
15
- }
@@ -1,12 +0,0 @@
1
- import { Command } from 'commander';
2
- import BuildUtils, { IBuildOptions } from '../../utils/BuildUtils';
3
-
4
- export function registerBuild(react: Command) {
5
- react
6
- .command('build [file]')
7
- .description('Build a React application inside Codenotch project')
8
- .option('-c, --cluster <url>', 'Cluster URL to make the .env file.')
9
- .action(async (filePath: string, options: IBuildOptions) => {
10
- await BuildUtils.buildApp(filePath, options.cluster);
11
- });
12
- }
@@ -1,12 +0,0 @@
1
- import { Command } from 'commander';
2
- import { registerServe } from './serve';
3
- import { registerBuild } from './build';
4
-
5
- export function registerReactCommands(program: Command) {
6
- const react = program
7
- .command('react')
8
- .description('React application management commands');
9
-
10
- registerServe(react);
11
- registerBuild(react);
12
- }
@@ -1,13 +0,0 @@
1
- import { Command } from 'commander';
2
- import ServeUtils, { IServeOptions } from '../../utils/ServeUtils';
3
-
4
- export function registerServe(react: Command) {
5
- react
6
- .command('serve [directory]')
7
- .description('Serve a built React application using a simple HTTP server')
8
- .option('-p, --port <port>', 'port to serve the application on (default 5000)', (value: string) => parseInt(value, 10), 5000)
9
- .option('-i, --index <name>', 'index file name (default index.html)', 'index.html')
10
- .action(async (directory: string, options: IServeOptions) => {
11
- await ServeUtils.serveApp(directory, options);
12
- });
13
- }
@@ -1,11 +0,0 @@
1
- import { Command } from 'commander';
2
- import RuntimeUtils from '../../utils/RuntimeUtils';
3
-
4
- export function registerClear(runtime: Command) {
5
- runtime
6
- .command('clear')
7
- .description('Erase all runtime data (ie. all projects, users, ...) but keep the runtime itself (use with caution)')
8
- .action(async () => {
9
- await RuntimeUtils.clearRuntime();
10
- });
11
- }
@@ -1,24 +0,0 @@
1
- import { Command } from 'commander';
2
- import { registerInfo } from './info';
3
- import { registerUpdate } from './update';
4
- import { registerStart } from './start';
5
- import { registerStop } from './stop';
6
- import { registerClear } from './clear';
7
- import { registerLatest } from './latest';
8
- import { registerPortal } from './portal';
9
-
10
- // General commands on the runtime, probably not directly useful for users but good to have for debugging and development purposes, we can hide them later if we want
11
- export function registerRuntimeCommands(program: Command) {
12
- const runtime = program
13
- .command('runtime') //TODO name subject to change
14
- .description('Runtime specific commands, use these commands to manage the Codenotch runtime.');
15
-
16
- registerInfo(runtime);
17
- registerUpdate(runtime);
18
- registerStart(runtime);
19
- registerStop(runtime);
20
- registerClear(runtime);
21
- registerLatest(runtime);
22
-
23
- registerPortal(program);
24
- }
@@ -1,47 +0,0 @@
1
- import { Command } from 'commander';
2
- import chalk from 'chalk';
3
- import RuntimeUtils from '../../utils/RuntimeUtils';
4
-
5
- export function registerInfo(runtime: Command) {
6
- runtime
7
- .command('info')
8
- .alias('status')
9
- .description('Display Codenotch runtime status and version information')
10
- .option('--json', 'output the result in JSON format')
11
- .action(async (options: { json: boolean }) => {
12
-
13
- const isInstalled = await RuntimeUtils.isRuntimeInstalled();
14
- if (options.json) {
15
- if (isInstalled === false) {
16
- console.log(JSON.stringify({ installed: false }));
17
- return;
18
- }
19
- const version = await RuntimeUtils.getRuntimeVersion();
20
- const runtimePath = RuntimeUtils.getRuntimeExecutablePath();
21
- const baseUrl = await RuntimeUtils.getRuntimeBaseUrl();
22
- const isRunning = await RuntimeUtils.isRuntimeRunning();
23
- const dataPath = await RuntimeUtils.getRuntimeDataPath();
24
- console.log(JSON.stringify({ installed: true, version, path: runtimePath, url: baseUrl, running: isRunning, dataPath: dataPath }));
25
- return;
26
- }
27
-
28
- if (isInstalled === false) {
29
- console.log(chalk.yellow(`Codenotch runtime is not installed. Use "codenotch runtime install" to install the latest version.`));
30
- return;
31
- }
32
- const version = await RuntimeUtils.getRuntimeVersion(); // Requires running the runtime which is a bit slow
33
- console.log(chalk.green(`Version: ${version}`));
34
- const runtimePath = RuntimeUtils.getRuntimeExecutablePath();
35
- console.log(chalk.green(`Codenotch runtime is installed at: ${runtimePath}`));
36
- const baseUrl = await RuntimeUtils.getRuntimeBaseUrl();
37
- console.log(chalk.green(`URL: ${baseUrl}`));
38
- const isRunning = await RuntimeUtils.isRuntimeRunning();
39
- console.log(chalk.green(`Status: ${isRunning ? 'Running' : 'Not running'}`));
40
- const dataPath = await RuntimeUtils.getRuntimeDataPath();
41
- if (dataPath) {
42
- console.log(chalk.green(`Data path: ${dataPath}`));
43
- }
44
-
45
- //TODO check if an update is available and suggest updating if that's the case
46
- });
47
- }