@intra-mart/accel 1.0.0 → 2.0.0-dev.202610210621

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. package/README.md +93 -6
  2. package/dist/asset/deployer.js +1 -2
  3. package/dist/asset/fetch-once.d.ts +2 -0
  4. package/dist/asset/fetch-once.js +14 -0
  5. package/dist/asset/mobile-meta.d.ts +15 -0
  6. package/dist/asset/mobile-meta.js +86 -0
  7. package/dist/asset/root-selection.d.ts +12 -0
  8. package/dist/asset/root-selection.js +78 -0
  9. package/dist/asset/updater.js +1 -1
  10. package/dist/asset/walker.d.ts +1 -1
  11. package/dist/asset/walker.js +3 -26
  12. package/dist/commands/attach-existing-files.d.ts +12 -0
  13. package/dist/commands/attach-existing-files.js +76 -0
  14. package/dist/commands/attach.d.ts +20 -0
  15. package/dist/commands/attach.js +77 -77
  16. package/dist/commands/deploy.js +16 -13
  17. package/dist/commands/detach.js +7 -3
  18. package/dist/commands/init.d.ts +20 -0
  19. package/dist/commands/init.js +71 -4
  20. package/dist/commands/login.js +12 -6
  21. package/dist/commands/mobile/attach.d.ts +7 -0
  22. package/dist/commands/mobile/attach.js +60 -0
  23. package/dist/commands/mobile/init.d.ts +4 -0
  24. package/dist/commands/mobile/init.js +95 -0
  25. package/dist/commands/mobile/shared.d.ts +65 -0
  26. package/dist/commands/mobile/shared.js +254 -0
  27. package/dist/commands/mobile/update.d.ts +8 -0
  28. package/dist/commands/mobile/update.js +109 -0
  29. package/dist/commands/mobile-sdk-options.d.ts +10 -0
  30. package/dist/commands/mobile-sdk-options.js +19 -0
  31. package/dist/commands/preset.d.ts +1 -1
  32. package/dist/commands/preset.js +35 -13
  33. package/dist/commands/project-type-select.d.ts +17 -0
  34. package/dist/commands/project-type-select.js +26 -0
  35. package/dist/commands/switch.d.ts +1 -1
  36. package/dist/commands/switch.js +118 -48
  37. package/dist/commands/update.d.ts +22 -0
  38. package/dist/commands/update.js +179 -106
  39. package/dist/core/condition-evaluator.js +4 -1
  40. package/dist/core/constants.d.ts +12 -2
  41. package/dist/core/constants.js +16 -0
  42. package/dist/core/eval-context.js +27 -0
  43. package/dist/core/project-type.d.ts +20 -0
  44. package/dist/core/project-type.js +49 -0
  45. package/dist/core/types.d.ts +28 -9
  46. package/dist/core/types.js +2 -0
  47. package/dist/core/validation.d.ts +2 -2
  48. package/dist/core/validators.d.ts +7 -0
  49. package/dist/core/validators.js +38 -1
  50. package/dist/core/variable-interpolator.js +2 -0
  51. package/dist/i18n/en.js +59 -0
  52. package/dist/i18n/ja.js +59 -0
  53. package/dist/i18n/zh_CN.js +59 -0
  54. package/dist/interactive/agent-detect.d.ts +1 -1
  55. package/dist/interactive/agent-detect.js +6 -6
  56. package/dist/interactive/mobile-prompts.d.ts +15 -0
  57. package/dist/interactive/mobile-prompts.js +45 -0
  58. package/dist/interactive/next-steps.d.ts +4 -0
  59. package/dist/interactive/next-steps.js +11 -0
  60. package/dist/interactive/prompts.d.ts +5 -2
  61. package/dist/interactive/prompts.js +23 -19
  62. package/dist/interactive/summary.d.ts +5 -3
  63. package/dist/interactive/summary.js +38 -0
  64. package/dist/lib.d.ts +11 -5
  65. package/dist/lib.js +6 -3
  66. package/dist/utils/args.d.ts +1 -0
  67. package/dist/utils/args.js +16 -0
  68. package/dist/utils/expo-project.d.ts +8 -0
  69. package/dist/utils/expo-project.js +54 -0
  70. package/dist/utils/external-command.d.ts +68 -0
  71. package/dist/utils/external-command.js +238 -0
  72. package/dist/utils/preset-io.d.ts +1 -0
  73. package/dist/utils/preset-io.js +18 -1
  74. package/dist/utils/settings-io.d.ts +1 -0
  75. package/dist/utils/settings-io.js +12 -0
  76. package/package.json +1 -1
