@vmz/vmz 0.1.17 → 0.1.18
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/dist/application-cmd.d.ts +6 -16
- package/dist/application-cmd.js +34 -180
- package/dist/author-input.d.ts +40 -19
- package/dist/author-input.js +2 -16
- package/dist/build-assemble.d.ts +63 -41
- package/dist/build-assemble.js +42 -43
- package/dist/bundler-adapter.d.ts +46 -48
- package/dist/bundler-adapter.js +4 -43
- package/dist/cdn-policy.d.ts +77 -93
- package/dist/cdn-policy.js +10 -16
- package/dist/cli-localize.d.ts +34 -0
- package/dist/cli-localize.js +58 -0
- package/dist/cli.d.ts +8 -19
- package/dist/cli.js +69 -252
- package/dist/content-addressed-assets.d.ts +24 -10
- package/dist/content-addressed-assets.js +2 -7
- package/dist/delivery-profile.d.ts +54 -27
- package/dist/delivery-profile.js +15 -13
- package/dist/dev-session.d.ts +29 -23
- package/dist/dev-session.js +0 -21
- package/dist/dev-watch-roots.d.ts +34 -25
- package/dist/dev-watch-roots.js +0 -31
- package/dist/document-build.d.ts +22 -97
- package/dist/document-build.js +4 -19
- package/dist/document-check.d.ts +30 -53
- package/dist/document-check.js +14 -29
- package/dist/document-cmd.d.ts +3 -6
- package/dist/document-cmd.js +19 -79
- package/dist/document-designs.d.ts +5 -8
- package/dist/document-designs.js +2 -15
- package/dist/document-enrich.d.ts +52 -24
- package/dist/document-enrich.js +4 -32
- package/dist/document-evidence.d.ts +46 -43
- package/dist/document-evidence.js +6 -47
- package/dist/document-integrate.d.ts +13 -29
- package/dist/document-integrate.js +2 -13
- package/dist/document-interactive.d.ts +45 -67
- package/dist/document-interactive.js +9 -50
- package/dist/document-layout-render.d.ts +7 -16
- package/dist/document-layout-render.js +0 -17
- package/dist/document-locale.d.ts +12 -25
- package/dist/document-locale.js +3 -14
- package/dist/document-markdown.d.ts +9 -5
- package/dist/document-markdown.js +0 -4
- package/dist/document-routing-config.d.ts +7 -14
- package/dist/document-routing-config.js +0 -9
- package/dist/document-scan.d.ts +14 -18
- package/dist/document-scan.js +2 -23
- package/dist/document-schema.d.ts +154 -41
- package/dist/document-schema.js +0 -35
- package/dist/embedded-packaging.d.ts +20 -8
- package/dist/embedded-packaging.js +0 -1
- package/dist/explain-cmd.d.ts +4 -3
- package/dist/explain-cmd.js +16 -65
- package/dist/index.d.ts +70 -143
- package/dist/index.js +16 -136
- package/dist/invocation.d.ts +29 -50
- package/dist/invocation.js +11 -57
- package/dist/locale-check.d.ts +69 -70
- package/dist/locale-check.js +5 -66
- package/dist/locale-cmd.d.ts +2 -5
- package/dist/locale-cmd.js +62 -142
- package/dist/locale-delivery.d.ts +294 -191
- package/dist/locale-delivery.js +8 -94
- package/dist/locale-route-emit.d.ts +23 -9
- package/dist/locale-route-emit.js +0 -7
- package/dist/locale-router.d.ts +189 -162
- package/dist/locale-router.js +13 -122
- package/dist/locale-runtime.d.ts +292 -262
- package/dist/locale-runtime.js +8 -102
- package/dist/locale-schema.js +0 -1
- package/dist/locale-tooling.d.ts +100 -63
- package/dist/locale-tooling.js +7 -45
- package/dist/log.d.ts +22 -15
- package/dist/log.js +24 -21
- package/dist/native-addon.d.ts +10 -9
- package/dist/native-addon.js +1 -10
- package/dist/pack-client-packages.d.ts +5 -1
- package/dist/pack-client-packages.js +0 -6
- package/dist/pack.d.ts +17 -15
- package/dist/pack.js +0 -12
- package/dist/packages.d.ts +10 -23
- package/dist/packages.js +1 -37
- package/dist/plan-cmd.d.ts +6 -0
- package/dist/plan-cmd.js +35 -0
- package/dist/plugin-host.js +0 -1
- package/dist/port.d.ts +2 -10
- package/dist/port.js +2 -11
- package/dist/pretty-json.d.ts +9 -19
- package/dist/pretty-json.js +3 -17
- package/dist/production-observability.d.ts +37 -181
- package/dist/production-observability.js +1 -9
- package/dist/production-test-pack.d.ts +17 -3
- package/dist/production-test-pack.js +0 -2
- package/dist/public-static-assets.d.ts +6 -1
- package/dist/public-static-assets.js +0 -5
- package/dist/refactor-cmd.d.ts +3 -6
- package/dist/refactor-cmd.js +16 -69
- package/dist/release-cmd.d.ts +7 -6
- package/dist/release-cmd.js +17 -59
- package/dist/release-pack.d.ts +7 -3
- package/dist/release-pack.js +0 -6
- package/dist/resolve.d.ts +15 -19
- package/dist/resolve.js +1 -15
- package/dist/server-artifact.d.ts +30 -75
- package/dist/server-artifact.js +0 -10
- package/dist/server-language-backend.d.ts +22 -79
- package/dist/server-language-backend.js +0 -26
- package/dist/site-delivery.d.ts +46 -59
- package/dist/site-delivery.js +3 -8
- package/dist/site-favicon.d.ts +6 -1
- package/dist/site-favicon.js +0 -5
- package/dist/static-emit.d.ts +73 -103
- package/dist/static-emit.js +1 -26
- package/dist/test-cmd.d.ts +3 -5
- package/dist/test-cmd.js +15 -25
- package/dist/test-compile.js +0 -1
- package/dist/test-discover.js +0 -1
- package/dist/test-logic.js +0 -1
- package/dist/test-protocol.js +0 -1
- package/dist/toolchain-dx.d.ts +11 -0
- package/dist/toolchain-dx.js +10 -0
- package/dist/watch-diff.d.ts +4 -13
- package/dist/watch-diff.js +0 -17
- package/dist/wechat-packaging.d.ts +8 -7
- package/dist/wechat-packaging.js +0 -6
- package/locales/en-US/cli.json +105 -0
- package/locales/locales.json +4 -0
- package/package.json +15 -12
- package/dist/resolve-native-cli.d.ts +0 -14
- package/dist/resolve-native-cli.js +0 -84
package/dist/cdn-policy.js
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
* A3-cdn: vendor-neutral CDN policy (cache / redirect / error) + local static host.
|
|
3
3
|
* Provider adapters only project the same contract — they must not change RouteId/canonical/CSP.
|
|
4
4
|
*/
|
|
5
|
-
// @ts-nocheck
|
|
6
5
|
import crypto from 'node:crypto';
|
|
7
6
|
import fs from 'node:fs';
|
|
8
7
|
import http from 'node:http';
|
|
@@ -15,20 +14,15 @@ export const CDN_ADAPTER_PROJECTION_SCHEMA = 'vmz.cdn.adapter_projection.v0';
|
|
|
15
14
|
export const CACHE_HTML = 'public, max-age=0, must-revalidate';
|
|
16
15
|
export const CACHE_ASSET_IMMUTABLE = 'public, max-age=31536000, immutable';
|
|
17
16
|
export const CACHE_META = 'public, max-age=3600';
|
|
18
|
-
/**
|
|
19
|
-
* Build CDNPolicyManifest from StaticDeliveryManifest (+ optional redirects / locale artifact).
|
|
20
|
-
* Locale-prefixed HTML gets LocaleId-encoded cache keys; Accept-Language must not steal body.
|
|
21
|
-
* @param {Record<string, any>} staticManifest
|
|
22
|
-
* @param {{
|
|
23
|
-
* redirects?: Array<{ from: string, to: string, status?: number, reason?: string }>,
|
|
24
|
-
* localeArtifact?: Record<string, any> | null,
|
|
25
|
-
* }} [opts]
|
|
26
|
-
*/
|
|
27
17
|
export function buildCdnPolicyManifest(staticManifest, opts = {}) {
|
|
28
18
|
const origin = String(staticManifest.origin || '');
|
|
29
19
|
const localeArt = opts.localeArtifact || null;
|
|
30
20
|
const localeRedirects = buildOmitPrefixRedirects(staticManifest, localeArt);
|
|
31
|
-
const redirects = [
|
|
21
|
+
const redirects = [
|
|
22
|
+
{ from: '/home', to: '/', status: 301, reason: 'canonical-alias' },
|
|
23
|
+
...localeRedirects,
|
|
24
|
+
...(opts.redirects || []),
|
|
25
|
+
];
|
|
32
26
|
const headers = [
|
|
33
27
|
{ match: '**/*.html', headers: { 'cache-control': CACHE_HTML } },
|
|
34
28
|
{
|
|
@@ -46,7 +40,8 @@ export function buildCdnPolicyManifest(staticManifest, opts = {}) {
|
|
|
46
40
|
const routes = [];
|
|
47
41
|
/** @type {any[]} */
|
|
48
42
|
const cacheKeyDiagnostics = [];
|
|
49
|
-
|
|
43
|
+
const staticRoutes = Array.isArray(staticManifest.routes) ? staticManifest.routes : [];
|
|
44
|
+
for (const r of staticRoutes) {
|
|
50
45
|
const localeId = r.localeId || null;
|
|
51
46
|
const alternates = Array.isArray(r.seo?.alternates) ? r.seo.alternates : [];
|
|
52
47
|
const cacheKey = localeId
|
|
@@ -111,14 +106,13 @@ export function buildCdnPolicyManifest(staticManifest, opts = {}) {
|
|
|
111
106
|
* @param {Record<string, any> | null} localeArt
|
|
112
107
|
*/
|
|
113
108
|
function buildOmitPrefixRedirects(staticManifest, localeArt) {
|
|
114
|
-
const routing = localeArt?.routing || {};
|
|
109
|
+
const routing = (localeArt?.routing || {});
|
|
115
110
|
const defaultLocale = localeArt?.defaultLocale || routing.defaultLocale;
|
|
116
111
|
if (!defaultLocale || routing.defaultPrefix !== 'omit')
|
|
117
112
|
return [];
|
|
118
|
-
/** @type {Array<{ from: string, to: string, status: number, reason: string }>} */
|
|
119
113
|
const out = [];
|
|
120
114
|
const seen = new Set();
|
|
121
|
-
for (const r of staticManifest.routes || []) {
|
|
115
|
+
for (const r of (staticManifest.routes || [])) {
|
|
122
116
|
if (r.localeId !== defaultLocale)
|
|
123
117
|
continue;
|
|
124
118
|
const canonical = String(r.path || '/');
|
|
@@ -250,7 +244,7 @@ export function listenLocalStaticHost(distDir, policy, opts = {}) {
|
|
|
250
244
|
port: actualPort,
|
|
251
245
|
baseUrl: `http://${host}:${actualPort}`,
|
|
252
246
|
close: () => new Promise((res, rej) => {
|
|
253
|
-
server.close((err) => (err ? rej(err) : res()));
|
|
247
|
+
server.close((err) => (err ? rej(err) : res(undefined)));
|
|
254
248
|
}),
|
|
255
249
|
});
|
|
256
250
|
});
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Official CLI / diagnostic localization for `@vmz/vmz`.
|
|
3
|
+
*
|
|
4
|
+
* Mechanism (manifest / flatten / load / createLocalize) lives in `@vmz/commander`.
|
|
5
|
+
* This module only points at the product `locales/` root and prefers `VMZ_LOCALE`.
|
|
6
|
+
*/
|
|
7
|
+
import { flattenCatalog, type LocaleCatalog, type LocalesManifest, type LocalizePlugin } from '@vmz/commander';
|
|
8
|
+
/** Package `locales/` root (shipped next to `dist/`). */
|
|
9
|
+
export declare function resolveCliLocalesRoot(): string;
|
|
10
|
+
/** @deprecated Prefer `loadLocalesManifest` from `@vmz/commander`. */
|
|
11
|
+
export declare function loadCliLocalesManifest(root?: string): LocalesManifest;
|
|
12
|
+
/** @deprecated Prefer `loadCatalog` from `@vmz/commander`. */
|
|
13
|
+
export declare function loadCliCatalog(locale: string, root?: string): LocaleCatalog;
|
|
14
|
+
/** @deprecated Prefer `loadCatalog('en-US', root)`. */
|
|
15
|
+
export declare function getVmzCliCatalogEnUs(): LocaleCatalog;
|
|
16
|
+
/** Eager default table (en-US) for callers that still import a constant. */
|
|
17
|
+
export declare const VMZ_CLI_CATALOG_EN_US: LocaleCatalog;
|
|
18
|
+
/** Resolve product locale (`VMZ_LOCALE` first). */
|
|
19
|
+
export declare function resolveVmzLocale(env?: NodeJS.ProcessEnv, argv?: string[]): string;
|
|
20
|
+
/** @deprecated Prefer `translate` / `translateWithFallback` from `@vmz/commander`. */
|
|
21
|
+
export declare function translateCatalog(id: string, args: Record<string, string> | undefined, catalog: LocaleCatalog): string;
|
|
22
|
+
export { flattenCatalog };
|
|
23
|
+
/**
|
|
24
|
+
* Build the official Localize plugin for `@vmz/vmz`.
|
|
25
|
+
*/
|
|
26
|
+
export declare function createVmzCliLocalize(opts?: {
|
|
27
|
+
locale?: string;
|
|
28
|
+
catalog?: LocaleCatalog;
|
|
29
|
+
env?: NodeJS.ProcessEnv;
|
|
30
|
+
argv?: string[];
|
|
31
|
+
localesRoot?: string;
|
|
32
|
+
}): LocalizePlugin;
|
|
33
|
+
/** Default official plugin (locale from env; catalog from `locales/`). */
|
|
34
|
+
export declare const vmzCliLocalize: LocalizePlugin;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Official CLI / diagnostic localization for `@vmz/vmz`.
|
|
3
|
+
*
|
|
4
|
+
* Mechanism (manifest / flatten / load / createLocalize) lives in `@vmz/commander`.
|
|
5
|
+
* This module only points at the product `locales/` root and prefers `VMZ_LOCALE`.
|
|
6
|
+
*/
|
|
7
|
+
import path from 'node:path';
|
|
8
|
+
import { fileURLToPath } from 'node:url';
|
|
9
|
+
import { createLocalizeFromLocales, flattenCatalog, loadCatalog, loadLocalesManifest, resolveLocale, translate, } from '@vmz/commander';
|
|
10
|
+
const LOCALES_ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..', 'locales');
|
|
11
|
+
const VMZ_ENV_KEYS = ['VMZ_LOCALE', 'LOCALE', 'LANG', 'LC_ALL'];
|
|
12
|
+
/** Package `locales/` root (shipped next to `dist/`). */
|
|
13
|
+
export function resolveCliLocalesRoot() {
|
|
14
|
+
return LOCALES_ROOT;
|
|
15
|
+
}
|
|
16
|
+
/** @deprecated Prefer `loadLocalesManifest` from `@vmz/commander`. */
|
|
17
|
+
export function loadCliLocalesManifest(root = LOCALES_ROOT) {
|
|
18
|
+
return loadLocalesManifest(root);
|
|
19
|
+
}
|
|
20
|
+
/** @deprecated Prefer `loadCatalog` from `@vmz/commander`. */
|
|
21
|
+
export function loadCliCatalog(locale, root = LOCALES_ROOT) {
|
|
22
|
+
return loadCatalog(locale, root);
|
|
23
|
+
}
|
|
24
|
+
/** @deprecated Prefer `loadCatalog('en-US', root)`. */
|
|
25
|
+
export function getVmzCliCatalogEnUs() {
|
|
26
|
+
return loadCatalog('en-US', LOCALES_ROOT);
|
|
27
|
+
}
|
|
28
|
+
/** Eager default table (en-US) for callers that still import a constant. */
|
|
29
|
+
export const VMZ_CLI_CATALOG_EN_US = loadCatalog('en-US', LOCALES_ROOT);
|
|
30
|
+
/** Resolve product locale (`VMZ_LOCALE` first). */
|
|
31
|
+
export function resolveVmzLocale(env = process.env, argv = []) {
|
|
32
|
+
return resolveLocale({
|
|
33
|
+
argv,
|
|
34
|
+
env,
|
|
35
|
+
manifest: loadLocalesManifest(LOCALES_ROOT),
|
|
36
|
+
envKeys: VMZ_ENV_KEYS,
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
/** @deprecated Prefer `translate` / `translateWithFallback` from `@vmz/commander`. */
|
|
40
|
+
export function translateCatalog(id, args, catalog) {
|
|
41
|
+
return translate(id, args, catalog);
|
|
42
|
+
}
|
|
43
|
+
export { flattenCatalog };
|
|
44
|
+
/**
|
|
45
|
+
* Build the official Localize plugin for `@vmz/vmz`.
|
|
46
|
+
*/
|
|
47
|
+
export function createVmzCliLocalize(opts = {}) {
|
|
48
|
+
return createLocalizeFromLocales({
|
|
49
|
+
root: opts.localesRoot ?? LOCALES_ROOT,
|
|
50
|
+
locale: opts.locale,
|
|
51
|
+
catalog: opts.catalog,
|
|
52
|
+
env: opts.env,
|
|
53
|
+
argv: opts.argv,
|
|
54
|
+
envKeys: VMZ_ENV_KEYS,
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
/** Default official plugin (locale from env; catalog from `locales/`). */
|
|
58
|
+
export const vmzCliLocalize = createVmzCliLocalize();
|
package/dist/cli.d.ts
CHANGED
|
@@ -1,23 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Node CLI command implementations .
|
|
3
3
|
*/
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
*/
|
|
7
|
-
export declare function parseArgs(argv: any): {
|
|
8
|
-
_: any[];
|
|
9
|
-
};
|
|
10
|
-
export declare function printGlobalHelp(): void;
|
|
11
|
-
export declare function printProjectHelp(): void;
|
|
4
|
+
export declare function printGlobalHelp(): Promise<number>;
|
|
5
|
+
export declare function printProjectHelp(): Promise<number>;
|
|
12
6
|
/** @deprecated use printProjectHelp / printGlobalHelp */
|
|
13
|
-
export declare function printHelp():
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
* reexec?: (bin: string, argv: string[]) => Promise<number>,
|
|
20
|
-
* }} [opts]
|
|
21
|
-
* @returns {Promise<number>}
|
|
22
|
-
*/
|
|
23
|
-
export declare function runCli(argv: any, opts?: {}): Promise<any>;
|
|
7
|
+
export declare function printHelp(): Promise<number>;
|
|
8
|
+
export declare function runCli(argv: string[], opts?: {
|
|
9
|
+
cwd?: string;
|
|
10
|
+
thisPackageRoot?: string;
|
|
11
|
+
reexec?: (bin: string, argv: string[]) => Promise<number>;
|
|
12
|
+
}): Promise<number>;
|
package/dist/cli.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// @ts-nocheck
|
|
2
1
|
/**
|
|
3
2
|
* Node CLI command implementations .
|
|
4
3
|
*/
|
|
@@ -11,168 +10,82 @@ import { gateGlobalProjectCommand, getInvocationContext, isGlobalAllowedCommand
|
|
|
11
10
|
import { log } from './log.js';
|
|
12
11
|
import { findAvailablePort } from './port.js';
|
|
13
12
|
import { readPackageMeta, resolveWorkspaceDirs } from './resolve.js';
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
13
|
+
import { registerTestCommand } from './test-cmd.js';
|
|
14
|
+
import { registerDocumentCommands } from './document-cmd.js';
|
|
16
15
|
import { buildIntegratedDocuments, projectHasDocuments } from './document-integrate.js';
|
|
17
|
-
import {
|
|
16
|
+
import { registerLocaleCommands } from './locale-cmd.js';
|
|
18
17
|
import { emitLocaleRuntimeModules, localeHasErrors } from './locale-check.js';
|
|
19
18
|
import { emitLocaleRouteRealization } from './locale-route-emit.js';
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
19
|
+
import { registerApplicationCommands } from './application-cmd.js';
|
|
20
|
+
import { registerArtifactCommands } from './release-cmd.js';
|
|
21
|
+
import { registerRefactorCommands } from './refactor-cmd.js';
|
|
22
|
+
import { registerExplainCommand } from './explain-cmd.js';
|
|
23
|
+
import { registerPlanCommands } from './plan-cmd.js';
|
|
25
24
|
import { loadVmzConfig } from './plugin-host.js';
|
|
26
25
|
import { normalizeDeliveryAuthoring, resolveProfileArtifactDir, selectBuildProfile } from './delivery-profile.js';
|
|
27
26
|
import { packFromDeploymentIr } from './pack.js';
|
|
28
27
|
import { assembleDelivery, emitBuildProof } from './build-assemble.js';
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
*/
|
|
32
|
-
export function parseArgs(argv) {
|
|
33
|
-
/** @type {Record<string, string | boolean> & { _: string[] }} */
|
|
34
|
-
const out = { _: [] };
|
|
35
|
-
for (let i = 0; i < argv.length; i++) {
|
|
36
|
-
const a = argv[i];
|
|
37
|
-
if (a === '--') {
|
|
38
|
-
out._.push(...argv.slice(i + 1));
|
|
39
|
-
break;
|
|
40
|
-
}
|
|
41
|
-
if (a.startsWith('--')) {
|
|
42
|
-
const eq = a.indexOf('=');
|
|
43
|
-
if (eq !== -1) {
|
|
44
|
-
out[a.slice(2, eq)] = a.slice(eq + 1);
|
|
45
|
-
continue;
|
|
46
|
-
}
|
|
47
|
-
const key = a.slice(2);
|
|
48
|
-
const next = argv[i + 1];
|
|
49
|
-
if (next && !next.startsWith('-')) {
|
|
50
|
-
out[key] = next;
|
|
51
|
-
i += 1;
|
|
52
|
-
}
|
|
53
|
-
else {
|
|
54
|
-
out[key] = true;
|
|
55
|
-
}
|
|
56
|
-
continue;
|
|
57
|
-
}
|
|
58
|
-
if (a.startsWith('-') && a.length === 2) {
|
|
59
|
-
const key = a === '-o' ? 'out-dir' : a.slice(1);
|
|
60
|
-
const next = argv[i + 1];
|
|
61
|
-
if (next && !next.startsWith('-')) {
|
|
62
|
-
out[key] = next;
|
|
63
|
-
i += 1;
|
|
64
|
-
}
|
|
65
|
-
else {
|
|
66
|
-
out[key] = true;
|
|
67
|
-
}
|
|
68
|
-
continue;
|
|
69
|
-
}
|
|
70
|
-
out._.push(a);
|
|
71
|
-
}
|
|
72
|
-
return out;
|
|
73
|
-
}
|
|
28
|
+
import { createCli } from '@vmz/commander';
|
|
29
|
+
import { resolveCliLocalesRoot } from './cli-localize.js';
|
|
74
30
|
export function printGlobalHelp() {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
Install faces: @vmz/core (runtime) · @vmz/vmz (this CLI) · optional @vmz/ui / @vmz/plugin-*
|
|
78
|
-
|
|
79
|
-
Three install modes:
|
|
80
|
-
developer monorepo source (packages/runtimes/vmz) — full CLI
|
|
81
|
-
project app node_modules/@vmz/vmz — full CLI
|
|
82
|
-
global npm/pnpm -g — only new/init/help/version
|
|
83
|
-
|
|
84
|
-
You are in global mode. Pin \`@vmz/vmz\` in the app so check/build/lsp
|
|
85
|
-
use a traceable project install.
|
|
86
|
-
|
|
87
|
-
Usage:
|
|
88
|
-
vmz new|init <dir> Scaffold (native CLI; Node only gates + forwards)
|
|
89
|
-
vmz version Show host + native protocol versions
|
|
90
|
-
vmz help Show this help
|
|
91
|
-
|
|
92
|
-
Project commands:
|
|
93
|
-
pnpm add @vmz/core && pnpm add -D @vmz/vmz
|
|
94
|
-
pnpm exec vmz check
|
|
95
|
-
# or: vmz new my-app && cd my-app && pnpm install
|
|
96
|
-
|
|
97
|
-
If a project \`node_modules/@vmz/vmz\` exists, a global
|
|
98
|
-
\`vmz <cmd>\` re-execs that bin.
|
|
99
|
-
`);
|
|
31
|
+
return buildProductCli({ mode: 'global' }).parse(['help']);
|
|
100
32
|
}
|
|
101
33
|
export function printProjectHelp() {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
Usage:
|
|
105
|
-
vmz new|init <dir> Scaffold a minimal app (native CLI)
|
|
106
|
-
vmz check [path] Check project via Workspace
|
|
107
|
-
vmz build [path] [options] Build project via Workspace; --target mini-program-wechat packs dist/wechat
|
|
108
|
-
vmz serve [path] [options] Serve dist (optional --build)
|
|
109
|
-
vmz dev [path] [options] Rebuild session; --target mini-program-wechat packs dist/wechat
|
|
110
|
-
vmz format [path] [--check] Format .vmz via N-API (oxc formatter + EditorConfig)
|
|
111
|
-
vmz lint [path] [--deny-warnings] Lint (= check) via N-API
|
|
112
|
-
vmz test [path] [options] Native test discover / report
|
|
113
|
-
vmz document|docs <cmd> Project /documents domain
|
|
114
|
-
vmz application <cmd> Application Collection / Mount
|
|
115
|
-
vmz artifact <cmd> Release pack / publish / rollback / diff (A3)
|
|
116
|
-
vmz refactor <cmd> DX rename plans / apply
|
|
117
|
-
vmz explain [style] <target> DX causal explain (style Theme chain)
|
|
118
|
-
vmz lsp [root] [--out-dir] Language server (stdio; native CLI)
|
|
119
|
-
vmz mcp [root] [--out-dir] MCP server (stdio; native CLI)
|
|
120
|
-
vmz version Show host + native protocol versions
|
|
121
|
-
vmz help Show this help
|
|
122
|
-
|
|
123
|
-
Options:
|
|
124
|
-
--out-dir, -o <dir> Workspace output root (default: dist). Profile artifacts land in <out-dir>/<name> (name defaults to profile id; CDN: name:'cdn' → dist/cdn)
|
|
125
|
-
--release Release build (omit serve-host; pack minify slot; proof)
|
|
126
|
-
--profile <name> Delivery profile (default from config; builtins: web-ssr|static|web-client|web-hybrid)
|
|
127
|
-
--target <id> browser (default) | mini-program-wechat (pack dist/wechat for WeChat DevTools; build+dev)
|
|
128
|
-
--origin <url> Site origin for web-static canonical/sitemap
|
|
129
|
-
--host <host> Listen host (default: 127.0.0.1)
|
|
130
|
-
--port <port> Listen port (dev: omit = auto from 5173; set = lock)
|
|
131
|
-
--poll-ms <ms> Dev watch poll interval (default: 300)
|
|
132
|
-
--build Build before serve
|
|
133
|
-
--check Format check-only (format)
|
|
134
|
-
--deny-warnings Treat warnings as errors (lint)
|
|
135
|
-
--list List discovered tests (test)
|
|
136
|
-
--json [file] Emit TestReport / DocumentManifest / ApplicationCheckReport JSON
|
|
137
|
-
--mode <modes> compile|logic|browser|ssr|resume|deployment|all (test)
|
|
138
|
-
--filter <pattern> Filter by test id or file (test)
|
|
139
|
-
--application <id> Run only tests for ApplicationId (standalone scope)
|
|
140
|
-
--mounted <id> Run relocation + host-boundary tests for ApplicationId
|
|
141
|
-
--affected Select tests from dirty VPG units (test; DX)
|
|
142
|
-
--root <dir> Project root (document check)
|
|
143
|
-
--strict Strict document locale/PageKey coverage (document check)
|
|
144
|
-
`);
|
|
34
|
+
return buildProductCli({ mode: 'project' }).parse(['help']);
|
|
145
35
|
}
|
|
146
36
|
/** @deprecated use printProjectHelp / printGlobalHelp */
|
|
147
37
|
export function printHelp() {
|
|
148
|
-
printProjectHelp();
|
|
38
|
+
return printProjectHelp();
|
|
39
|
+
}
|
|
40
|
+
function buildProductCli(opts = {}) {
|
|
41
|
+
const mode = opts.mode === 'global' ? 'global' : 'project';
|
|
42
|
+
const introId = mode === 'global' ? 'cli.intro.global' : 'cli.intro.project';
|
|
43
|
+
const cli = createCli('vmz')
|
|
44
|
+
.locales(resolveCliLocalesRoot(), {
|
|
45
|
+
envKeys: ['VMZ_LOCALE', 'LOCALE', 'LANG', 'LC_ALL'],
|
|
46
|
+
})
|
|
47
|
+
.intro(introId);
|
|
48
|
+
// Global install: only version (help is derived). Project commands need a project bin.
|
|
49
|
+
if (mode === 'global') {
|
|
50
|
+
cli.command('version', 'cli.cmd.version').action(() => cmdVersion());
|
|
51
|
+
return cli;
|
|
52
|
+
}
|
|
53
|
+
const withWorkspaceOpts = (cmd) => cmd
|
|
54
|
+
.option('--out-dir, -o <dir>', 'cli.opt.out-dir')
|
|
55
|
+
.option('--release', 'cli.opt.release')
|
|
56
|
+
.option('--profile <name>', 'cli.opt.profile')
|
|
57
|
+
.option('--target <id>', 'cli.opt.target')
|
|
58
|
+
.option('--origin <url>', 'cli.opt.origin')
|
|
59
|
+
.option('--host <host>', 'cli.opt.host')
|
|
60
|
+
.option('--port <port>', 'cli.opt.port')
|
|
61
|
+
.option('--poll-ms <ms>', 'cli.opt.poll-ms')
|
|
62
|
+
.option('--build', 'cli.opt.build')
|
|
63
|
+
.option('--check', 'cli.opt.check')
|
|
64
|
+
.option('--deny-warnings', 'cli.opt.deny-warnings');
|
|
65
|
+
withWorkspaceOpts(cli.command('check', 'cli.cmd.check')).action((options) => cmdCheck(options));
|
|
66
|
+
withWorkspaceOpts(cli.command('build', 'cli.cmd.build')).action((options) => cmdBuild(options));
|
|
67
|
+
withWorkspaceOpts(cli.command('serve', 'cli.cmd.serve')).action((options) => cmdServe(options));
|
|
68
|
+
withWorkspaceOpts(cli.command('dev', 'cli.cmd.dev')).action((options) => cmdDev(options));
|
|
69
|
+
withWorkspaceOpts(cli.command('format', 'cli.cmd.format')).action((options) => cmdFormat(options));
|
|
70
|
+
withWorkspaceOpts(cli.command('lint', 'cli.cmd.lint')).action((options) => cmdLint(options));
|
|
71
|
+
registerTestCommand(cli);
|
|
72
|
+
registerDocumentCommands(cli.command('document|docs', 'cli.cmd.document'));
|
|
73
|
+
registerLocaleCommands(cli.command('locale|locales', 'cli.cmd.locale'));
|
|
74
|
+
registerPlanCommands(cli.command('plan', 'cli.cmd.plan'));
|
|
75
|
+
registerApplicationCommands(cli.command('application|applications|app', 'cli.cmd.application'));
|
|
76
|
+
registerArtifactCommands(cli.command('artifact|artifacts|release', 'cli.cmd.artifact'));
|
|
77
|
+
registerRefactorCommands(cli.command('refactor', 'cli.cmd.refactor'));
|
|
78
|
+
registerExplainCommand(cli);
|
|
79
|
+
cli.command('version', 'cli.cmd.version').action(() => cmdVersion());
|
|
80
|
+
return cli;
|
|
149
81
|
}
|
|
150
|
-
/**
|
|
151
|
-
* @param {string[]} argv
|
|
152
|
-
* @param {{
|
|
153
|
-
* cwd?: string,
|
|
154
|
-
* thisPackageRoot?: string,
|
|
155
|
-
* reexec?: (bin: string, argv: string[]) => Promise<number>,
|
|
156
|
-
* }} [opts]
|
|
157
|
-
* @returns {Promise<number>}
|
|
158
|
-
*/
|
|
159
82
|
export async function runCli(argv, opts = {}) {
|
|
160
|
-
const [cmd
|
|
83
|
+
const [cmd] = argv;
|
|
161
84
|
const inv = getInvocationContext({
|
|
162
85
|
cwd: opts.cwd,
|
|
163
86
|
thisPackageRoot: opts.thisPackageRoot,
|
|
164
87
|
});
|
|
165
|
-
if (!cmd
|
|
166
|
-
if (inv.mode === 'global')
|
|
167
|
-
printGlobalHelp();
|
|
168
|
-
else
|
|
169
|
-
printProjectHelp();
|
|
170
|
-
return 0;
|
|
171
|
-
}
|
|
172
|
-
if (cmd === 'version' || cmd === '-V' || cmd === '--version') {
|
|
173
|
-
return cmdVersion();
|
|
174
|
-
}
|
|
175
|
-
if (!isGlobalAllowedCommand(cmd)) {
|
|
88
|
+
if (cmd && !isHelpToken(cmd) && cmd !== 'version' && cmd !== '-V' && cmd !== '--version' && !isGlobalAllowedCommand(cmd)) {
|
|
176
89
|
const gated = await gateGlobalProjectCommand({
|
|
177
90
|
argv,
|
|
178
91
|
cwd: opts.cwd,
|
|
@@ -183,85 +96,13 @@ export async function runCli(argv, opts = {}) {
|
|
|
183
96
|
if (gated.action === 'exit')
|
|
184
97
|
return gated.code;
|
|
185
98
|
}
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
return cmdNativeForward(cmd, rest);
|
|
191
|
-
case 'check':
|
|
192
|
-
return cmdCheck(args);
|
|
193
|
-
case 'build':
|
|
194
|
-
return cmdBuild(args);
|
|
195
|
-
case 'serve':
|
|
196
|
-
return cmdServe(args);
|
|
197
|
-
case 'dev':
|
|
198
|
-
return cmdDev(args);
|
|
199
|
-
case 'format':
|
|
200
|
-
return cmdFormat(args);
|
|
201
|
-
case 'lint':
|
|
202
|
-
return cmdLint(args);
|
|
203
|
-
case 'test':
|
|
204
|
-
return cmdTest(args);
|
|
205
|
-
case 'document':
|
|
206
|
-
case 'docs':
|
|
207
|
-
return cmdDocument(rest);
|
|
208
|
-
case 'locale':
|
|
209
|
-
case 'locales':
|
|
210
|
-
return cmdLocale(rest);
|
|
211
|
-
case 'application':
|
|
212
|
-
case 'applications':
|
|
213
|
-
case 'app':
|
|
214
|
-
return cmdApplication(rest);
|
|
215
|
-
case 'artifact':
|
|
216
|
-
case 'artifacts':
|
|
217
|
-
case 'release':
|
|
218
|
-
return cmdArtifact(rest);
|
|
219
|
-
case 'refactor':
|
|
220
|
-
return cmdRefactor(rest);
|
|
221
|
-
case 'explain':
|
|
222
|
-
return cmdExplain(rest);
|
|
223
|
-
case 'lsp':
|
|
224
|
-
return cmdNativeForward('lsp', rest);
|
|
225
|
-
case 'mcp':
|
|
226
|
-
return cmdNativeForward('mcp', rest);
|
|
227
|
-
default:
|
|
228
|
-
log.error(`unknown command \`${cmd}\``);
|
|
229
|
-
if (inv.mode === 'global')
|
|
230
|
-
printGlobalHelp();
|
|
231
|
-
else
|
|
232
|
-
printProjectHelp();
|
|
233
|
-
return 1;
|
|
234
|
-
}
|
|
99
|
+
// Normalize version aliases onto the registered `version` command.
|
|
100
|
+
const normalized = cmd === '-V' || cmd === '--version' ? ['version', ...argv.slice(1)] : argv;
|
|
101
|
+
const mode = inv.mode === 'global' ? 'global' : 'project';
|
|
102
|
+
return buildProductCli({ mode }).parse(normalized);
|
|
235
103
|
}
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
* Scaffold / stdio servers live in Rust — Node only gates + re-execs.
|
|
239
|
-
*
|
|
240
|
-
* @param {'new' | 'init' | 'lsp' | 'mcp'} sub
|
|
241
|
-
* @param {string[]} argv
|
|
242
|
-
* @returns {Promise<number>}
|
|
243
|
-
*/
|
|
244
|
-
function cmdNativeForward(sub, argv) {
|
|
245
|
-
const bin = resolveNativeVmzCli();
|
|
246
|
-
if (!bin) {
|
|
247
|
-
log.error('native `vmz` CLI not found (vmz-tools).');
|
|
248
|
-
log.error('Build: cargo build -p vmz-tools');
|
|
249
|
-
log.error('Or set VMZ_NATIVE to the absolute path of that binary.');
|
|
250
|
-
return Promise.resolve(1);
|
|
251
|
-
}
|
|
252
|
-
return new Promise((resolve) => {
|
|
253
|
-
const child = spawn(bin, [sub, ...argv], { stdio: 'inherit' });
|
|
254
|
-
child.on('error', (err) => {
|
|
255
|
-
log.error(`failed to spawn ${bin}: ${err.message}`);
|
|
256
|
-
resolve(1);
|
|
257
|
-
});
|
|
258
|
-
child.on('exit', (code, signal) => {
|
|
259
|
-
if (signal)
|
|
260
|
-
resolve(1);
|
|
261
|
-
else
|
|
262
|
-
resolve(code ?? 1);
|
|
263
|
-
});
|
|
264
|
-
});
|
|
104
|
+
function isHelpToken(token) {
|
|
105
|
+
return token === 'help' || token === '-h' || token === '--help';
|
|
265
106
|
}
|
|
266
107
|
function cmdVersion() {
|
|
267
108
|
const native = getProtocolVersions();
|
|
@@ -269,10 +110,7 @@ function cmdVersion() {
|
|
|
269
110
|
console.log(`native host=${native.hostProtocol} compiler=${native.compilerProtocol} program_ir=${native.programIrSchema} plugin=${native.pluginProtocol}`);
|
|
270
111
|
return 0;
|
|
271
112
|
}
|
|
272
|
-
|
|
273
|
-
* @param {Record<string, string | boolean> & { _: string[] }} args
|
|
274
|
-
*/
|
|
275
|
-
function cmdCheck(args) {
|
|
113
|
+
async function cmdCheck(args) {
|
|
276
114
|
const pathArg = args._[0] ?? '.';
|
|
277
115
|
const { project, outDir } = resolveWorkspaceDirs({
|
|
278
116
|
path: pathArg,
|
|
@@ -297,13 +135,9 @@ function cmdCheck(args) {
|
|
|
297
135
|
ws.dispose();
|
|
298
136
|
}
|
|
299
137
|
}
|
|
300
|
-
/**
|
|
301
|
-
* Dedupe locale/build diagnostics by code+path+message (runtime + route emit both report missing manifest).
|
|
302
|
-
* @param {Array<{ code?: string, path?: string, message?: string, severity?: string }>} list
|
|
303
|
-
*/
|
|
138
|
+
/** Dedupe locale/build diagnostics by code+path+message (runtime + route emit both report missing manifest). */
|
|
304
139
|
function dedupeDiagnostics(list) {
|
|
305
140
|
const seen = new Set();
|
|
306
|
-
/** @type {typeof list} */
|
|
307
141
|
const out = [];
|
|
308
142
|
for (const d of list || []) {
|
|
309
143
|
const key = `${d.code || ''}\0${d.path || ''}\0${d.message || ''}\0${d.severity || ''}`;
|
|
@@ -314,12 +148,6 @@ function dedupeDiagnostics(list) {
|
|
|
314
148
|
}
|
|
315
149
|
return out;
|
|
316
150
|
}
|
|
317
|
-
/**
|
|
318
|
-
* @param {import('./index.js').Workspace} ws
|
|
319
|
-
* @param {string} project
|
|
320
|
-
* @param {string} outDir
|
|
321
|
-
* @param {() => Promise<number> | number} fn
|
|
322
|
-
*/
|
|
323
151
|
async function runWithPlugins(ws, project, outDir, fn) {
|
|
324
152
|
const { loadVmzConfig, applyPlugins } = await import('./plugin-host.js');
|
|
325
153
|
const { plugins, engines } = await loadVmzConfig(project);
|
|
@@ -328,14 +156,11 @@ async function runWithPlugins(ws, project, outDir, fn) {
|
|
|
328
156
|
}
|
|
329
157
|
return await fn();
|
|
330
158
|
}
|
|
331
|
-
/**
|
|
332
|
-
* @param {Record<string, string | boolean> & { _: string[] }} args
|
|
333
|
-
*/
|
|
334
159
|
async function cmdBuild(args) {
|
|
335
160
|
const pathArg = args._[0] ?? '.';
|
|
336
161
|
const targetRaw = typeof args.target === 'string' ? args.target : 'browser';
|
|
337
162
|
if (targetRaw !== 'browser' && targetRaw !== 'mini-program-wechat') {
|
|
338
|
-
log.
|
|
163
|
+
log.errorId('cli.err.unknown_target', { target: String(targetRaw) });
|
|
339
164
|
return 1;
|
|
340
165
|
}
|
|
341
166
|
const wechatPack = targetRaw === 'mini-program-wechat';
|
|
@@ -457,7 +282,8 @@ async function cmdBuild(args) {
|
|
|
457
282
|
selection: selected.selection,
|
|
458
283
|
profile: {
|
|
459
284
|
...selected.profile,
|
|
460
|
-
sources: selected.profile.sources ||
|
|
285
|
+
sources: selected.profile.sources ||
|
|
286
|
+
(norm.table.sugar ? norm.table.profiles[norm.table.default]?.sources : null),
|
|
461
287
|
},
|
|
462
288
|
siteId: cfg.application?.id || undefined,
|
|
463
289
|
origin,
|
|
@@ -559,9 +385,6 @@ async function cmdServe(args) {
|
|
|
559
385
|
});
|
|
560
386
|
});
|
|
561
387
|
}
|
|
562
|
-
/**
|
|
563
|
-
* @param {Record<string, string | boolean> & { _: string[] }} args
|
|
564
|
-
*/
|
|
565
388
|
async function cmdDev(args) {
|
|
566
389
|
const pathArg = args._[0] ?? '.';
|
|
567
390
|
const { project, outDir: outDirRoot } = resolveWorkspaceDirs({
|
|
@@ -603,7 +426,7 @@ async function cmdDev(args) {
|
|
|
603
426
|
const pollMs = Number(args['poll-ms'] ?? 300);
|
|
604
427
|
const targetRaw = typeof args.target === 'string' ? args.target : 'browser';
|
|
605
428
|
if (targetRaw !== 'browser' && targetRaw !== 'mini-program-wechat') {
|
|
606
|
-
log.
|
|
429
|
+
log.errorId('cli.err.unknown_target', { target: String(targetRaw) });
|
|
607
430
|
return 1;
|
|
608
431
|
}
|
|
609
432
|
const ac = new AbortController();
|
|
@@ -638,9 +461,6 @@ async function cmdDev(args) {
|
|
|
638
461
|
await session.stop();
|
|
639
462
|
}
|
|
640
463
|
}
|
|
641
|
-
/**
|
|
642
|
-
* @param {Record<string, string | boolean> & { _: string[] }} args
|
|
643
|
-
*/
|
|
644
464
|
function cmdFormat(args) {
|
|
645
465
|
const pathArg = args._[0] ?? '.';
|
|
646
466
|
const { project, outDir } = resolveWorkspaceDirs({
|
|
@@ -664,9 +484,6 @@ function cmdFormat(args) {
|
|
|
664
484
|
ws.dispose();
|
|
665
485
|
}
|
|
666
486
|
}
|
|
667
|
-
/**
|
|
668
|
-
* @param {Record<string, string | boolean> & { _: string[] }} args
|
|
669
|
-
*/
|
|
670
487
|
function cmdLint(args) {
|
|
671
488
|
const pathArg = args._[0] ?? '.';
|
|
672
489
|
const { project, outDir } = resolveWorkspaceDirs({
|
|
@@ -6,6 +6,26 @@
|
|
|
6
6
|
* resolve at dist root — never prefer hashed siblings for JS (second-hop 404).
|
|
7
7
|
*/
|
|
8
8
|
export declare const CONTENT_ADDRESSED_ASSETS_SCHEMA = "vmz.content_addressed_assets.v0";
|
|
9
|
+
interface ContentAddressedAssetObject {
|
|
10
|
+
logicalPath: string;
|
|
11
|
+
assetPath: string;
|
|
12
|
+
digest: string;
|
|
13
|
+
bytes: number;
|
|
14
|
+
immutable: boolean;
|
|
15
|
+
}
|
|
16
|
+
export interface ContentAddressedAssetsManifest {
|
|
17
|
+
schema: string;
|
|
18
|
+
layout: string;
|
|
19
|
+
immutable: boolean;
|
|
20
|
+
objectCount: number;
|
|
21
|
+
objects: ContentAddressedAssetObject[];
|
|
22
|
+
rewrittenHtml: number;
|
|
23
|
+
manifestDigest?: string;
|
|
24
|
+
}
|
|
25
|
+
interface EmitContentAddressedAssetsOpts {
|
|
26
|
+
candidates?: string[];
|
|
27
|
+
rewriteHtml?: boolean;
|
|
28
|
+
}
|
|
9
29
|
/**
|
|
10
30
|
* Rewrite relative `@import "./foo.css"` to hashed paths under assets/.
|
|
11
31
|
* @param {string} cssText
|
|
@@ -30,17 +50,10 @@ export declare function rewriteJsEntryRelativeImports(jsText: any, _rewrites?: {
|
|
|
30
50
|
* @param {string} distDir
|
|
31
51
|
* @param {{ candidates?: string[], rewriteHtml?: boolean }} [opts]
|
|
32
52
|
*/
|
|
33
|
-
export declare function emitContentAddressedAssets(distDir:
|
|
34
|
-
manifest:
|
|
35
|
-
schema: string;
|
|
36
|
-
layout: string;
|
|
37
|
-
immutable: boolean;
|
|
38
|
-
objectCount: number;
|
|
39
|
-
objects: any[];
|
|
40
|
-
rewrittenHtml: number;
|
|
41
|
-
};
|
|
53
|
+
export declare function emitContentAddressedAssets(distDir: string, opts?: EmitContentAddressedAssetsOpts): {
|
|
54
|
+
manifest: ContentAddressedAssetsManifest;
|
|
42
55
|
assetsDir: string;
|
|
43
|
-
rewrites:
|
|
56
|
+
rewrites: Record<string, string>;
|
|
44
57
|
manifestPath: string;
|
|
45
58
|
};
|
|
46
59
|
/**
|
|
@@ -88,3 +101,4 @@ export declare function assertSharedAssetPath(distDir: any, a: any, b: any, ext?
|
|
|
88
101
|
};
|
|
89
102
|
export declare function contentAddressedAssetsDigest(manifest: any): any;
|
|
90
103
|
export declare function sha256Buffer(buf: any): string;
|
|
104
|
+
export {};
|