@antelopejs/dms-frontend 0.0.1
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/LICENSE +190 -0
- package/README.md +131 -0
- package/dist/commands/build.js +66 -0
- package/dist/commands/clean.js +42 -0
- package/dist/commands/dev.js +116 -0
- package/dist/commands/prepare.js +60 -0
- package/dist/commands/start.js +49 -0
- package/dist/commands/verify-source.js +39 -0
- package/dist/common.js +24 -0
- package/dist/config.js +142 -0
- package/dist/discovery.js +123 -0
- package/dist/fs-sync.js +142 -0
- package/dist/index.js +44 -0
- package/dist/layer-watch.js +154 -0
- package/dist/layers.js +120 -0
- package/dist/manifest.js +109 -0
- package/dist/materialize.js +249 -0
- package/dist/ports.js +30 -0
- package/dist/update-check.js +173 -0
- package/dist/utils/cli-ui.js +178 -0
- package/dist/verify-source-runner.js +228 -0
- package/dist/workspace-setup.js +109 -0
- package/dist/workspace.js +76 -0
- package/package.json +97 -0
- package/templates/vue/DmsDynamicPage.vue +89 -0
- package/templates/vue/app-config-stub.mjs +1 -0
- package/templates/vue/app-runtime.ts +240 -0
- package/templates/vue/compress-assets.mjs +48 -0
- package/templates/vue/email-locales.ts +32 -0
- package/templates/vue/email-renderer.ts +159 -0
- package/templates/vue/email-runtime.ts +23 -0
- package/templates/vue/frontend-module.ts +1418 -0
- package/templates/vue/globals.d.ts +1 -0
- package/templates/vue/index.html +24 -0
- package/templates/vue/main.ts +33 -0
- package/templates/vue/npmrc +2 -0
- package/templates/vue/package.json +35 -0
- package/templates/vue/pnpm-workspace.yaml +4 -0
- package/templates/vue/server/auth/backend.mjs +83 -0
- package/templates/vue/server/auth/client-ip.mjs +52 -0
- package/templates/vue/server/auth/oauth.mjs +213 -0
- package/templates/vue/server/auth/routes.mjs +254 -0
- package/templates/vue/server/auth/session.mjs +180 -0
- package/templates/vue/server/client-manifest.mjs +116 -0
- package/templates/vue/server/email.mjs +36 -0
- package/templates/vue/server/inertia.mjs +79 -0
- package/templates/vue/server/render-token.mjs +81 -0
- package/templates/vue/server/tester.mjs +228 -0
- package/templates/vue/server.mjs +526 -0
- package/templates/vue/ssr-renderer.ts +146 -0
- package/templates/vue/tsconfig.json +31 -0
- package/templates/vue/typecheck-loader.mjs +13 -0
- package/templates/vue/vite.config.ts +161 -0
- package/templates/vue/vite.email.config.ts +77 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
Copyright (c) 2025-present - AntelopeJS Team
|
|
179
|
+
|
|
180
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
181
|
+
you may not use this file except in compliance with the License.
|
|
182
|
+
You may obtain a copy of the License at
|
|
183
|
+
|
|
184
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
185
|
+
|
|
186
|
+
Unless required by applicable law or agreed to in writing, software
|
|
187
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
188
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
189
|
+
See the License for the specific language governing permissions and
|
|
190
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
# @antelopejs/dms-frontend
|
|
2
|
+
|
|
3
|
+
<div align="center">
|
|
4
|
+
<a href="./LICENSE"><img alt="License" src="https://img.shields.io/badge/license-Apache--2.0-blue?style=for-the-badge&labelColor=000000"></a>
|
|
5
|
+
<a href="https://discord.gg/sjK28QHrA7"><img src="https://img.shields.io/badge/Discord-18181B?logo=discord&style=for-the-badge&color=000000" alt="Discord"></a>
|
|
6
|
+
<a href="https://antelopejs.com"><img src="https://img.shields.io/badge/Docs-18181B?style=for-the-badge&color=000000" alt="Documentation"></a>
|
|
7
|
+
</div>
|
|
8
|
+
|
|
9
|
+
Official Vue 3, Vite, Inertia, and SSR frontend loader for AntelopeJS DMS. The `ajs dms` CLI generates a Vue workspace and runs its Node frontend server.
|
|
10
|
+
|
|
11
|
+
## Application ownership
|
|
12
|
+
|
|
13
|
+
The generated Inertia application owns page resolution, SSR, hydration, and the
|
|
14
|
+
root Vue tree. Every frontend module explicitly owns its native
|
|
15
|
+
`dms.frontend.ts` entry. That entry registers reusable pages, layouts,
|
|
16
|
+
components, plugins, and middleware through the frontend SDK; the loader does
|
|
17
|
+
not infer application ownership from other framework configuration.
|
|
18
|
+
|
|
19
|
+
## Install
|
|
20
|
+
|
|
21
|
+
The loader is an AntelopeJS CLI plugin: install it next to `@antelopejs/core`
|
|
22
|
+
and `ajs` delegates its `dms` command to the `ajs-dms` executable.
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
pnpm add -g @antelopejs/core @antelopejs/dms-frontend
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
`npm install -g` works too; this repository and every generated workspace use
|
|
29
|
+
pnpm.
|
|
30
|
+
|
|
31
|
+
## Commands
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
ajs dms prepare -b http://localhost:5010
|
|
35
|
+
ajs dms dev -b http://localhost:5010 -p 3001
|
|
36
|
+
ajs dms build -b https://dms.example.com
|
|
37
|
+
ajs dms start -b https://dms.example.com -p 3001
|
|
38
|
+
ajs dms clean -b https://dms.example.com
|
|
39
|
+
ajs dms clean --all
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
`ajs dms <command>` and `ajs-dms <command>` are the same program; the delegation
|
|
43
|
+
only saves you from remembering a second executable name. Package scripts should
|
|
44
|
+
call `ajs-dms` directly so they do not depend on the CLI being installed.
|
|
45
|
+
`--help`, `--version` and `clean` run from any directory. `prepare` also runs
|
|
46
|
+
anywhere: with no backend in reach it warns and exits 0, so a frontend module's
|
|
47
|
+
`postinstall` hook never fails an install, and the generated types are refreshed
|
|
48
|
+
later from a development environment. `dev`, `build` and `start` need a backend
|
|
49
|
+
URL, either through `-b` or through the enclosing antelope project's
|
|
50
|
+
`.antelope/dev.json`, and say so on exit 1 when they have neither;
|
|
51
|
+
`verify-source` needs `--layer` instead.
|
|
52
|
+
|
|
53
|
+
The CLI checks npm for a newer release at most once a day — a failed lookup
|
|
54
|
+
counts as the day's attempt — and prints a one-line notice on stderr. The
|
|
55
|
+
throttle stamp lives at `~/.antelopejs/dms-frontend/update-check.json`. Set
|
|
56
|
+
`NO_UPDATE_NOTIFIER=1`, pass `--no-update-check`, or run under `CI` to turn the
|
|
57
|
+
check off.
|
|
58
|
+
|
|
59
|
+
The loader renders Vue 3 only: a manifest that declares any other renderer is rejected. `prepare`, `dev`, and `build` request the versioned `/dms/frontend` manifest with `renderer=vue&rendererVersion=3`. Modules are materialized under `frontend-modules/` and registered in deterministic manifest-priority order in `generated-frontend-modules.json`.
|
|
60
|
+
|
|
61
|
+
The generated application uses `@inertiajs/vue3`, `@nuxt/ui/vite` with `{ router: "inertia" }`, and `@nuxt/ui/vue-plugin`. The Node server resolves each Inertia visit through `/dms/page?path=…`, including fresh shared data so account, tenant, and permission changes update navigation state. It proxies backend routes and manages authentication through server-side sessions. `DMS_BOOTSTRAP_SECRET` is used only by the CLI's server-to-server frontend manifest and module archive requests and is never sent by, or exposed to, browser traffic.
|
|
62
|
+
|
|
63
|
+
Vue modules use `dms.frontend.ts` and the `#dms-inertia/frontend-module` SDK alias, which replaces the former `#cms-inertia` alias and is the import path every DMS frontend module now uses. Email templates register separately through `dms.email.ts`.
|
|
64
|
+
|
|
65
|
+
An email entry exports `serverEmailTemplates` and may export a plain `appConfig` object, such as shared branding defaults. Email rendering merges these configurations in manifest-priority order and provides them to `useDmsAppConfig` per render. Public runtime options come from the module manifest; `DMS_CLIENT_URL` overrides `public.dms.clientBaseUrl`. Email entries must not import the browser frontend module.
|
|
66
|
+
|
|
67
|
+
Email builds ship complete merged translation catalogs as JSON under `dist/server/locales/`, separate from executable JavaScript. Deploy the entire `dist/server` directory. Each render loads only its requested language and the English fallback; arbitrary translation keys and module overrides remain available. Unknown languages fall back to English, while missing or corrupt files for a supported language fail rendering rather than silently dropping translations. The source harness keeps the 256 KiB JavaScript ceiling and reports locale-data bytes separately.
|
|
68
|
+
|
|
69
|
+
## Frontend modules
|
|
70
|
+
|
|
71
|
+
A materialized module opts into the Vue adapter with a root `dms.frontend.ts`:
|
|
72
|
+
|
|
73
|
+
```ts
|
|
74
|
+
import MyBlock from "./components/MyBlock.vue";
|
|
75
|
+
import MyPage from "./pages/MyPage.vue";
|
|
76
|
+
import type { DmsFrontendModule } from "../../frontend-module";
|
|
77
|
+
|
|
78
|
+
const frontendModule: DmsFrontendModule = {
|
|
79
|
+
setup(sdk) {
|
|
80
|
+
sdk.registerComponent("MyBlock", MyBlock);
|
|
81
|
+
sdk.registerPage("default", MyPage);
|
|
82
|
+
},
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
export default frontendModule;
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
The SDK also exposes `use` for Vue plugins. Entries execute by descending manifest priority, then stable module id. Modules without `dms.frontend.ts` are skipped by the generated loader. Registered page keys match a route's `fullSlug`, request path, or `default`; unregistered pages and components use the generic card renderer.
|
|
89
|
+
|
|
90
|
+
## Discovery, caching, and security
|
|
91
|
+
|
|
92
|
+
In development, `ajs dms` discovers the backend from the nearest live `.antelope/dev.json`. It reads the local bootstrap credential from `.antelope/dms-dev.json` only when that discovered backend matches the destination URL. For production and CI, set `DMS_BACKEND_URL` and `DMS_BOOTSTRAP_SECRET` in the environment rather than passing credentials on the command line.
|
|
93
|
+
|
|
94
|
+
Each canonical backend URL gets an owner-only workspace under `~/.antelopejs/dms-frontend`. Manifest caches, private module configuration, and extracted archives retain restrictive permissions. `--offline` reuses the last successful manifest and archive; an authorization failure never falls back to privileged cached data.
|
|
95
|
+
|
|
96
|
+
## Rendering model
|
|
97
|
+
|
|
98
|
+
The Node server renders full-page requests through the Vite SSR bundle and sends
|
|
99
|
+
the matching Inertia page object to the browser for hydration. Subsequent
|
|
100
|
+
`X-Inertia` visits receive page objects and render client-side. Client-only
|
|
101
|
+
plugins and `DmsClientOnly` defer browser-only work while the same generated
|
|
102
|
+
frontend-module registry drives server and client entries.
|
|
103
|
+
|
|
104
|
+
## Options
|
|
105
|
+
|
|
106
|
+
| Option | Environment | Purpose |
|
|
107
|
+
| --- | --- | --- |
|
|
108
|
+
| `-b, --backend-url` | `DMS_BACKEND_URL` | DMS backend URL |
|
|
109
|
+
| `-p, --port` | `PORT` | Frontend port, default `3001` |
|
|
110
|
+
| `-f, --force` | | Reinstall workspace dependencies |
|
|
111
|
+
| `--offline` | `DMS_OFFLINE` | Reuse cached manifest and archives |
|
|
112
|
+
| `--bootstrap-secret` | `DMS_BOOTSTRAP_SECRET` | Backend bootstrap credential |
|
|
113
|
+
| | `DMS_COOKIE_SECURE` | Secure cookies (`true` by default; `ajs dms dev` defaults to `false`) |
|
|
114
|
+
| | `DMS_TRUSTED_PROXY_HOPS` | Number of trusted, rightmost reverse-proxy hops (default `0`) |
|
|
115
|
+
|
|
116
|
+
Use pnpm for all repository and workspace operations.
|
|
117
|
+
|
|
118
|
+
## Verify local frontend modules
|
|
119
|
+
|
|
120
|
+
Use the packaged source verifier to validate an unpublished DMS frontend package against this exact adapter version. Additional modules and local package bindings are repeatable. All supplied frontend packages are copied into the generated workspace and bound with `workspace:*`.
|
|
121
|
+
|
|
122
|
+
```bash
|
|
123
|
+
ajs dms verify-source \
|
|
124
|
+
--layer /path/to/dms/frontend-vue \
|
|
125
|
+
--module /path/to/module/frontend-vue \
|
|
126
|
+
--local-package @antelopejs/dms=/path/to/dms
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
The verifier prints its generated workspace path, builds client, SSR, and email bundles, runs `vue-tsc`, renders eight DMS email templates, and checks that the email bundle excludes browser-only modules. It leaves the generated workspace in the temporary directory for inspection. It does not start a backend or publish packages. Repository development can invoke the same runner with `DMS_LAYER_SOURCE` through `pnpm test:real-source`.
|
|
130
|
+
|
|
131
|
+
Refresh rotation is single-flight within one frontend process. Horizontally scaled deployments must use sticky routing so a browser reaches the same process, or replace this process-local behavior with an external session adapter. It does not provide a distributed rotation guarantee.
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.cmdBuild = cmdBuild;
|
|
7
|
+
const node_path_1 = require("node:path");
|
|
8
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
9
|
+
const commander_1 = require("commander");
|
|
10
|
+
const common_1 = require("../common");
|
|
11
|
+
const cli_ui_1 = require("../utils/cli-ui");
|
|
12
|
+
function cmdBuild() {
|
|
13
|
+
return new commander_1.Command("build")
|
|
14
|
+
.description("Build for production (downloads layers via ZIP from backend)")
|
|
15
|
+
.addOption(common_1.Options.backendUrl)
|
|
16
|
+
.addOption(common_1.Options.force)
|
|
17
|
+
.addOption(common_1.Options.offline)
|
|
18
|
+
.addOption(common_1.Options.bootstrapSecret)
|
|
19
|
+
.action(async (options) => {
|
|
20
|
+
if (!options.backendUrl) {
|
|
21
|
+
(0, cli_ui_1.error)("Backend URL is required. Use -b <url> or set DMS_BACKEND_URL.");
|
|
22
|
+
process.exit(1);
|
|
23
|
+
}
|
|
24
|
+
const spinner = new cli_ui_1.Spinner("Setting up workspace...");
|
|
25
|
+
await spinner.start();
|
|
26
|
+
try {
|
|
27
|
+
const { workspaceDir, manifestFromCache, manifestFetchedAt } = await (0, common_1.setupWorkspace)({
|
|
28
|
+
backendUrl: options.backendUrl,
|
|
29
|
+
force: !!options.force,
|
|
30
|
+
mode: "build",
|
|
31
|
+
offline: options.offline,
|
|
32
|
+
bootstrapSecret: (0, common_1.normalizeBootstrapSecret)(options.bootstrapSecret),
|
|
33
|
+
});
|
|
34
|
+
await spinner.succeed("Workspace ready");
|
|
35
|
+
if (manifestFromCache) {
|
|
36
|
+
(0, cli_ui_1.warning)(`Building from cached manifest and layers archive${manifestFetchedAt ? ` (cached on ${manifestFetchedAt})` : ""} — output may not match the current backend`);
|
|
37
|
+
}
|
|
38
|
+
console.log("");
|
|
39
|
+
(0, cli_ui_1.info)("Building for production...");
|
|
40
|
+
console.log(chalk_1.default.dim(` Workspace: ${workspaceDir}`));
|
|
41
|
+
console.log("");
|
|
42
|
+
const nodeModulesDir = (0, node_path_1.join)(workspaceDir, "node_modules");
|
|
43
|
+
const code = await (0, common_1.runCommand)("pnpm", ["run", "build"], {
|
|
44
|
+
cwd: workspaceDir,
|
|
45
|
+
env: {
|
|
46
|
+
...process.env,
|
|
47
|
+
NODE_OPTIONS: "--max-old-space-size=4096",
|
|
48
|
+
NODE_PATH: nodeModulesDir,
|
|
49
|
+
},
|
|
50
|
+
});
|
|
51
|
+
if (code === 0) {
|
|
52
|
+
console.log("");
|
|
53
|
+
(0, cli_ui_1.success)("Build completed successfully!");
|
|
54
|
+
console.log(chalk_1.default.dim(" Run 'ajs-dms start' to start the production server"));
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
(0, cli_ui_1.error)("Build failed");
|
|
58
|
+
}
|
|
59
|
+
process.exit(code);
|
|
60
|
+
}
|
|
61
|
+
catch (err) {
|
|
62
|
+
await spinner.fail(`Setup failed: ${err.message}`);
|
|
63
|
+
process.exit(1);
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.cmdClean = cmdClean;
|
|
4
|
+
const node_fs_1 = require("node:fs");
|
|
5
|
+
const commander_1 = require("commander");
|
|
6
|
+
const common_1 = require("../common");
|
|
7
|
+
const cli_ui_1 = require("../utils/cli-ui");
|
|
8
|
+
function cmdClean() {
|
|
9
|
+
return new commander_1.Command("clean")
|
|
10
|
+
.description("Remove workspace build artifacts")
|
|
11
|
+
.addOption(common_1.Options.backendUrl)
|
|
12
|
+
.option("-a, --all", "Clean all workspaces")
|
|
13
|
+
.action(async (options) => {
|
|
14
|
+
console.log("");
|
|
15
|
+
if (options.all) {
|
|
16
|
+
(0, cli_ui_1.info)("Cleaning all workspaces...");
|
|
17
|
+
const workspaces = (0, common_1.listWorkspaces)();
|
|
18
|
+
if (workspaces.length === 0) {
|
|
19
|
+
(0, cli_ui_1.info)("No workspaces found.");
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
for (const ws of workspaces) {
|
|
23
|
+
(0, node_fs_1.rmSync)(ws.dir, { recursive: true, force: true });
|
|
24
|
+
(0, cli_ui_1.success)(`Removed ${ws.dir} (${ws.backendUrl})`);
|
|
25
|
+
}
|
|
26
|
+
console.log("");
|
|
27
|
+
(0, cli_ui_1.success)(`Cleaned ${workspaces.length} workspace(s).`);
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
if (!options.backendUrl) {
|
|
31
|
+
(0, cli_ui_1.warning)("Specify -b <url> to clean a specific workspace, or --all to clean everything.");
|
|
32
|
+
process.exit(1);
|
|
33
|
+
}
|
|
34
|
+
const workspaceDir = (0, common_1.getWorkspaceDir)(options.backendUrl);
|
|
35
|
+
if (!(0, node_fs_1.existsSync)(workspaceDir)) {
|
|
36
|
+
(0, cli_ui_1.info)("Workspace not found — nothing to clean.");
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
(0, node_fs_1.rmSync)(workspaceDir, { recursive: true, force: true });
|
|
40
|
+
(0, cli_ui_1.success)(`Removed workspace: ${workspaceDir}`);
|
|
41
|
+
});
|
|
42
|
+
}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.cmdDev = cmdDev;
|
|
7
|
+
const node_path_1 = require("node:path");
|
|
8
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
9
|
+
const commander_1 = require("commander");
|
|
10
|
+
const common_1 = require("../common");
|
|
11
|
+
const discovery_1 = require("../discovery");
|
|
12
|
+
const ports_1 = require("../ports");
|
|
13
|
+
const cli_ui_1 = require("../utils/cli-ui");
|
|
14
|
+
function clientHost() {
|
|
15
|
+
const host = process.env.HOST?.trim();
|
|
16
|
+
if (!host || host === "0.0.0.0" || host === "::" || host === "[::]") {
|
|
17
|
+
return "localhost";
|
|
18
|
+
}
|
|
19
|
+
return host.includes(":") && !host.startsWith("[") ? `[${host}]` : host;
|
|
20
|
+
}
|
|
21
|
+
function resolveBackend(options) {
|
|
22
|
+
if (options.backendUrl) {
|
|
23
|
+
return { backendUrl: options.backendUrl };
|
|
24
|
+
}
|
|
25
|
+
const result = (0, discovery_1.discoverBackend)(process.cwd());
|
|
26
|
+
if (result.status !== "found") {
|
|
27
|
+
(0, cli_ui_1.error)((0, discovery_1.describeDiscoveryFailure)(result));
|
|
28
|
+
process.exit(1);
|
|
29
|
+
}
|
|
30
|
+
(0, cli_ui_1.info)(`Backend discovered from ${chalk_1.default.cyan(result.backend.projectDir)}: ${chalk_1.default.cyan(result.backend.backendUrl)}`);
|
|
31
|
+
return {
|
|
32
|
+
backendUrl: result.backend.backendUrl,
|
|
33
|
+
workspaceKey: (0, common_1.projectWorkspaceKey)(result.backend.projectDir),
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
function cmdDev() {
|
|
37
|
+
return new commander_1.Command("dev")
|
|
38
|
+
.description("Start development server with hot reload (direct paths, same machine)")
|
|
39
|
+
.addOption(common_1.Options.backendUrl)
|
|
40
|
+
.addOption(common_1.Options.port)
|
|
41
|
+
.addOption(common_1.Options.force)
|
|
42
|
+
.addOption(common_1.Options.offline)
|
|
43
|
+
.addOption(common_1.Options.bootstrapSecret)
|
|
44
|
+
.action(async (options) => {
|
|
45
|
+
const { backendUrl, workspaceKey } = resolveBackend(options);
|
|
46
|
+
const bootstrapSecret = (0, common_1.resolveBootstrapSecret)(options.bootstrapSecret, backendUrl);
|
|
47
|
+
const requestedPort = Number.parseInt(options.port, 10);
|
|
48
|
+
if (Number.isNaN(requestedPort)) {
|
|
49
|
+
(0, cli_ui_1.error)(`Invalid port: ${options.port}`);
|
|
50
|
+
process.exit(1);
|
|
51
|
+
}
|
|
52
|
+
let reserved;
|
|
53
|
+
try {
|
|
54
|
+
reserved = await (0, ports_1.reserveFreePort)(requestedPort);
|
|
55
|
+
}
|
|
56
|
+
catch (err) {
|
|
57
|
+
(0, cli_ui_1.error)(err.message);
|
|
58
|
+
process.exit(1);
|
|
59
|
+
}
|
|
60
|
+
const port = reserved.port;
|
|
61
|
+
if (port !== requestedPort) {
|
|
62
|
+
(0, cli_ui_1.warning)(`Port ${requestedPort} in use, using ${port} instead`);
|
|
63
|
+
}
|
|
64
|
+
const clientUrl = `http://${clientHost()}:${port}`;
|
|
65
|
+
const spinner = new cli_ui_1.Spinner("Setting up workspace...");
|
|
66
|
+
await spinner.start();
|
|
67
|
+
try {
|
|
68
|
+
const { workspaceDir, layers, manifestFromCache, manifestFetchedAt } = await (0, common_1.setupWorkspace)({
|
|
69
|
+
backendUrl,
|
|
70
|
+
force: !!options.force,
|
|
71
|
+
mode: "dev",
|
|
72
|
+
offline: options.offline,
|
|
73
|
+
clientUrl,
|
|
74
|
+
workspaceKey,
|
|
75
|
+
bootstrapSecret,
|
|
76
|
+
});
|
|
77
|
+
await spinner.succeed("Workspace ready");
|
|
78
|
+
if (manifestFromCache) {
|
|
79
|
+
(0, cli_ui_1.warning)(`Using cached layers manifest${manifestFetchedAt ? ` (cached on ${manifestFetchedAt})` : ""} — API calls will fail until the backend is up`);
|
|
80
|
+
}
|
|
81
|
+
const stopWatchers = (0, common_1.startLayerWatchers)(workspaceDir, layers);
|
|
82
|
+
const handleShutdown = async () => {
|
|
83
|
+
await stopWatchers();
|
|
84
|
+
};
|
|
85
|
+
process.once("SIGINT", handleShutdown);
|
|
86
|
+
process.once("SIGTERM", handleShutdown);
|
|
87
|
+
console.log("");
|
|
88
|
+
(0, cli_ui_1.info)(`Starting dev server on port ${chalk_1.default.cyan(String(port))}...`);
|
|
89
|
+
console.log(chalk_1.default.dim(` Workspace: ${workspaceDir}`));
|
|
90
|
+
console.log(chalk_1.default.dim(` Backend: ${backendUrl}`));
|
|
91
|
+
console.log(chalk_1.default.dim(` Watching: ${layers.length} layer source tree(s)`));
|
|
92
|
+
console.log("");
|
|
93
|
+
const nodeModulesDir = (0, node_path_1.join)(workspaceDir, "node_modules");
|
|
94
|
+
await reserved.release();
|
|
95
|
+
const code = await (0, common_1.runCommand)("node", ["server.mjs"], {
|
|
96
|
+
cwd: workspaceDir,
|
|
97
|
+
env: {
|
|
98
|
+
...process.env,
|
|
99
|
+
PORT: String(port),
|
|
100
|
+
DMS_DEV: "true",
|
|
101
|
+
DMS_COOKIE_SECURE: process.env.DMS_COOKIE_SECURE ?? "false",
|
|
102
|
+
DMS_BACKEND_URL: backendUrl,
|
|
103
|
+
DMS_BOOTSTRAP_SECRET: bootstrapSecret,
|
|
104
|
+
NODE_OPTIONS: "--max-old-space-size=4096",
|
|
105
|
+
NODE_PATH: nodeModulesDir,
|
|
106
|
+
},
|
|
107
|
+
});
|
|
108
|
+
await stopWatchers();
|
|
109
|
+
process.exit(code);
|
|
110
|
+
}
|
|
111
|
+
catch (err) {
|
|
112
|
+
await spinner.fail(`Setup failed: ${err.message}`);
|
|
113
|
+
process.exit(1);
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.cmdPrepare = cmdPrepare;
|
|
7
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
8
|
+
const commander_1 = require("commander");
|
|
9
|
+
const common_1 = require("../common");
|
|
10
|
+
const cli_ui_1 = require("../utils/cli-ui");
|
|
11
|
+
function cmdPrepare() {
|
|
12
|
+
return new commander_1.Command("prepare")
|
|
13
|
+
.description("Prepare the generated Vite workspace and frontend-module registry")
|
|
14
|
+
.addOption(common_1.Options.backendUrl)
|
|
15
|
+
.addOption(common_1.Options.force)
|
|
16
|
+
.addOption(common_1.Options.offline)
|
|
17
|
+
.addOption(common_1.Options.bootstrapSecret)
|
|
18
|
+
.action(async (options) => {
|
|
19
|
+
if (!options.backendUrl) {
|
|
20
|
+
(0, cli_ui_1.warning)("Backend URL not set; skipping prepare. Pass -b <url> or set DMS_BACKEND_URL to generate types.");
|
|
21
|
+
process.exit(0);
|
|
22
|
+
}
|
|
23
|
+
const spinner = new cli_ui_1.Spinner("Setting up workspace...");
|
|
24
|
+
await spinner.start();
|
|
25
|
+
let workspaceDir;
|
|
26
|
+
let manifestFromCache;
|
|
27
|
+
let manifestFetchedAt;
|
|
28
|
+
try {
|
|
29
|
+
const result = await (0, common_1.setupWorkspace)({
|
|
30
|
+
backendUrl: options.backendUrl,
|
|
31
|
+
force: !!options.force,
|
|
32
|
+
mode: "dev",
|
|
33
|
+
offline: options.offline,
|
|
34
|
+
bootstrapSecret: (0, common_1.resolveBootstrapSecret)(options.bootstrapSecret, options.backendUrl),
|
|
35
|
+
});
|
|
36
|
+
workspaceDir = result.workspaceDir;
|
|
37
|
+
manifestFromCache = result.manifestFromCache;
|
|
38
|
+
manifestFetchedAt = result.manifestFetchedAt;
|
|
39
|
+
}
|
|
40
|
+
catch (err) {
|
|
41
|
+
await spinner.warn(`Skipping prepare: ${err.message}`);
|
|
42
|
+
process.exit(0);
|
|
43
|
+
}
|
|
44
|
+
await spinner.succeed("Workspace ready");
|
|
45
|
+
if (manifestFromCache) {
|
|
46
|
+
const cachedOn = manifestFetchedAt
|
|
47
|
+
? ` (cached on ${manifestFetchedAt})`
|
|
48
|
+
: "";
|
|
49
|
+
if (options.offline) {
|
|
50
|
+
(0, cli_ui_1.info)(`Offline mode — using cached frontend-module manifest${cachedOn}`);
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
(0, cli_ui_1.warning)(`Backend unreachable — using cached frontend-module manifest${cachedOn}`);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
console.log("");
|
|
57
|
+
(0, cli_ui_1.success)(`Vite workspace prepared ${chalk_1.default.dim(`(${workspaceDir})`)}`);
|
|
58
|
+
process.exit(0);
|
|
59
|
+
});
|
|
60
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.cmdStart = cmdStart;
|
|
7
|
+
const node_fs_1 = require("node:fs");
|
|
8
|
+
const node_path_1 = require("node:path");
|
|
9
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
10
|
+
const commander_1 = require("commander");
|
|
11
|
+
const common_1 = require("../common");
|
|
12
|
+
const cli_ui_1 = require("../utils/cli-ui");
|
|
13
|
+
function cmdStart() {
|
|
14
|
+
return new commander_1.Command("start")
|
|
15
|
+
.description("Start the production server from a built workspace")
|
|
16
|
+
.addOption(common_1.Options.backendUrl)
|
|
17
|
+
.addOption(common_1.Options.port)
|
|
18
|
+
.action(async (options) => {
|
|
19
|
+
if (!options.backendUrl) {
|
|
20
|
+
(0, cli_ui_1.error)("Backend URL is required. Use -b <url> or set DMS_BACKEND_URL.");
|
|
21
|
+
process.exit(1);
|
|
22
|
+
}
|
|
23
|
+
const workspaceDir = (0, common_1.getWorkspaceDir)(options.backendUrl);
|
|
24
|
+
const serverPath = (0, node_path_1.join)(workspaceDir, "server.mjs");
|
|
25
|
+
const clientPath = (0, node_path_1.join)(workspaceDir, "dist", "client", "index.html");
|
|
26
|
+
if (!(0, node_fs_1.existsSync)(serverPath) || !(0, node_fs_1.existsSync)(clientPath)) {
|
|
27
|
+
console.log("");
|
|
28
|
+
(0, cli_ui_1.error)("Production build not found!");
|
|
29
|
+
console.log(chalk_1.default.dim(" Run 'ajs-dms build -b " +
|
|
30
|
+
options.backendUrl +
|
|
31
|
+
"' first to create a production build"));
|
|
32
|
+
process.exit(1);
|
|
33
|
+
}
|
|
34
|
+
console.log("");
|
|
35
|
+
(0, cli_ui_1.info)(`Starting production server on port ${chalk_1.default.cyan(options.port)}...`);
|
|
36
|
+
console.log(chalk_1.default.dim(` Workspace: ${workspaceDir}`));
|
|
37
|
+
console.log("");
|
|
38
|
+
const code = await (0, common_1.runCommand)("node", [serverPath], {
|
|
39
|
+
cwd: workspaceDir,
|
|
40
|
+
env: {
|
|
41
|
+
...process.env,
|
|
42
|
+
PORT: options.port,
|
|
43
|
+
DMS_BACKEND_URL: options.backendUrl,
|
|
44
|
+
DMS_COOKIE_SECURE: process.env.DMS_COOKIE_SECURE ?? "true",
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
process.exit(code);
|
|
48
|
+
});
|
|
49
|
+
}
|