@mpgd/cli 0.27.0 → 0.28.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.
@@ -40,12 +40,16 @@ export function normalizeConfiguredBuildTargets(configuredTargets) {
40
40
  }
41
41
  function resolveBuildTarget(target, configuredTargets) {
42
42
  const configuredWebTarget = isConfiguredWebTarget(target, configuredTargets);
43
- if (configuredWebTarget) {
43
+ const configuredMiniGameTarget = isConfiguredMiniGameTarget(target, configuredTargets);
44
+ if (configuredWebTarget || configuredMiniGameTarget) {
44
45
  assertDeploymentTargetName(target);
45
46
  }
46
47
  if (target === 'web' && configuredWebTarget) {
47
48
  return target;
48
49
  }
50
+ if (configuredMiniGameTarget) {
51
+ return target;
52
+ }
49
53
  const builtInTarget = normalizeBuiltInBuildTarget(target);
50
54
  if (builtInTarget !== undefined) {
51
55
  return builtInTarget;
@@ -55,6 +59,17 @@ function resolveBuildTarget(target, configuredTargets) {
55
59
  }
56
60
  return undefined;
57
61
  }
62
+ function isConfiguredMiniGameTarget(target, configuredTargets) {
63
+ if (!Object.prototype.hasOwnProperty.call(configuredTargets, target)) {
64
+ return false;
65
+ }
66
+ const configuredTarget = configuredTargets[target];
67
+ return typeof configuredTarget === 'object'
68
+ && configuredTarget !== null
69
+ && !Array.isArray(configuredTarget)
70
+ && 'kind' in configuredTarget
71
+ && configuredTarget.kind === 'wechat-minigame';
72
+ }
58
73
  function normalizeBuiltInBuildTarget(target) {
59
74
  if (target === 'browser' || target === 'web') {
60
75
  return 'web-preview';
@@ -5,6 +5,7 @@ export interface ProductionTargetReadinessInput {
5
5
  readonly gameRoot: string;
6
6
  readonly gameServicesUrl?: string;
7
7
  readonly targetPolicy?: ProductionTargetPolicy;
8
+ readonly environment?: NodeJS.ProcessEnv;
8
9
  }
9
10
  export interface ProductionTargetPolicy {
10
11
  readonly runtime: string;
@@ -1,6 +1,7 @@
1
1
  import { existsSync, readFileSync, realpathSync } from 'node:fs';
2
2
  import { isIP } from 'node:net';
3
3
  import path from 'node:path';
4
+ const wechatStagingAppId = 'wx0000000000000000';
4
5
  const ownerPathByTarget = {
5
6
  ait: 'wrapperApp',
6
7
  android: 'shellApp',
@@ -23,6 +24,7 @@ export function assertProductionTargetReadiness(input) {
23
24
  if (!isRecord(targetConfig)) {
24
25
  throw new Error(`Missing target configuration for ${input.target}.`);
25
26
  }
27
+ assertExperimentalTargetReadiness(input, targetConfig);
26
28
  const targetPolicy = targetConfig.authoritativeGameServices === false
27
29
  ? disableMonetization(input.targetPolicy)
28
30
  : input.targetPolicy;
@@ -83,6 +85,24 @@ export function assertProductionTargetReadiness(input) {
83
85
  assertAuthoritativeGameServicesUrl(input.gameServicesUrl, input.target);
84
86
  }
85
87
  }
88
+ function assertExperimentalTargetReadiness(input, targetConfig) {
89
+ if (targetConfig.experimental !== true) {
90
+ return;
91
+ }
92
+ const environment = input.environment ?? process.env;
93
+ if (environment.MPGD_ALLOW_EXPERIMENTAL_TARGET !== '1') {
94
+ throw new Error(`Production build for experimental target ${input.target} is blocked.\n`
95
+ + 'Set MPGD_ALLOW_EXPERIMENTAL_TARGET=1 only for platform validation builds.');
96
+ }
97
+ if (targetConfig.kind === 'wechat-minigame') {
98
+ const appId = environment.MPGD_WECHAT_APP_ID?.trim();
99
+ if (appId === undefined
100
+ || appId === wechatStagingAppId
101
+ || !/^wx[0-9a-f]{16}$/u.test(appId)) {
102
+ throw new Error('Production WeChat Mini Game builds require MPGD_WECHAT_APP_ID.');
103
+ }
104
+ }
105
+ }
86
106
  function disableMonetization(policy) {
87
107
  if (policy === undefined) {
88
108
  return undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mpgd/cli",
3
- "version": "0.27.0",
3
+ "version": "0.28.1",
4
4
  "description": "Gunshi CLI for mpgd-kit starter generation and target workflow orchestration.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -52,19 +52,19 @@
52
52
  "@types/node": "^24.0.0",
53
53
  "ttsc": "0.18.4",
54
54
  "typescript": "7.0.2",
55
- "@mpgd/adapter-capacitor": "0.4.8",
56
- "@mpgd/adapter-ait": "0.12.0",
57
- "@mpgd/adapter-devvit": "0.9.5",
58
- "@mpgd/adapter-browser": "0.7.2",
59
- "@mpgd/adapter-verse8": "0.3.3",
60
- "@mpgd/analytics": "0.3.11",
55
+ "@mpgd/adapter-ait": "0.12.1",
56
+ "@mpgd/adapter-capacitor": "0.4.10",
57
+ "@mpgd/adapter-devvit": "0.9.6",
58
+ "@mpgd/adapter-verse8": "0.3.4",
59
+ "@mpgd/adapter-browser": "0.7.3",
60
+ "@mpgd/analytics": "0.3.12",
61
61
  "@mpgd/bridge": "0.9.0",
62
- "@mpgd/catalog": "0.7.1",
63
- "@mpgd/game-services": "0.13.1",
62
+ "@mpgd/catalog": "0.7.2",
63
+ "@mpgd/game-services": "0.14.0",
64
+ "@mpgd/i18n": "0.6.0",
64
65
  "@mpgd/phaser-assets": "0.4.1",
65
- "@mpgd/platform": "0.11.0",
66
- "@mpgd/target-config": "0.13.1",
67
- "@mpgd/i18n": "0.5.7"
66
+ "@mpgd/target-config": "0.14.0",
67
+ "@mpgd/platform": "0.12.0"
68
68
  },
69
69
  "main": "./dist/index.js",
70
70
  "types": "./dist/index.d.ts",
@@ -9,6 +9,8 @@ const validTargets = new Set<string>([
9
9
  'verse8',
10
10
  'telegram',
11
11
  'tauri',
12
+ 'wechat',
13
+ 'tiktok',
12
14
  ] satisfies readonly PlatformTarget[]);
13
15
 
14
16
  export interface RuntimeConfig {
@@ -20,6 +20,8 @@ const runtimeKinds = valueSet({
20
20
  'apps-in-toss': true,
21
21
  'devvit-web': true,
22
22
  'verse8-web': true,
23
+ 'wechat-minigame': true,
24
+ 'tiktok-minigame': true,
23
25
  } satisfies Record<TargetRuntimeKind, true>);
24
26
  const releaseProfiles = valueSet({
25
27
  web: true,
@@ -30,6 +32,8 @@ const releaseProfiles = valueSet({
30
32
  'apps-in-toss': true,
31
33
  'devvit': true,
32
34
  'verse8': true,
35
+ 'wechat-minigame': true,
36
+ 'tiktok-minigame': true,
33
37
  } satisfies Record<ReleaseProfile, true>);
34
38
  const storageSupportValues = valueSet({
35
39
  local: true,
@@ -138,6 +138,16 @@ export function resolveBuildGatewayModule(input: {
138
138
  return 'src/platform/buildGateways/verse8.ts';
139
139
  case 'microsoft-store':
140
140
  return 'src/platform/buildGateways/microsoftStore.ts';
141
+ case 'telegram':
142
+ case 'tauri':
143
+ throw new Error(
144
+ `Direct APP_TARGET=${input.target} builds are unavailable until its native platform gateway is installed.`,
145
+ );
146
+ case 'wechat':
147
+ case 'tiktok':
148
+ throw new Error(
149
+ `Direct APP_TARGET=${input.target} builds are unavailable until the native mini-game gateway and artifact emitter are installed.`,
150
+ );
141
151
  default:
142
152
  return 'src/platform/buildGateways/browser.ts';
143
153
  }