@@ -0,0 +1,95 @@
1
+ import { resolve } from "node:path";
2
+ import { DEFAULT_SETTINGS } from "../../core/constants.js";
3
+ import { checkProjectDirAvailable } from "../../core/validation.js";
4
+ import { getMessage } from "../../i18n/index.js";
5
+ import { deployAssets } from "../../asset/deployer.js";
6
+ import { buildCreateExpoRequest, formatCommandLine, formatOutputTail, } from "../../utils/external-command.js";
7
+ import { inspectCreatedProject } from "../../utils/expo-project.js";
8
+ import { sanitizeDisplayText } from "../../utils/sanitize-text.js";
9
+ import { printMobileSummary } from "../../interactive/summary.js";
10
+ import { buildMobileSettings, confirmOrCancel, finishMobile, formatSkillsCommandLine, listSdkCandidates, openMobileProvider, printMobileIntro, resolveAgents, resolveExpoSdk, resolveExpoSkills, resolveNameAndTarget, validateMobileCliValues, withSpinner, } from "./shared.js";
11
+ const assertProjectDirAvailable = async (baseDir, name, locale) => {
12
+ const error = await checkProjectDirAvailable(baseDir, name, locale);
13
+ if (error)
14
+ throw new Error(error);
15
+ };
16
+ export const runMobileInit = async (input) => {
17
+ const { locale, logger } = input;
18
+ validateMobileCliValues(input, "init");
19
+ printMobileIntro(input, "init");
20
+ const provider = await openMobileProvider(input);
21
+ try {
22
+ const { name, targetReleaseId } = await resolveNameAndTarget(input, "init", DEFAULT_SETTINGS.name, (n) => assertProjectDirAvailable(input.baseDir, n, locale));
23
+ const projectDir = resolve(input.baseDir, name);
24
+ const candidates = await listSdkCandidates(provider, targetReleaseId, locale);
25
+ const selected = await resolveExpoSdk(input, candidates);
26
+ const agents = await resolveAgents(input);
27
+ const packageManager = input.packageManager ?? DEFAULT_SETTINGS.packageManager;
28
+ const plan = await resolveExpoSkills(input, selected.mobile, agents, packageManager, projectDir);
29
+ const settings = buildMobileSettings({
30
+ name,
31
+ targetReleaseId,
32
+ expoSdk: selected.mobile.expoSdk,
33
+ agents,
34
+ locale,
35
+ packageManager,
36
+ });
37
+ const createExpo = buildCreateExpoRequest({
38
+ createExpo: selected.mobile.createExpo,
39
+ name,
40
+ parentDir: input.baseDir,
41
+ packageManager,
42
+ skipInstall: input.skipInstall,
43
+ signal: input.signal,
44
+ });
45
+ if (!input.nonInteractive) {
46
+ printMobileSummary(settings, projectDir, [
47
+ formatCommandLine(createExpo),
48
+ ...(plan?.install
49
+ ? [formatSkillsCommandLine(plan, projectDir, packageManager)]
50
+ : []),
51
+ ], locale, logger);
52
+ }
53
+ await confirmOrCancel(input, "init");
54
+ await assertProjectDirAvailable(input.baseDir, name, locale);
55
+ await runCreateExpo(input, createExpo, projectDir, packageManager);
56
+ await deployAssets({
57
+ projectDir,
58
+ settings,
59
+ provider,
60
+ noInstall: true,
61
+ progress: { ...input.progress, onFetchStart: undefined },
62
+ signal: input.signal,
63
+ });
64
+ await finishMobile(input, "init", projectDir, settings, plan);
65
+ }
66
+ finally {
67
+ await provider.cleanup().catch(() => { });
68
+ }
69
+ };
70
+ const runCreateExpo = async (input, request, projectDir, packageManager) => {
71
+ const { locale, logger } = input;
72
+ const command = formatCommandLine(request);
73
+ const result = await withSpinner(input, getMessage("progress.createExpo", locale), () => input.runExternalCommand(request));
74
+ if (!result.launched) {
75
+ const message = getMessage("error.externalRunnerNotFound", locale, {
76
+ command: result.missing,
77
+ });
78
+ throw new Error(result.missing === request.command
79
+ ? `${message}\n${getMessage("hint.packageManagerOption", locale)}`
80
+ : message);
81
+ }
82
+ const state = await inspectCreatedProject(projectDir, packageManager);
83
+ if (result.exitCode !== 0 || !state.hasPackageJson) {
84
+ throw new Error(getMessage("error.createExpoFailed", locale, {
85
+ command,
86
+ dir: sanitizeDisplayText(projectDir),
87
+ output: formatOutputTail(result.outputTail),
88
+ }));
89
+ }
90
+ if (!input.skipInstall && !state.installed) {
91
+ logger.warn(getMessage("warning.createExpoInstallIncomplete", locale, {
92
+ command: `${packageManager} install`,
93
+ }));
94
+ }
95
+ };
@@ -0,0 +1,65 @@
1
+ import type { AssetProvider, MobileProjectSettings } from "../../core/types.js";
2
+ import type { Logger } from "../../core/logger.js";
3
+ import type { ProgressCallbacks } from "../../asset/deployer.js";
4
+ import { type MobileRootDir } from "../../asset/root-selection.js";
5
+ import type { MobileMeta } from "../../asset/mobile-meta.js";
6
+ import { type RunExternalCommand } from "../../utils/external-command.js";
7
+ import { type generateMcpConfigs } from "../../utils/mcp-generate.js";
8
+ import { type runEnsure, type syncDependencyArtifacts } from "../../utils/runtime-ensure.js";
9
+ import type { MobilePrompts } from "../../interactive/mobile-prompts.js";
10
+ export type MobileRunInput = {
11
+ locale: string;
12
+ logger: Logger;
13
+ nonInteractive: boolean;
14
+ introShown: boolean;
15
+ name?: string;
16
+ accelplatformVersion?: string;
17
+ expoSdk?: string;
18
+ agents?: string[];
19
+ packageManager?: string;
20
+ expoSkills?: boolean;
21
+ skipInstall: boolean;
22
+ assetServerUrl?: string;
23
+ assetRef?: string;
24
+ assetSource?: string;
25
+ progress: ProgressCallbacks;
26
+ signal?: AbortSignal;
27
+ runExternalCommand: RunExternalCommand;
28
+ prompts: MobilePrompts;
29
+ generateMcpConfigs?: typeof generateMcpConfigs;
30
+ syncDependencyArtifacts?: typeof syncDependencyArtifacts;
31
+ runEnsure?: typeof runEnsure;
32
+ };
33
+ export type MobileMode = "init" | "attach";
34
+ export declare const validateMobileCliValues: (input: Pick<MobileRunInput, "locale" | "name" | "accelplatformVersion" | "packageManager" | "expoSdk" | "agents">, mode: MobileMode | "update") => void;
35
+ export declare const assertMobileAgents: (agents: readonly string[], locale: string) => void;
36
+ export declare const printMobileIntro: (input: MobileRunInput, mode: MobileMode) => void;
37
+ export declare const resolveNameAndTarget: (input: MobileRunInput, mode: MobileMode, defaultName: string, afterName?: (name: string) => Promise<void>) => Promise<{
38
+ name: string;
39
+ targetReleaseId: string;
40
+ }>;
41
+ export declare const openMobileProvider: (input: Pick<MobileRunInput, "assetSource" | "assetServerUrl" | "assetRef" | "locale" | "signal"> & {
42
+ progress?: Pick<ProgressCallbacks, "onFetchStart">;
43
+ }) => Promise<AssetProvider>;
44
+ export declare const listSdkCandidates: (provider: AssetProvider, targetReleaseId: string, locale: string) => Promise<MobileRootDir[]>;
45
+ export declare const resolveExpoSdk: (input: MobileRunInput, candidates: readonly MobileRootDir[], preferred?: string) => Promise<MobileRootDir>;
46
+ export declare const resolveAgents: (input: MobileRunInput) => Promise<string[]>;
47
+ export type ExpoSkillsPlan = {
48
+ expoSkills: NonNullable<MobileMeta["expoSkills"]>;
49
+ agents: string[];
50
+ install: boolean;
51
+ };
52
+ export declare const resolveExpoSkills: (input: MobileRunInput, mobile: MobileMeta, agents: readonly string[], packageManager: string, projectDir: string) => Promise<ExpoSkillsPlan | undefined>;
53
+ export declare const formatSkillsCommandLine: (plan: ExpoSkillsPlan, projectDir: string, packageManager: string) => string;
54
+ export declare const confirmOrCancel: (input: MobileRunInput, mode: MobileMode) => Promise<void>;
55
+ export declare const buildMobileSettings: (opts: {
56
+ name: string;
57
+ targetReleaseId: string;
58
+ expoSdk: string;
59
+ agents: string[];
60
+ locale: string;
61
+ packageManager: string;
62
+ }) => MobileProjectSettings;
63
+ export declare const withSpinner: <T>(input: Pick<MobileRunInput, "logger">, message: string, run: () => Promise<T>) => Promise<T>;
64
+ export declare const expoSkillsHintForAddedAgents: (previousAgents: readonly string[], nextAgents: readonly string[], mobile: MobileMeta, locale: string) => string | undefined;
65
+ export declare const finishMobile: (input: MobileRunInput, mode: MobileMode, projectDir: string, settings: MobileProjectSettings, plan: ExpoSkillsPlan | undefined) => Promise<void>;
@@ -0,0 +1,254 @@
1
+ import { createCancelledError } from "../../core/errors.js";
2
+ import { createMobileValidators, createValidators, } from "../../core/validators.js";
3
+ import { validateNonInteractive } from "../../core/validation.js";
4
+ import { DEFAULT_SETTINGS, MOBILE_AGENT_OPTIONS, } from "../../core/constants.js";
5
+ import { findReleaseById, resolveAccelplatformVersion, } from "../../core/catalog.js";
6
+ import { emptyEvalContext } from "../../core/eval-context.js";
7
+ import { getCliVersion } from "../../core/paths.js";
8
+ import { getMessage } from "../../i18n/index.js";
9
+ import { withFetchOnce } from "../../asset/fetch-once.js";
10
+ import { formatSdkNotAvailable, hasMobileRootDirs, listMobileRootDirs, } from "../../asset/root-selection.js";
11
+ import { sanitizeDisplayText } from "../../utils/sanitize-text.js";
12
+ import { selectAssetProvider } from "../asset-provider.js";
13
+ import { buildSkillsAddRequest, expoSkillsAgentsFor, formatCommandLine, formatManualSkillsCommand, formatOutputTail, } from "../../utils/external-command.js";
14
+ import { generateMcpConfigsBestEffort, } from "../../utils/mcp-generate.js";
15
+ import { syncDependencyArtifactsAndEnsureBestEffort, } from "../../utils/runtime-ensure.js";
16
+ import { detectDefaultAgents } from "../../interactive/agent-detect.js";
17
+ import { printIntro, printIntroNote, } from "../../interactive/prompts.js";
18
+ import { printNextSteps } from "../../interactive/next-steps.js";
19
+ export const validateMobileCliValues = (input, mode) => {
20
+ const v = createValidators(input.locale);
21
+ const m = createMobileValidators(input.locale);
22
+ const checks = [
23
+ [mode === "init" ? m.mobileName : v.name, input.name],
24
+ [v.accelplatformVersion, input.accelplatformVersion],
25
+ [v.packageManager, input.packageManager],
26
+ [m.expoSdk, input.expoSdk],
27
+ ...(input.agents ?? []).map((a) => [m.agent, a]),
28
+ ];
29
+ const errors = checks
30
+ .filter(([, value]) => value !== undefined)
31
+ .map(([validate, value]) => validate(value))
32
+ .filter((e) => e !== undefined);
33
+ if (errors.length > 0)
34
+ throw new Error(errors.join("\n"));
35
+ };
36
+ export const assertMobileAgents = (agents, locale) => {
37
+ const validate = createMobileValidators(locale).agent;
38
+ const errors = agents
39
+ .map((a) => validate(a))
40
+ .filter((e) => e !== undefined);
41
+ if (errors.length > 0)
42
+ throw new Error(errors.join("\n"));
43
+ };
44
+ export const printMobileIntro = (input, mode) => {
45
+ if (input.nonInteractive)
46
+ return;
47
+ const introMode = mode === "init" ? "mobile" : "mobileAttach";
48
+ if (input.introShown)
49
+ printIntroNote(introMode, input.locale, input.logger);
50
+ else
51
+ printIntro(introMode, input.locale, input.logger);
52
+ };
53
+ export const resolveNameAndTarget = async (input, mode, defaultName, afterName) => {
54
+ if (input.nonInteractive) {
55
+ const errors = validateNonInteractive({
56
+ name: mode === "init" ? input.name : (input.name ?? defaultName),
57
+ accelplatformVersion: input.accelplatformVersion,
58
+ locale: input.locale,
59
+ isInit: mode === "init",
60
+ noInteraction: true,
61
+ });
62
+ if (errors.length > 0)
63
+ throw new Error(errors.join("\n"));
64
+ const name = input.name ?? defaultName;
65
+ await afterName?.(name);
66
+ return { name, targetReleaseId: input.accelplatformVersion };
67
+ }
68
+ const validate = mode === "init"
69
+ ? createMobileValidators(input.locale).mobileName
70
+ : createValidators(input.locale).name;
71
+ const name = await input.prompts.name(input.name ?? defaultName, input.locale, validate);
72
+ await afterName?.(name);
73
+ const targetReleaseId = await input.prompts.targetAccelplatformVersion(input.accelplatformVersion ?? DEFAULT_SETTINGS.accelplatformVersion.label, input.locale);
74
+ return { name, targetReleaseId };
75
+ };
76
+ export const openMobileProvider = async (input) => {
77
+ const provider = withFetchOnce(await selectAssetProvider({
78
+ assetSource: input.assetSource,
79
+ assetServerUrl: input.assetServerUrl,
80
+ assetRef: input.assetRef,
81
+ }, input.locale, input.signal));
82
+ try {
83
+ input.progress?.onFetchStart?.();
84
+ await provider.fetch();
85
+ if (!(await hasMobileRootDirs(provider))) {
86
+ throw new Error(getMessage("error.mobileAssetsNotFound", input.locale));
87
+ }
88
+ return provider;
89
+ }
90
+ catch (err) {
91
+ await provider.cleanup().catch(() => { });
92
+ throw err;
93
+ }
94
+ };
95
+ export const listSdkCandidates = async (provider, targetReleaseId, locale) => {
96
+ if (!findReleaseById(targetReleaseId)) {
97
+ throw new Error(getMessage("error.invalidVersion", locale, {
98
+ version: sanitizeDisplayText(String(targetReleaseId)),
99
+ }));
100
+ }
101
+ const target = resolveAccelplatformVersion(targetReleaseId);
102
+ const candidates = await listMobileRootDirs(provider, emptyEvalContext({
103
+ projectType: "mobile",
104
+ accelplatformVersion: target,
105
+ locale,
106
+ }));
107
+ if (candidates.length === 0) {
108
+ throw new Error(getMessage("error.mobileAssetsNotForTarget", locale, {
109
+ version: target.label,
110
+ }));
111
+ }
112
+ return candidates;
113
+ };
114
+ export const resolveExpoSdk = async (input, candidates, preferred) => {
115
+ const find = (sdk) => candidates.find((c) => c.mobile.expoSdk === sdk);
116
+ const notAvailable = (sdk) => new Error(formatSdkNotAvailable(sdk, candidates, input.locale));
117
+ if (input.expoSdk !== undefined) {
118
+ const selected = find(input.expoSdk);
119
+ if (!selected)
120
+ throw notAvailable(input.expoSdk);
121
+ return selected;
122
+ }
123
+ const preferredDir = preferred === undefined ? undefined : find(preferred);
124
+ if (preferred !== undefined && !preferredDir) {
125
+ if (input.nonInteractive)
126
+ throw notAvailable(preferred);
127
+ input.logger.warn(getMessage("warning.expoSdkNotAvailable", input.locale, {
128
+ sdk: sanitizeDisplayText(preferred),
129
+ }));
130
+ }
131
+ const fallback = preferred === undefined ? candidates[0] : preferredDir;
132
+ if (input.nonInteractive)
133
+ return preferredDir ?? candidates[0];
134
+ const sdk = await input.prompts.expoSdk(candidates.map((c) => c.mobile.expoSdk), fallback?.mobile.expoSdk, input.locale);
135
+ const selected = find(sdk);
136
+ if (!selected)
137
+ throw notAvailable(sdk);
138
+ return selected;
139
+ };
140
+ export const resolveAgents = async (input) => {
141
+ if (input.nonInteractive) {
142
+ return input.agents ?? detectDefaultAgents(MOBILE_AGENT_OPTIONS);
143
+ }
144
+ const agents = await input.prompts.agents(input.agents, input.locale);
145
+ assertMobileAgents(agents, input.locale);
146
+ return agents;
147
+ };
148
+ export const resolveExpoSkills = async (input, mobile, agents, packageManager, projectDir) => {
149
+ const targets = expoSkillsAgentsFor(agents);
150
+ if (!mobile.expoSkills || targets.length === 0)
151
+ return undefined;
152
+ const plan = { expoSkills: mobile.expoSkills, agents: targets, install: true };
153
+ let install = input.expoSkills;
154
+ if (install === undefined) {
155
+ if (input.nonInteractive) {
156
+ throw new Error(getMessage("error.expoSkillsFlagRequired", input.locale));
157
+ }
158
+ install = await input.prompts.expoSkills({
159
+ source: mobile.expoSkills.source,
160
+ command: formatCommandLine(skillsRequest(plan, projectDir, packageManager)),
161
+ }, input.locale);
162
+ }
163
+ return { ...plan, install };
164
+ };
165
+ const skillsRequest = (plan, projectDir, packageManager, signal) => buildSkillsAddRequest({
166
+ expoSkills: plan.expoSkills,
167
+ agents: plan.agents,
168
+ projectDir,
169
+ packageManager,
170
+ signal,
171
+ });
172
+ export const formatSkillsCommandLine = (plan, projectDir, packageManager) => formatCommandLine(skillsRequest(plan, projectDir, packageManager));
173
+ export const confirmOrCancel = async (input, mode) => {
174
+ if (input.nonInteractive)
175
+ return;
176
+ if (!(await input.prompts.confirm(mode, input.locale))) {
177
+ input.logger.info(getMessage("mobile.cancelled", input.locale));
178
+ throw createCancelledError();
179
+ }
180
+ };
181
+ export const buildMobileSettings = (opts) => ({
182
+ projectType: "mobile",
183
+ cliVersion: getCliVersion(),
184
+ createdAt: new Date().toISOString(),
185
+ name: opts.name,
186
+ targetAccelplatformVersion: resolveAccelplatformVersion(opts.targetReleaseId),
187
+ expoSdk: opts.expoSdk,
188
+ agents: opts.agents,
189
+ locale: opts.locale,
190
+ packageManager: opts.packageManager,
191
+ deployedAssets: {},
192
+ });
193
+ export const withSpinner = async (input, message, run) => {
194
+ const spin = input.logger.spinner();
195
+ spin.start(message);
196
+ try {
197
+ return await run();
198
+ }
199
+ finally {
200
+ spin.stop(message);
201
+ }
202
+ };
203
+ export const expoSkillsHintForAddedAgents = (previousAgents, nextAgents, mobile, locale) => {
204
+ const added = expoSkillsAgentsFor(nextAgents).filter((a) => !previousAgents.includes(a));
205
+ if (!mobile.expoSkills || added.length === 0)
206
+ return undefined;
207
+ return getMessage("mobile.expoSkills.hint", locale, {
208
+ command: formatManualSkillsCommand(mobile.expoSkills, added),
209
+ });
210
+ };
211
+ const installExpoSkills = async (input, plan, projectDir, packageManager) => {
212
+ const manual = formatManualSkillsCommand(plan.expoSkills, plan.agents);
213
+ const result = await withSpinner(input, getMessage("progress.expoSkills", input.locale), () => input.runExternalCommand(skillsRequest(plan, projectDir, packageManager, input.signal)));
214
+ if (!result.launched) {
215
+ input.logger.warn(getMessage("warning.expoSkillsNotRun", input.locale, {
216
+ missing: result.missing,
217
+ command: manual,
218
+ }));
219
+ return manual;
220
+ }
221
+ if (result.exitCode !== 0) {
222
+ input.logger.warn(getMessage("warning.expoSkillsFailed", input.locale, {
223
+ command: manual,
224
+ output: formatOutputTail(result.outputTail),
225
+ }));
226
+ return manual;
227
+ }
228
+ return undefined;
229
+ };
230
+ export const finishMobile = async (input, mode, projectDir, settings, plan) => {
231
+ const { logger, locale } = input;
232
+ let expoSkillsCommand;
233
+ if (plan?.install) {
234
+ expoSkillsCommand = await installExpoSkills(input, plan, projectDir, settings.packageManager);
235
+ }
236
+ else if (plan) {
237
+ expoSkillsCommand = formatManualSkillsCommand(plan.expoSkills, plan.agents);
238
+ }
239
+ const { hasDeps } = await syncDependencyArtifactsAndEnsureBestEffort(projectDir, logger, {
240
+ skipInstall: input.skipInstall,
241
+ syncImpl: input.syncDependencyArtifacts,
242
+ runImpl: input.runEnsure,
243
+ });
244
+ await generateMcpConfigsBestEffort(projectDir, logger, input.generateMcpConfigs);
245
+ logger.success(getMessage("progress.complete", locale));
246
+ printNextSteps({
247
+ projectDir,
248
+ agents: settings.agents,
249
+ isInit: mode === "init",
250
+ locale,
251
+ codexHookApproval: hasDeps && settings.agents.includes("codex"),
252
+ mobile: { packageManager: settings.packageManager, expoSkillsCommand },
253
+ }, logger);
254
+ };
@@ -0,0 +1,8 @@
1
+ import type { AssetProvider, MobileProjectSettings } from "../../core/types.js";
2
+ import type { UpdateContext, UpdatePrompts } from "../update.js";
3
+ export declare const validateMobileUpdateInputs: (ctx: UpdateContext) => Promise<string[] | undefined>;
4
+ export declare const resolveMobileUpdate: (ctx: UpdateContext, settings: MobileProjectSettings, provider: AssetProvider, presetAgents: string[] | undefined) => Promise<{
5
+ newSettings: MobileProjectSettings;
6
+ afterApply?: () => void;
7
+ }>;
8
+ export declare const defaultReenterMobileSettings: UpdatePrompts["reenterMobileSettings"];
@@ -0,0 +1,109 @@
1
+ import { createCancelledError } from "../../core/errors.js";
2
+ import { getCliVersion } from "../../core/paths.js";
3
+ import { resolveAccelplatformVersion } from "../../core/catalog.js";
4
+ import { createValidators } from "../../core/validators.js";
5
+ import { getMessage } from "../../i18n/index.js";
6
+ import { listPresetSummaries, loadAndValidateMobilePreset, } from "../../utils/preset-io.js";
7
+ import { detectProjectExpoSdk } from "../../utils/expo-project.js";
8
+ import { sanitizeDisplayText } from "../../utils/sanitize-text.js";
9
+ import { formatSdkNotAvailable } from "../../asset/root-selection.js";
10
+ import { printIntro } from "../../interactive/prompts.js";
11
+ import { printMobileSummary } from "../../interactive/summary.js";
12
+ import { defaultMobilePrompts } from "../../interactive/mobile-prompts.js";
13
+ import { assertMobileAgents, expoSkillsHintForAddedAgents, listSdkCandidates, validateMobileCliValues, } from "./shared.js";
14
+ export const validateMobileUpdateInputs = async (ctx) => {
15
+ const { deps, projectDir, locale } = ctx;
16
+ validateMobileCliValues({
17
+ locale,
18
+ name: deps.name,
19
+ accelplatformVersion: deps.accelplatformVersion,
20
+ packageManager: deps.packageManager,
21
+ expoSdk: deps.expoSdk,
22
+ agents: deps.agents,
23
+ }, "update");
24
+ return deps.preset !== undefined
25
+ ? (await loadAndValidateMobilePreset(projectDir, deps.preset, locale)).agents
26
+ : undefined;
27
+ };
28
+ export const resolveMobileUpdate = async (ctx, settings, provider, presetAgents) => {
29
+ const { deps, projectDir, locale, logger, prompts, isInteractive } = ctx;
30
+ if (isInteractive)
31
+ printIntro("update", locale, logger);
32
+ logger.info(getMessage("progress.fetching", locale));
33
+ await provider.fetch();
34
+ let values = {
35
+ name: deps.name ?? settings.name,
36
+ targetReleaseId: deps.accelplatformVersion ?? settings.targetAccelplatformVersion.label,
37
+ expoSdk: deps.expoSdk ?? settings.expoSdk,
38
+ agents: presetAgents ?? deps.agents ?? settings.agents,
39
+ };
40
+ if (deps.expoSdk === undefined) {
41
+ const detected = await detectProjectExpoSdk(projectDir);
42
+ const candidates = detected !== undefined && detected !== settings.expoSdk
43
+ ? await listSdkCandidates(provider, values.targetReleaseId, locale).catch(() => undefined)
44
+ : undefined;
45
+ if (detected !== undefined && candidates !== undefined) {
46
+ const available = candidates.some((c) => c.mobile.expoSdk === detected);
47
+ const params = {
48
+ detected,
49
+ recorded: sanitizeDisplayText(String(settings.expoSdk)),
50
+ };
51
+ if (!available) {
52
+ logger.warn(getMessage("update.warning.expoSdkNoAssets", locale, params));
53
+ }
54
+ else if (isInteractive) {
55
+ if (await prompts.confirmFollowExpoSdk(detected, params.recorded, locale)) {
56
+ values.expoSdk = detected;
57
+ }
58
+ }
59
+ else {
60
+ logger.warn(getMessage("update.warning.expoSdkMismatch", locale, params));
61
+ }
62
+ }
63
+ }
64
+ if (isInteractive && deps.preset === undefined) {
65
+ const choice = await prompts.selectSettingsSource(await listPresetSummaries(projectDir), locale);
66
+ if (choice.kind === "preset") {
67
+ values.agents = (await loadAndValidateMobilePreset(projectDir, choice.name, locale)).agents;
68
+ }
69
+ else if (choice.kind === "reenter") {
70
+ values = await prompts.reenterMobileSettings(values, async (releaseId) => (await listSdkCandidates(provider, releaseId, locale)).map((c) => c.mobile.expoSdk), locale);
71
+ assertMobileAgents(values.agents, locale);
72
+ }
73
+ }
74
+ const candidates = await listSdkCandidates(provider, values.targetReleaseId, locale);
75
+ const selected = candidates.find((c) => c.mobile.expoSdk === values.expoSdk);
76
+ if (!selected) {
77
+ throw new Error(`${formatSdkNotAvailable(values.expoSdk, candidates, locale)}\n${getMessage("update.hint.expoSdk", locale)}`);
78
+ }
79
+ const newSettings = {
80
+ ...settings,
81
+ cliVersion: getCliVersion(),
82
+ name: values.name,
83
+ targetAccelplatformVersion: resolveAccelplatformVersion(values.targetReleaseId),
84
+ expoSdk: values.expoSdk,
85
+ agents: values.agents,
86
+ locale,
87
+ packageManager: deps.packageManager ?? settings.packageManager,
88
+ };
89
+ if (isInteractive) {
90
+ printMobileSummary(newSettings, projectDir, [], locale, logger);
91
+ if (!(await prompts.confirmApply(locale))) {
92
+ logger.info(getMessage("update.cancelled", locale));
93
+ throw createCancelledError();
94
+ }
95
+ }
96
+ const hint = expoSkillsHintForAddedAgents(settings.agents, newSettings.agents, selected.mobile, locale);
97
+ return {
98
+ newSettings,
99
+ afterApply: hint === undefined ? undefined : () => logger.info(hint),
100
+ };
101
+ };
102
+ export const defaultReenterMobileSettings = async (current, sdkCandidates, locale) => {
103
+ const name = await defaultMobilePrompts.name(current.name, locale, createValidators(locale).name);
104
+ const targetReleaseId = await defaultMobilePrompts.targetAccelplatformVersion(current.targetReleaseId, locale);
105
+ const candidates = await sdkCandidates(targetReleaseId);
106
+ const expoSdk = await defaultMobilePrompts.expoSdk(candidates, candidates.includes(current.expoSdk) ? current.expoSdk : candidates[0], locale);
107
+ const agents = await defaultMobilePrompts.agents(current.agents, locale);
108
+ return { name, targetReleaseId, expoSdk, agents };
109
+ };
@@ -0,0 +1,10 @@
1
+ import type { MobileMeta } from "../asset/mobile-meta.js";
2
+ export type ListMobileSdkOptionsInput = {
3
+ assetServerUrl?: string;
4
+ assetRef?: string;
5
+ assetSource?: string;
6
+ targetAccelplatformVersion: string;
7
+ locale?: string;
8
+ signal?: AbortSignal;
9
+ };
10
+ export declare const listMobileSdkOptions: (input: ListMobileSdkOptionsInput) => Promise<MobileMeta[]>;
@@ -0,0 +1,19 @@
1
+ import { normalizeAbort } from "../core/errors.js";
2
+ import { detectLocale } from "../utils/locale-detect.js";
3
+ import { listSdkCandidates, openMobileProvider } from "./mobile/shared.js";
4
+ export const listMobileSdkOptions = async (input) => {
5
+ const locale = input.locale ?? detectLocale();
6
+ try {
7
+ const provider = await openMobileProvider({ ...input, locale });
8
+ try {
9
+ const candidates = await listSdkCandidates(provider, input.targetAccelplatformVersion, locale);
10
+ return candidates.map((c) => c.mobile);
11
+ }
12
+ finally {
13
+ await provider.cleanup().catch(() => { });
14
+ }
15
+ }
16
+ catch (err) {
17
+ throw normalizeAbort(err, input.signal);
18
+ }
19
+ };
@@ -25,7 +25,7 @@ export type PresetCreatePrompts = {
25
25
  export declare const runPresetCreateInteractive: (ctx: {
26
26
  projectDir: string;
27
27
  locale: string;
28
- }, release: Release, cli: PresetCreateCliValues, force?: boolean, prompts?: PresetCreatePrompts) => Promise<void>;
28
+ }, release: Release | null, cli: PresetCreateCliValues, force?: boolean, prompts?: PresetCreatePrompts) => Promise<void>;
29
29
  export declare const buildPresetListBody: (summaries: PresetSummary[]) => string;
30
30
  export declare const buildPresetShowBody: (raw: Record<string, unknown>, locale: string) => string;
31
31
  export declare const presetCommand: import("citty").CommandDef<import("citty").ArgsDef>;