@neuxnet/neux-cli 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +438 -0
- package/README.zh-CN.md +554 -0
- package/assets/container/assets/index.css +1 -0
- package/assets/container/assets/index.js +137 -0
- package/assets/container/assets/pageFrame.css +1 -0
- package/assets/container/assets/pageFrame.js +56 -0
- package/assets/container/assets/service.js +6 -0
- package/assets/container/assets/vconsole.js +931 -0
- package/assets/container/favicon.ico +0 -0
- package/assets/container/images/icon-arrow.png +0 -0
- package/assets/container/images/mini-action-white.png +0 -0
- package/assets/container/images/mini-action.png +0 -0
- package/assets/container/images/mini-arrow-left-white.png +0 -0
- package/assets/container/images/mini-arrow-left.jpg +0 -0
- package/assets/container/images/mini-arrow-left.png +0 -0
- package/assets/container/images/mini-close-white.png +0 -0
- package/assets/container/images/mini-close.png +0 -0
- package/assets/container/images/more.png +0 -0
- package/assets/container/images/search.jpg +0 -0
- package/assets/container/index.html +1 -0
- package/assets/container/pageFrame.html +1 -0
- package/assets/init/tabbar/home-active.png +0 -0
- package/assets/init/tabbar/home.png +0 -0
- package/assets/init/tabbar/list-active.png +0 -0
- package/assets/init/tabbar/list.png +0 -0
- package/assets/init/types/neux-api.d.ts +1402 -0
- package/package.json +68 -0
- package/scripts/generate-init-types.js +210 -0
- package/scripts/sync-compiler.js +22 -0
- package/scripts/sync-web-container.js +34 -0
- package/src/bin/cli.js +646 -0
- package/src/core/brand.js +11 -0
- package/src/core/compiler.js +305 -0
- package/src/core/defaults.js +12 -0
- package/src/core/dev.js +15 -0
- package/src/core/errors.js +17 -0
- package/src/core/fs.js +66 -0
- package/src/core/i18n.js +37 -0
- package/src/core/init.js +866 -0
- package/src/core/lifecycle.js +32 -0
- package/src/core/manifest.js +72 -0
- package/src/core/pack.js +156 -0
- package/src/core/package-info.js +27 -0
- package/src/core/preview-server.js +123 -0
- package/src/core/project.js +101 -0
- package/src/core/prompts.js +71 -0
- package/src/core/proxy-security.js +141 -0
- package/src/core/proxy.js +156 -0
- package/src/core/qr.js +41 -0
- package/src/core/terminal-qr.js +72 -0
- package/src/core/update.js +278 -0
- package/src/core/watch.js +113 -0
- package/src/core/web.js +649 -0
- package/src/core/zip.js +120 -0
- package/src/index.js +20 -0
- package/src/providers/service-client.js +149 -0
- package/src/providers/service-config.js +264 -0
- package/src/providers/service.js +146 -0
- package/src/providers/upload.js +112 -0
- package/vendor/dimina-compiler/bin/index.cjs +265 -0
- package/vendor/dimina-compiler/bin/index.js +263 -0
- package/vendor/dimina-compiler/compatibility-B-DoZtUX.cjs +395 -0
- package/vendor/dimina-compiler/compatibility-Cl3-DO6V.js +366 -0
- package/vendor/dimina-compiler/core/logic-compiler.cjs +378 -0
- package/vendor/dimina-compiler/core/logic-compiler.js +374 -0
- package/vendor/dimina-compiler/core/style-compiler.cjs +392 -0
- package/vendor/dimina-compiler/core/style-compiler.js +377 -0
- package/vendor/dimina-compiler/core/view-compiler.cjs +1601 -0
- package/vendor/dimina-compiler/core/view-compiler.js +1582 -0
- package/vendor/dimina-compiler/index.cjs +762 -0
- package/vendor/dimina-compiler/index.js +751 -0
- package/vendor/dimina-compiler/sourcemap-BgtIgqkC.cjs +1377 -0
- package/vendor/dimina-compiler/sourcemap-CKjhV9h7.js +1135 -0
package/README.md
ADDED
|
@@ -0,0 +1,438 @@
|
|
|
1
|
+
# Neux CLI
|
|
2
|
+
|
|
3
|
+
[中文文档](./README.zh-CN.md)
|
|
4
|
+
|
|
5
|
+
Standalone Neux automation package for local development, CI/CD, and future IDE Node-side integration.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
Neux CLI is published publicly under the `@neuxnet` npm scope. If your npm
|
|
10
|
+
configuration maps this scope to a private registry, override it explicitly:
|
|
11
|
+
|
|
12
|
+
Install the CLI globally:
|
|
13
|
+
|
|
14
|
+
```sh
|
|
15
|
+
npm install -g @neuxnet/neux-cli --registry=https://registry.npmjs.org/
|
|
16
|
+
neux --version
|
|
17
|
+
neux --help
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Upgrade to the latest public version:
|
|
21
|
+
|
|
22
|
+
```sh
|
|
23
|
+
npm install -g @neuxnet/neux-cli@latest --registry=https://registry.npmjs.org/
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
If a private `@neuxnet:registry` setting still takes precedence, remove that
|
|
27
|
+
setting for the install or use a separate npm user config containing
|
|
28
|
+
`registry=https://registry.npmjs.org/`.
|
|
29
|
+
|
|
30
|
+
## Commands
|
|
31
|
+
|
|
32
|
+
```sh
|
|
33
|
+
neux init ./miniapp --app-id touristappid --name "My Miniapp"
|
|
34
|
+
neux --version
|
|
35
|
+
neux cli-version --json
|
|
36
|
+
neux inspect --project ./miniapp --json
|
|
37
|
+
neux dev --project ./miniapp --port 7788
|
|
38
|
+
neux build --project ./miniapp --version 1.0.1 --json
|
|
39
|
+
neux config doctor --project ./miniapp --server-url https://miniapp.example.com --json
|
|
40
|
+
neux update --check --json
|
|
41
|
+
neux update --registry https://registry.example.com
|
|
42
|
+
NEUX_CLI_KEY_APP_XXX=key_xxx neux upload --project ./miniapp --app-id app_xxx --server-url https://miniapp.example.com --preview --json
|
|
43
|
+
NEUX_CLI_KEY_APP_XXX=key_xxx neux debug --project ./miniapp --app-id app_xxx --server-url https://miniapp.example.com
|
|
44
|
+
NEUX_CLI_KEY_APP_XXX=key_xxx neux debug --project ./miniapp --app-id app_xxx --server-url https://miniapp.example.com --page-path pages/index/index --query foo=bar --qr-output ./dist/release/preview.qr.txt
|
|
45
|
+
NEUX_CLI_KEY_APP_XXX=key_xxx neux service-preview --app-id app_xxx --server-url https://miniapp.example.com --json
|
|
46
|
+
NEUX_CLI_KEY_APP_XXX=key_xxx neux submit --app-id app_xxx --server-url https://miniapp.example.com --version-id 123 --json
|
|
47
|
+
NEUX_CLI_KEY_APP_XXX=key_xxx neux status --app-id app_xxx --server-url https://miniapp.example.com --json
|
|
48
|
+
NEUX_CLI_KEY_APP_XXX=key_xxx neux meta --app-id app_xxx --server-url https://miniapp.example.com --json
|
|
49
|
+
NEUX_CLI_KEY_APP_XXX=key_xxx neux audit-status --app-id app_xxx --server-url https://miniapp.example.com --version-id 123 --json
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
`init` creates a minimal mini program project from scratch. In a TTY it interactively asks for the project name, App ID, Server URL, and a hidden `CLI Key`. The default Server URL is `https://demo-c.paas.superapp.neuvision.cn`. App ID and Server URL are written to the project; each App ID's CLI Key is stored in the user-level `~/.neux/config.json` and never in project files. Use `neux config set` to change the current project's CLI Key. `build` creates the client `.wgt` delivery artifact. `upload`, `debug`, `service-preview`, `submit`, `status` / `meta`, and `audit-status` use the signed service API when `--provider` is omitted. `debug-preview`, `submit-audit`, `version`, and `wgt` remain compatibility spellings for integrations that already use them. `login` is still provider-backed and unsupported by the signed service. Use `--provider local-file` or a provider module when testing adapter integrations instead of the remote service.
|
|
53
|
+
|
|
54
|
+
When the command runs inside a mini program project, `--project` defaults to the current directory. Output directories also have command-level defaults:
|
|
55
|
+
|
|
56
|
+
| Command | Default output |
|
|
57
|
+
| --- | --- |
|
|
58
|
+
| `neux build` | `dist/release` |
|
|
59
|
+
| `neux compile` | `dist/build` |
|
|
60
|
+
| `neux dev` | `dist/dev` |
|
|
61
|
+
| `neux web` | `dist/web` |
|
|
62
|
+
| `neux pack` | `dist/pack` |
|
|
63
|
+
| `neux wgt` | `dist/release` |
|
|
64
|
+
| `neux preview` | `dist/preview` |
|
|
65
|
+
|
|
66
|
+
## Updating The CLI
|
|
67
|
+
|
|
68
|
+
Check for a newer CLI without installing it:
|
|
69
|
+
|
|
70
|
+
```sh
|
|
71
|
+
neux update --check
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Install the latest version from the configured npm registry:
|
|
75
|
+
|
|
76
|
+
```sh
|
|
77
|
+
neux update
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
When `--registry` is omitted, `neux update` first reads the package scope registry from the current npm config such as `@neuxnet:registry`, then falls back to the default `registry`.
|
|
81
|
+
|
|
82
|
+
Use a private registry:
|
|
83
|
+
|
|
84
|
+
```sh
|
|
85
|
+
neux update --registry https://registry.example.com
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
Automatic update is opt-in:
|
|
89
|
+
|
|
90
|
+
```sh
|
|
91
|
+
NEUX_CLI_AUTO_UPDATE=1 neux dev
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
Automatic update failures are printed as warnings and do not stop the original command. In CI/CD, prefer `neux update --check --json` or a pinned CLI version when deterministic toolchains matter.
|
|
95
|
+
|
|
96
|
+
## Mini Program Scripts
|
|
97
|
+
|
|
98
|
+
Create a new project:
|
|
99
|
+
|
|
100
|
+
```sh
|
|
101
|
+
npx @neuxnet/neux-cli init my-miniapp --app-id touristappid --name "My Miniapp"
|
|
102
|
+
cd my-miniapp
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
Mini program projects can keep their own npm scripts and call the CLI from the project root:
|
|
106
|
+
|
|
107
|
+
```json
|
|
108
|
+
{
|
|
109
|
+
"scripts": {
|
|
110
|
+
"build": "neux build",
|
|
111
|
+
"dev": "neux dev",
|
|
112
|
+
"upload": "neux upload --preview",
|
|
113
|
+
"debug": "neux debug",
|
|
114
|
+
"submit": "neux submit"
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
The generated project declares the CLI as a local `devDependency` intentionally. The
|
|
120
|
+
`npm run` commands then resolve `neux` from `node_modules/.bin`, so the project,
|
|
121
|
+
other developers, and CI use the project's declared CLI version range instead of
|
|
122
|
+
depending on an untracked global installation. Commit the generated lockfile to
|
|
123
|
+
pin the exact version. `neux init` fills this value from the installed CLI package;
|
|
124
|
+
it does not hard-code an old release. If the project is only operated with a
|
|
125
|
+
globally installed CLI, this dependency is not technically required, but the
|
|
126
|
+
scripts become dependent on each machine's global version and are no longer
|
|
127
|
+
reproducible.
|
|
128
|
+
|
|
129
|
+
`npm run build` compiles the mini app and writes the client `.wgt` package under `dist/release/`. `npm run dev` starts the browser H5 container, watches project files, reloads after successful rebuilds, and exposes a same-origin `/proxy` endpoint for browser network requests. Individual mini programs do not need to maintain proxy scripts. The proxy is development-only and is not included in `.wgt` packages or native runtime behavior. `npm run upload` uploads a trial package, `npm run debug` uploads a debug preview package and prints a scannable terminal QR code, and `npm run submit` submits a trial version for audit.
|
|
130
|
+
|
|
131
|
+
The proxy request body follows the browser network adapter shape:
|
|
132
|
+
|
|
133
|
+
```json
|
|
134
|
+
{
|
|
135
|
+
"url": "https://api.example.com/path",
|
|
136
|
+
"method": "POST",
|
|
137
|
+
"data": {},
|
|
138
|
+
"header": {}
|
|
139
|
+
}
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
Only loopback browser origins are allowed by default. Private, loopback, and reserved
|
|
143
|
+
target addresses are rejected. Set `DIMINA_PROXY_ALLOWED_ORIGINS` to a comma-separated
|
|
144
|
+
allowlist when an additional development origin is required.
|
|
145
|
+
|
|
146
|
+
Debug and upload commands accept optional service metadata and launch parameters:
|
|
147
|
+
|
|
148
|
+
```sh
|
|
149
|
+
neux debug --page-path pages/detail/index --query 'id=1' --scene 1001 --launch-from cli --location 31.2,121.5
|
|
150
|
+
neux debug --qr-format png --qr-output ./dist/release/preview.png
|
|
151
|
+
neux debug --qr-format terminal
|
|
152
|
+
neux debug --qr-format none --qr-output ./dist/release/preview.qr.txt
|
|
153
|
+
neux upload --preview --changelog "Release notes" --channel test
|
|
154
|
+
neux submit --version-id 123 --channel test --auto-publish
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
Text-mode `debug` / `debug-preview` prints a terminal QR code by default. The renderer uses compact ANSI upper-half cells with explicit colors for both module rows and a four-module quiet zone. Encoding two vertical modules in each terminal cell keeps the QR code close to square while avoiding reliance on the terminal's default foreground/background colors, improving scanning in Mac Terminal and Android Studio Terminal. Use `--qr-format png --qr-output <path>` for an image, `--qr-format none --qr-output <path>` to archive the raw payload, and `--copy` to copy the deeplink. `--json` keeps stdout machine-readable and does not print a QR code.
|
|
158
|
+
|
|
159
|
+
For tooling that needs the old compiler-only behavior, use `neux compile`. The `neux wgt` command remains as a compatibility alias for the delivery build.
|
|
160
|
+
|
|
161
|
+
When running this repository directly before publishing/installing the CLI package, use yalc so package name and bin command stay consistent with the published shape:
|
|
162
|
+
|
|
163
|
+
```sh
|
|
164
|
+
cd neux-cli
|
|
165
|
+
yalc publish
|
|
166
|
+
|
|
167
|
+
cd ../fe/example/base
|
|
168
|
+
yalc add @neuxnet/neux-cli
|
|
169
|
+
npm install
|
|
170
|
+
npm run build
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
## Node API
|
|
174
|
+
|
|
175
|
+
```js
|
|
176
|
+
import {
|
|
177
|
+
buildProject,
|
|
178
|
+
createProjectWatcher,
|
|
179
|
+
createLocalFileProvider,
|
|
180
|
+
createUploadProvider,
|
|
181
|
+
initProject,
|
|
182
|
+
inspectProject,
|
|
183
|
+
packProject,
|
|
184
|
+
updateCli,
|
|
185
|
+
startDev,
|
|
186
|
+
startPreview,
|
|
187
|
+
startWeb,
|
|
188
|
+
} from '@neuxnet/neux-cli'
|
|
189
|
+
|
|
190
|
+
await initProject({ _: ['./miniapp'], appId: 'touristappid', name: 'My Miniapp' })
|
|
191
|
+
await updateCli({ check: true })
|
|
192
|
+
const info = await inspectProject({ project: './miniapp' })
|
|
193
|
+
const build = await buildProject({
|
|
194
|
+
project: './miniapp',
|
|
195
|
+
captureLogs: true,
|
|
196
|
+
onLog(log) {
|
|
197
|
+
console.log(`[${log.level}] ${log.message}`)
|
|
198
|
+
},
|
|
199
|
+
})
|
|
200
|
+
const pack = await packProject({ project: './miniapp', out: './artifacts' })
|
|
201
|
+
const session = await startPreview({ project: './miniapp', host: '127.0.0.1', port: 0 })
|
|
202
|
+
await session.close()
|
|
203
|
+
|
|
204
|
+
const web = await startWeb({ project: './miniapp', port: 0, open: false })
|
|
205
|
+
console.log(web.url)
|
|
206
|
+
await web.close()
|
|
207
|
+
|
|
208
|
+
const dev = await startDev({ project: './miniapp', port: 0, open: false })
|
|
209
|
+
console.log(dev.url)
|
|
210
|
+
await dev.close()
|
|
211
|
+
|
|
212
|
+
const watcher = await createProjectWatcher({
|
|
213
|
+
project: './miniapp',
|
|
214
|
+
onChange: () => buildProject({ project: './miniapp', out: './dist' }),
|
|
215
|
+
})
|
|
216
|
+
watcher.close()
|
|
217
|
+
|
|
218
|
+
const provider = createUploadProvider()
|
|
219
|
+
await provider.upload('./artifacts/app.zip') // throws DIMINA_PROVIDER_UNSUPPORTED until an adapter is supplied
|
|
220
|
+
|
|
221
|
+
const localProvider = createLocalFileProvider({ providerOut: './provider-records' })
|
|
222
|
+
await localProvider.login({
|
|
223
|
+
project: { projectPath: info.projectPath, appId: info.appId },
|
|
224
|
+
options: { account: 'demo' },
|
|
225
|
+
})
|
|
226
|
+
await localProvider.upload({
|
|
227
|
+
artifact: pack,
|
|
228
|
+
project: { projectPath: info.projectPath, appId: info.appId },
|
|
229
|
+
options: { versionCode: 1, versionName: '1.0.0' },
|
|
230
|
+
})
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
The CLI is a thin adapter over these APIs so a future IDE can reuse the same lifecycle without parsing terminal output.
|
|
234
|
+
|
|
235
|
+
`initProject({ _: ['./miniapp'], appId: 'touristappid', name: 'My Miniapp' })` creates the same starter project that `neux init` writes from the command line. Existing non-empty directories are rejected unless `force: true` is passed.
|
|
236
|
+
|
|
237
|
+
`buildProject()` supports projects whose `project.config.json` declares `miniprogramRoot`. In that case it prepares a normalized compiler input directory beside the output directory and returns `sourceRoot`, `compilerInputPath`, and `compilerInputCreated` for IDE diagnostics. Use `captureLogs` / `onLog` for IDE status panes; keep captured builds serial within a single Node process because compiler stdout/stderr are process-global streams.
|
|
238
|
+
|
|
239
|
+
`startWeb({ watch: true })` serves the bundled H5 container, rebuilds on project file changes, and sends a browser live-reload event after each successful rebuild. `startDev()` is the same development loop exposed as the stable IDE-friendly entrypoint.
|
|
240
|
+
|
|
241
|
+
Long-running Node APIs accept `onEvent(event)` so IDEs can consume one stable lifecycle stream without parsing terminal output. Event names are stable: `build-start`, `build-success`, `build-error`, `ready`, `reload`, and `close`. Events are JSON-safe and omit functions from session payloads.
|
|
242
|
+
|
|
243
|
+
## Signed Service Uploads
|
|
244
|
+
|
|
245
|
+
The signed service API authenticates machine requests with `appId + key`. Requests send `X-App-Id`, `X-Timestamp`, `X-Nonce`, and `X-Signature`; there is no `keyId` or CLI scope field in the V2 contract.
|
|
246
|
+
|
|
247
|
+
Config resolution order:
|
|
248
|
+
|
|
249
|
+
1. CLI flags, such as `--server-url`, `--app-id`, `--key`, and `--profile`.
|
|
250
|
+
2. Environment variables: `NEUX_CLI_SERVER_URL`, `NEUX_CLI_APP_ID`, `NEUX_CLI_PROFILE`, app/profile-specific key variables, and `NEUX_CLI_KEY`.
|
|
251
|
+
3. Project config for non-key values: `neux.config.json` or top-level fields in `project.config.json`.
|
|
252
|
+
4. User profiles from `$NEUX_CLI_CONFIG` or `~/.neux/config.json`.
|
|
253
|
+
|
|
254
|
+
Project config example:
|
|
255
|
+
|
|
256
|
+
```json
|
|
257
|
+
{
|
|
258
|
+
"appId": "app_xxx",
|
|
259
|
+
"profile": "demo-private",
|
|
260
|
+
"versionName": "1.2.3",
|
|
261
|
+
"versionCode": 12
|
|
262
|
+
}
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
You can also keep package metadata inside `project.config.json`:
|
|
266
|
+
|
|
267
|
+
```json
|
|
268
|
+
{
|
|
269
|
+
"appid": "app_xxx",
|
|
270
|
+
"compileType": "miniprogram",
|
|
271
|
+
"miniprogramRoot": "",
|
|
272
|
+
"neuxCli": {
|
|
273
|
+
"serverUrl": "https://demo-c.paas.superapp.neuvision.cn"
|
|
274
|
+
},
|
|
275
|
+
"versionName": "1.2.3",
|
|
276
|
+
"versionCode": 12,
|
|
277
|
+
"setting": {
|
|
278
|
+
"urlCheck": true,
|
|
279
|
+
"es6": true,
|
|
280
|
+
"postcss": true,
|
|
281
|
+
"minified": true
|
|
282
|
+
},
|
|
283
|
+
"packOptions": {
|
|
284
|
+
"ignore": [],
|
|
285
|
+
"include": []
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
`serverUrl` can also be placed at the top level of `project.config.json`; the generated starter uses `neuxCli.serverUrl` so service settings stay separate from IDE project fields. `project.private.config.json` can override non-key local values from `project.config.json`, including `appid`, `projectname`, `versionName`, `versionCode`, `setting`, `packOptions`, and `neuxCli.serverUrl`. Keep `key` out of both files; use environment variables or `--key`.
|
|
291
|
+
|
|
292
|
+
`neux build` and service upload commands use version values in this order: CLI flags (`--version-name`, `--version`, `--version-code`), `neux.config.json`, top-level `project.config.json` fields (`versionName`, `versionCode`), `package.json` `version` for `versionName`, and finally the defaults `1.0.0` / `1`.
|
|
293
|
+
|
|
294
|
+
User profile example:
|
|
295
|
+
|
|
296
|
+
```json
|
|
297
|
+
{
|
|
298
|
+
"profiles": {
|
|
299
|
+
"demo-private": {
|
|
300
|
+
"serverUrl": "https://miniapp.example.com"
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
CLI Keys are stored per App ID in the user-level `~/.neux/config.json` `keys` object, never in project config or Git. Use `neux config set` to update a key. For CI, pass the key through `--key` or environment variables.
|
|
307
|
+
|
|
308
|
+
Key resolution order:
|
|
309
|
+
|
|
310
|
+
1. `--key`
|
|
311
|
+
2. `NEUX_CLI_KEY_<APPID_NORMALIZED>`
|
|
312
|
+
3. `NEUX_CLI_KEY_<PROFILE_NORMALIZED>`
|
|
313
|
+
4. `NEUX_CLI_KEY`
|
|
314
|
+
5. The current App ID's key in the user-level `~/.neux/config.json`
|
|
315
|
+
|
|
316
|
+
The normalized suffix is uppercased and non-alphanumeric characters become `_`. For example, app id `wxbaf4b47de04f1d8a` uses:
|
|
317
|
+
|
|
318
|
+
```sh
|
|
319
|
+
export NEUX_CLI_KEY_WXBAF4B47DE04F1D8A=key_xxx
|
|
320
|
+
npm run upload
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
A profile named `demo-private` uses:
|
|
324
|
+
|
|
325
|
+
```sh
|
|
326
|
+
export NEUX_CLI_KEY_DEMO_PRIVATE=key_xxx
|
|
327
|
+
npm run upload
|
|
328
|
+
```
|
|
329
|
+
|
|
330
|
+
For CI/CD with multiple mini apps, inject the app-specific key for each job and keep package scripts short:
|
|
331
|
+
|
|
332
|
+
```yaml
|
|
333
|
+
env:
|
|
334
|
+
NEUX_CLI_SERVER_URL: https://miniapp.example.com
|
|
335
|
+
NEUX_CLI_KEY_WXBAF4B47DE04F1D8A: ${{ env.MINIAPP_BASE_KEY }}
|
|
336
|
+
|
|
337
|
+
steps:
|
|
338
|
+
- run: npm run upload
|
|
339
|
+
```
|
|
340
|
+
|
|
341
|
+
When configuration is missing, non-JSON CLI output prints the exact environment variable names that match the current project app id and profile. JSON mode returns the same suggestions in `details.suggestions`.
|
|
342
|
+
|
|
343
|
+
`neux build`, `neux wgt`, and service uploads create client `.wgt` files with the same shape as the downloaded runtime package. The outer `.wgt` is a zip containing exactly `config.json` and `<appId>.zip`; the inner `<appId>.zip` contains the files from the resolved mini app production/build output directory. They do not zip the whole source project folder. Local `pack` and local `preview` keep their existing legacy `.zip` behavior.
|
|
344
|
+
|
|
345
|
+
The existing `preview` command remains the legacy local static preview server. Use `service-preview` for the signed API endpoint that generates trial preview information. Trial preview and debug preview results include `qrPayload` / `deepLink` fields for CLI-side QR generation; the CLI does not call the server PNG QR endpoint. For `upload --preview`, the CLI appends the packaged `versionName` as the deeplink `version` query parameter even when the service `scanUrl` only contains `appId` and `appVerType`. In text mode, successful `debug` / `debug-preview` prints the compact ANSI half-cell terminal QR by default; `--qr-format png` generates a PNG and `--qr-format none` suppresses visual output. In `--json` mode, stdout stays machine-readable JSON and the QR payload remains available as `qrPayload`. `--qr-output <path>` selects an explicit QR output path.
|
|
346
|
+
|
|
347
|
+
Use `neux config doctor` to inspect signed service configuration without exposing keys:
|
|
348
|
+
|
|
349
|
+
```sh
|
|
350
|
+
neux config doctor --project ./miniapp --json
|
|
351
|
+
```
|
|
352
|
+
|
|
353
|
+
The diagnostic output includes resolved non-key values, config source paths, missing fields, candidate key environment variables, and whether a key is present. It never prints the key value.
|
|
354
|
+
|
|
355
|
+
## JSON Output Contract
|
|
356
|
+
|
|
357
|
+
One-shot commands write one JSON object to stdout when `--json` is passed:
|
|
358
|
+
|
|
359
|
+
```sh
|
|
360
|
+
neux build --project ./miniapp --json
|
|
361
|
+
```
|
|
362
|
+
|
|
363
|
+
Long-running development commands write newline-delimited JSON events:
|
|
364
|
+
|
|
365
|
+
```sh
|
|
366
|
+
neux dev --project ./miniapp --json
|
|
367
|
+
neux preview --project ./miniapp --json --stay
|
|
368
|
+
```
|
|
369
|
+
|
|
370
|
+
Event names are stable: `build-start`, `build-success`, `build-error`, `ready`, `reload`, and `close`. Compiler progress logs are redirected to stderr in JSON mode so stdout remains machine-readable for CI and IDE integrations.
|
|
371
|
+
|
|
372
|
+
## Provider Adapters
|
|
373
|
+
|
|
374
|
+
Provider commands first create a package artifact, then call the selected provider:
|
|
375
|
+
|
|
376
|
+
```sh
|
|
377
|
+
neux login --project ./miniapp --provider ./provider.mjs --json
|
|
378
|
+
neux upload --project ./miniapp --provider ./provider.mjs --json
|
|
379
|
+
neux audit --project ./miniapp --provider ./provider.mjs --json
|
|
380
|
+
neux submit --project ./miniapp --provider ./provider.mjs --json
|
|
381
|
+
```
|
|
382
|
+
|
|
383
|
+
A provider module can export `createProvider(options)`, a default provider object, or a named `provider` object:
|
|
384
|
+
|
|
385
|
+
```js
|
|
386
|
+
export function createProvider(options) {
|
|
387
|
+
return {
|
|
388
|
+
async login({ project }) {
|
|
389
|
+
return { ok: true, provider: 'example', appId: project?.appId }
|
|
390
|
+
},
|
|
391
|
+
async upload({ artifact, project }) {
|
|
392
|
+
return { ok: true, provider: 'example', appId: project.appId, packagePath: artifact.packagePath }
|
|
393
|
+
},
|
|
394
|
+
async audit({ artifact }) {
|
|
395
|
+
return { ok: true, provider: 'example', manifestPath: artifact.manifestPath }
|
|
396
|
+
},
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
```
|
|
400
|
+
|
|
401
|
+
Use `--provider local-file` for CI smoke tests. It writes local JSON records and does not contact any remote service.
|
|
402
|
+
|
|
403
|
+
## Bundled Compiler
|
|
404
|
+
|
|
405
|
+
The published CLI bundles the mini program compiler, so mini program projects do not need to install a separate compiler package. To refresh the bundled compiler from this repository before publishing the CLI, build the compiler package and sync the compiled output:
|
|
406
|
+
|
|
407
|
+
```sh
|
|
408
|
+
pnpm --dir ../fe build
|
|
409
|
+
npm run sync:compiler
|
|
410
|
+
```
|
|
411
|
+
|
|
412
|
+
For a one-step local publish preparation flow, run:
|
|
413
|
+
|
|
414
|
+
```sh
|
|
415
|
+
npm run prepare:publish
|
|
416
|
+
```
|
|
417
|
+
|
|
418
|
+
Use `--compiler-module <path>` or `DIMINA_COMPILER_MODULE=<path>` only when testing a custom compiler module.
|
|
419
|
+
|
|
420
|
+
## Web Container Asset
|
|
421
|
+
|
|
422
|
+
`neux web` first looks for the bundled H5 container under `assets/container`. Refresh that asset from this repository with:
|
|
423
|
+
|
|
424
|
+
```sh
|
|
425
|
+
npm run sync:container
|
|
426
|
+
```
|
|
427
|
+
|
|
428
|
+
Use `--container-dir <path>` or `DIMINA_WEB_CONTAINER_DIR=<path>` to test a different container build.
|
|
429
|
+
### Language
|
|
430
|
+
|
|
431
|
+
The CLI defaults to English. Use `--lang zh-CN` or `NEUX_CLI_LANG=zh-CN` to translate CLI help and terminal result labels:
|
|
432
|
+
|
|
433
|
+
```bash
|
|
434
|
+
neux --help --lang zh-CN
|
|
435
|
+
NEUX_CLI_LANG=zh-CN neux init ./miniapp
|
|
436
|
+
```
|
|
437
|
+
|
|
438
|
+
The Web container also defaults to English. Start it with `neux dev --lang zh-CN`, or add `?lang=zh-CN` to the Web URL. `--json` output keeps stable machine-readable fields regardless of the selected language.
|