@intra-mart/accel 1.0.0-rc.202609290758 → 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.
- package/README.md +93 -6
- package/dist/asset/deployer.js +1 -2
- package/dist/asset/fetch-once.d.ts +2 -0
- package/dist/asset/fetch-once.js +14 -0
- package/dist/asset/mobile-meta.d.ts +15 -0
- package/dist/asset/mobile-meta.js +86 -0
- package/dist/asset/root-selection.d.ts +12 -0
- package/dist/asset/root-selection.js +78 -0
- package/dist/asset/updater.js +1 -1
- package/dist/asset/walker.d.ts +1 -1
- package/dist/asset/walker.js +3 -26
- package/dist/commands/attach-existing-files.d.ts +12 -0
- package/dist/commands/attach-existing-files.js +76 -0
- package/dist/commands/attach.d.ts +20 -0
- package/dist/commands/attach.js +77 -77
- package/dist/commands/deploy.js +16 -13
- package/dist/commands/detach.js +7 -3
- package/dist/commands/init.d.ts +20 -0
- package/dist/commands/init.js +71 -4
- package/dist/commands/login.js +12 -6
- package/dist/commands/mobile/attach.d.ts +7 -0
- package/dist/commands/mobile/attach.js +60 -0
- package/dist/commands/mobile/init.d.ts +4 -0
- package/dist/commands/mobile/init.js +95 -0
- package/dist/commands/mobile/shared.d.ts +65 -0
- package/dist/commands/mobile/shared.js +254 -0
- package/dist/commands/mobile/update.d.ts +8 -0
- package/dist/commands/mobile/update.js +109 -0
- package/dist/commands/mobile-sdk-options.d.ts +10 -0
- package/dist/commands/mobile-sdk-options.js +19 -0
- package/dist/commands/preset.d.ts +1 -1
- package/dist/commands/preset.js +35 -13
- package/dist/commands/project-type-select.d.ts +17 -0
- package/dist/commands/project-type-select.js +26 -0
- package/dist/commands/switch.d.ts +1 -1
- package/dist/commands/switch.js +118 -48
- package/dist/commands/update.d.ts +22 -0
- package/dist/commands/update.js +179 -106
- package/dist/core/condition-evaluator.js +4 -1
- package/dist/core/constants.d.ts +12 -2
- package/dist/core/constants.js +16 -0
- package/dist/core/eval-context.js +27 -0
- package/dist/core/project-type.d.ts +20 -0
- package/dist/core/project-type.js +49 -0
- package/dist/core/types.d.ts +28 -9
- package/dist/core/types.js +2 -0
- package/dist/core/validation.d.ts +2 -2
- package/dist/core/validators.d.ts +7 -0
- package/dist/core/validators.js +38 -1
- package/dist/core/variable-interpolator.js +2 -0
- package/dist/i18n/en.js +59 -0
- package/dist/i18n/ja.js +59 -0
- package/dist/i18n/zh_CN.js +59 -0
- package/dist/interactive/agent-detect.d.ts +1 -1
- package/dist/interactive/agent-detect.js +6 -6
- package/dist/interactive/mobile-prompts.d.ts +15 -0
- package/dist/interactive/mobile-prompts.js +45 -0
- package/dist/interactive/next-steps.d.ts +4 -0
- package/dist/interactive/next-steps.js +11 -0
- package/dist/interactive/prompts.d.ts +5 -2
- package/dist/interactive/prompts.js +23 -19
- package/dist/interactive/summary.d.ts +5 -3
- package/dist/interactive/summary.js +38 -0
- package/dist/lib.d.ts +11 -5
- package/dist/lib.js +6 -3
- package/dist/utils/args.d.ts +1 -0
- package/dist/utils/args.js +16 -0
- package/dist/utils/expo-project.d.ts +8 -0
- package/dist/utils/expo-project.js +54 -0
- package/dist/utils/external-command.d.ts +68 -0
- package/dist/utils/external-command.js +238 -0
- package/dist/utils/preset-io.d.ts +1 -0
- package/dist/utils/preset-io.js +18 -1
- package/dist/utils/settings-io.d.ts +1 -0
- package/dist/utils/settings-io.js +12 -0
- package/package.json +1 -1
package/dist/commands/update.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { defineCommand } from "citty";
|
|
2
2
|
import * as p from "@clack/prompts";
|
|
3
|
+
import { isMobileSettings } from "../core/types.js";
|
|
3
4
|
import { getCliVersion } from "../core/paths.js";
|
|
4
5
|
import { runPrompts, printIntro } from "../interactive/prompts.js";
|
|
5
6
|
import { collectSettingsErrors, } from "../core/validation.js";
|
|
@@ -8,13 +9,15 @@ import { createCancelledError, markReported, normalizeAbort, } from "../core/err
|
|
|
8
9
|
import { createClackLogger } from "../interactive/clack-logger.js";
|
|
9
10
|
import { withExitCode } from "./run-wrapper.js";
|
|
10
11
|
import { createGitAssetProvider } from "../asset/git-provider.js";
|
|
12
|
+
import { withFetchOnce } from "../asset/fetch-once.js";
|
|
13
|
+
import { collectOptionsNotForProjectType, formatOptionsNotForProjectType, projectTypeOptionValues, } from "../core/project-type.js";
|
|
11
14
|
import { isWorktreeDirty } from "../git/worktree-status.js";
|
|
12
15
|
import { buildRenderedPlan, dependencyDirsOfPlan, collectFileStates, classifyAll, applyUpdateActions, buildUpdatedRecords, } from "../asset/updater.js";
|
|
13
16
|
import { createMessageCollector } from "../asset/messages.js";
|
|
14
17
|
import { printAssetMessages } from "../interactive/asset-messages.js";
|
|
15
18
|
import { mergeFile } from "../utils/merge-file.js";
|
|
16
19
|
import { getInstallCmds, runInstallBuild } from "../asset/installer.js";
|
|
17
|
-
import {
|
|
20
|
+
import { readProjectSettings, readHashsum, writeSettings, writeHashsum, } from "../utils/settings-io.js";
|
|
18
21
|
import { loadAndValidatePreset, listPresetSummaries, buildPresetSelectOptions, parsePresetChoice, } from "../utils/preset-io.js";
|
|
19
22
|
import { getMessage } from "../i18n/index.js";
|
|
20
23
|
import { detectLocale } from "../utils/locale-detect.js";
|
|
@@ -94,6 +97,19 @@ const defaultPrompts = {
|
|
|
94
97
|
return !p.isCancel(ok) && ok === true;
|
|
95
98
|
},
|
|
96
99
|
reenterSettings: runPrompts,
|
|
100
|
+
confirmFollowExpoSdk: async (detected, recorded, locale) => {
|
|
101
|
+
const ok = await p.confirm({
|
|
102
|
+
message: getMessage("update.prompt.followExpoSdk", locale, {
|
|
103
|
+
detected,
|
|
104
|
+
recorded,
|
|
105
|
+
}),
|
|
106
|
+
initialValue: true,
|
|
107
|
+
});
|
|
108
|
+
if (p.isCancel(ok))
|
|
109
|
+
throw createCancelledError();
|
|
110
|
+
return ok === true;
|
|
111
|
+
},
|
|
112
|
+
reenterMobileSettings: async (current, sdkCandidates, locale) => (await import("./mobile/update.js")).defaultReenterMobileSettings(current, sdkCandidates, locale),
|
|
97
113
|
};
|
|
98
114
|
const resolveFallbackMode = async (opts) => {
|
|
99
115
|
const { baseError, editedCount, commit, locale, prompts, logger } = opts;
|
|
@@ -238,7 +254,7 @@ const runUpdateInner = async (deps) => {
|
|
|
238
254
|
const logger = deps.logger ?? createClackLogger();
|
|
239
255
|
const prompts = deps.prompts ?? defaultPrompts;
|
|
240
256
|
let locale = deps.locale ?? detectLocale();
|
|
241
|
-
const settings = await
|
|
257
|
+
const settings = await readProjectSettings(projectDir, locale);
|
|
242
258
|
if (!settings) {
|
|
243
259
|
throw new Error(getMessage("error.accelNotFound", locale));
|
|
244
260
|
}
|
|
@@ -248,13 +264,17 @@ const runUpdateInner = async (deps) => {
|
|
|
248
264
|
if (keepEditedFlag && !allowMissingBase) {
|
|
249
265
|
throw new Error(getMessage("update.error.keepEditedWithoutAllow", locale));
|
|
250
266
|
}
|
|
251
|
-
|
|
252
|
-
if (presetArg !== undefined &&
|
|
267
|
+
if (deps.preset !== undefined &&
|
|
253
268
|
(deps.modules !== undefined ||
|
|
254
269
|
deps.features !== undefined ||
|
|
255
270
|
deps.agents !== undefined)) {
|
|
256
271
|
throw new Error(getMessage("preset.error.conflictingFlags", locale));
|
|
257
272
|
}
|
|
273
|
+
const projectType = isMobileSettings(settings) ? "mobile" : "iap";
|
|
274
|
+
const notFor = collectOptionsNotForProjectType(projectTypeOptionValues(deps), projectType);
|
|
275
|
+
if (notFor.length > 0) {
|
|
276
|
+
throw new Error(formatOptionsNotForProjectType(notFor, projectType, locale));
|
|
277
|
+
}
|
|
258
278
|
const assetSource = settings.assetSource;
|
|
259
279
|
if (!assetSource) {
|
|
260
280
|
throw new Error(getMessage("update.error.legacyProject", locale));
|
|
@@ -270,17 +290,64 @@ const runUpdateInner = async (deps) => {
|
|
|
270
290
|
const targetUrl = deps.assetServerUrl ?? source.url;
|
|
271
291
|
const targetRef = deps.assetRef ?? source.ref;
|
|
272
292
|
const isInteractive = !deps.nonInteractive;
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
293
|
+
const ctx = {
|
|
294
|
+
deps,
|
|
295
|
+
projectDir,
|
|
296
|
+
locale,
|
|
297
|
+
logger,
|
|
298
|
+
prompts,
|
|
299
|
+
isInteractive,
|
|
300
|
+
};
|
|
301
|
+
const provider = withFetchOnce(createGitAssetProvider(targetUrl, targetRef, {
|
|
302
|
+
locale,
|
|
303
|
+
signal: deps.signal,
|
|
304
|
+
}));
|
|
305
|
+
try {
|
|
306
|
+
let newSettings;
|
|
307
|
+
let afterApply;
|
|
308
|
+
if (isMobileSettings(settings)) {
|
|
309
|
+
const { resolveMobileUpdate, validateMobileUpdateInputs } = await import("./mobile/update.js");
|
|
310
|
+
const presetAgents = await validateMobileUpdateInputs(ctx);
|
|
311
|
+
await confirmDirtyWorktree(ctx);
|
|
312
|
+
({ newSettings, afterApply } = await resolveMobileUpdate(ctx, settings, provider, presetAgents));
|
|
313
|
+
}
|
|
314
|
+
else {
|
|
315
|
+
newSettings = await resolveIapUpdate(ctx, settings);
|
|
316
|
+
}
|
|
317
|
+
await applyUpdate({
|
|
318
|
+
...ctx,
|
|
319
|
+
settings,
|
|
320
|
+
newSettings,
|
|
321
|
+
provider,
|
|
322
|
+
source,
|
|
323
|
+
targetUrl,
|
|
324
|
+
targetRef,
|
|
325
|
+
allowMissingBase,
|
|
326
|
+
keepEditedFlag,
|
|
327
|
+
});
|
|
328
|
+
afterApply?.();
|
|
276
329
|
}
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
330
|
+
finally {
|
|
331
|
+
await provider.cleanup().catch(() => { });
|
|
332
|
+
}
|
|
333
|
+
};
|
|
334
|
+
export const confirmDirtyWorktree = async (ctx) => {
|
|
335
|
+
if (await isWorktreeDirty(ctx.projectDir)) {
|
|
336
|
+
ctx.logger.warn(getMessage("update.warning.dirty", ctx.locale));
|
|
337
|
+
if (ctx.isInteractive && !(await ctx.prompts.confirmDirtyWorktree(ctx.locale))) {
|
|
338
|
+
ctx.logger.info(getMessage("update.cancelled", ctx.locale));
|
|
281
339
|
throw createCancelledError();
|
|
282
340
|
}
|
|
283
341
|
}
|
|
342
|
+
};
|
|
343
|
+
const resolveIapUpdate = async (ctx, settings) => {
|
|
344
|
+
const { deps, projectDir, locale, logger, prompts, isInteractive } = ctx;
|
|
345
|
+
const presetArg = deps.preset;
|
|
346
|
+
let presetValues;
|
|
347
|
+
if (presetArg !== undefined) {
|
|
348
|
+
presetValues = await loadAndValidatePreset(projectDir, presetArg, deps.accelplatformVersion ?? settings.accelplatformVersion.label, locale);
|
|
349
|
+
}
|
|
350
|
+
await confirmDirtyWorktree(ctx);
|
|
284
351
|
const cliOnlyOpts = {
|
|
285
352
|
name: deps.name,
|
|
286
353
|
artifactId: deps.artifactId,
|
|
@@ -348,104 +415,105 @@ const runUpdateInner = async (deps) => {
|
|
|
348
415
|
throw createCancelledError();
|
|
349
416
|
}
|
|
350
417
|
}
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
}
|
|
355
|
-
|
|
418
|
+
return newSettings;
|
|
419
|
+
};
|
|
420
|
+
const applyUpdate = async (a) => {
|
|
421
|
+
const { deps, projectDir, locale, logger, prompts, isInteractive, settings, newSettings, provider, source, targetUrl, targetRef, allowMissingBase, keepEditedFlag, } = a;
|
|
422
|
+
if (!isMobileSettings(settings)) {
|
|
356
423
|
logger.info(getMessage("progress.fetching", locale));
|
|
357
|
-
await provider.fetch();
|
|
358
|
-
const newCommit = provider.sourceInfo().commit;
|
|
359
|
-
if (!newCommit) {
|
|
360
|
-
throw new Error("Failed to resolve the fetched commit");
|
|
361
|
-
}
|
|
362
|
-
logger.info(getMessage("update.progress.range", locale, {
|
|
363
|
-
from: shortSha(source.commit),
|
|
364
|
-
to: shortSha(newCommit),
|
|
365
|
-
}));
|
|
366
|
-
const messageCollector = createMessageCollector();
|
|
367
|
-
const onPathRejected = resolvePathRejected(deps.progress, locale, logger);
|
|
368
|
-
deps.progress?.onRenderStart?.("theirs");
|
|
369
|
-
const theirsPlan = await buildRenderedPlan(provider.asTree(), newSettings, provider.materialize, messageCollector.collect, onPathRejected);
|
|
370
|
-
let baseTree = null;
|
|
371
|
-
let baseError = null;
|
|
372
|
-
try {
|
|
373
|
-
baseTree = await provider.openCommit(source.commit);
|
|
374
|
-
}
|
|
375
|
-
catch (err) {
|
|
376
|
-
baseError = err;
|
|
377
|
-
}
|
|
378
|
-
const oldHashsum = await readHashsum(projectDir);
|
|
379
|
-
const previousDependencyDirs = settings.dependencies ?? [];
|
|
380
|
-
const previousIds = await computeDependencyIds(projectDir, previousDependencyDirs, settings.packageManager);
|
|
381
|
-
let actions;
|
|
382
|
-
if (baseTree) {
|
|
383
|
-
deps.progress?.onRenderStart?.("base");
|
|
384
|
-
const basePlan = await buildRenderedPlan(baseTree, settings, baseTree.materialize, undefined, onPathRejected);
|
|
385
|
-
const states = await collectFileStates(projectDir, basePlan, theirsPlan, oldHashsum);
|
|
386
|
-
deps.progress?.onClassifyStart?.(states.length);
|
|
387
|
-
actions = await classifyAll(states, mergeFile);
|
|
388
|
-
}
|
|
389
|
-
else {
|
|
390
|
-
const states = await collectFileStates(projectDir, new Map(), theirsPlan, oldHashsum);
|
|
391
|
-
deps.progress?.onClassifyStart?.(states.length);
|
|
392
|
-
const preview = await classifyAll(states, mergeFile, {
|
|
393
|
-
keepEdited: true,
|
|
394
|
-
});
|
|
395
|
-
const editedCount = preview.filter((a) => a.outcome === "skipped-edited").length;
|
|
396
|
-
const { keepEdited } = await resolveFallbackMode({
|
|
397
|
-
baseError,
|
|
398
|
-
editedCount,
|
|
399
|
-
commit: source.commit,
|
|
400
|
-
locale,
|
|
401
|
-
isInteractive,
|
|
402
|
-
allowMissingBase,
|
|
403
|
-
keepEditedFlag,
|
|
404
|
-
prompts,
|
|
405
|
-
logger,
|
|
406
|
-
});
|
|
407
|
-
actions = keepEdited
|
|
408
|
-
? preview
|
|
409
|
-
: await classifyAll(states, mergeFile, { keepEdited: false });
|
|
410
|
-
}
|
|
411
|
-
const summary = await applyUpdateActions(projectDir, actions, deps.progress);
|
|
412
|
-
const { hashEntries, deployedAssets } = buildUpdatedRecords(oldHashsum, actions);
|
|
413
|
-
const dependencies = dependencyDirsOfPlan(theirsPlan);
|
|
414
|
-
const updatedSettings = withDependencies({
|
|
415
|
-
...newSettings,
|
|
416
|
-
createdAt: settings.createdAt,
|
|
417
|
-
assetSource: { ...source, url: targetUrl, ref: targetRef, commit: newCommit },
|
|
418
|
-
deployedAssets,
|
|
419
|
-
}, dependencies);
|
|
420
|
-
await writeSettings(projectDir, updatedSettings);
|
|
421
|
-
await writeHashsum(projectDir, hashEntries);
|
|
422
|
-
await generateMcpConfigsBestEffort(projectDir, logger, deps.generateMcpConfigs);
|
|
423
|
-
const { ensureReady } = await syncDependencyArtifactsBestEffort(projectDir, logger, deps.syncDependencyArtifacts);
|
|
424
|
-
printAssetMessages(messageCollector.drain(), logger);
|
|
425
|
-
const skipInstall = deps.skipInstall ?? false;
|
|
426
|
-
const hasConflicts = summary.conflicts.length > 0;
|
|
427
|
-
if (summary.changedFileCount > 0 && !hasConflicts && !skipInstall) {
|
|
428
|
-
runInstallBuild(projectDir, newSettings.packageManager, buildProgressCallbacks(locale, logger));
|
|
429
|
-
}
|
|
430
|
-
if (ensureReady && !skipInstall) {
|
|
431
|
-
await runEnsureBestEffort(projectDir, logger, deps.runEnsure);
|
|
432
|
-
}
|
|
433
|
-
const nextIds = await computeDependencyIds(projectDir, dependencies, newSettings.packageManager);
|
|
434
|
-
const supersededIds = [...previousIds].filter((id) => !nextIds.has(id));
|
|
435
|
-
if (supersededIds.length > 0) {
|
|
436
|
-
await pruneRuntimeIdsBestEffort(projectDir, supersededIds, deps.pruneRuntimeIds);
|
|
437
|
-
}
|
|
438
|
-
let installGuide;
|
|
439
|
-
if (hasConflicts && !skipInstall) {
|
|
440
|
-
const [installCommand, buildCommand] = getInstallCmds(newSettings.packageManager);
|
|
441
|
-
installGuide = { installCommand, buildCommand };
|
|
442
|
-
}
|
|
443
|
-
const dependencyConflict = summary.conflicts.some((path) => isDependencyFile(path, [...previousDependencyDirs, ...dependencies]));
|
|
444
|
-
printResult(summary, locale, logger, installGuide, dependencyConflict ? ensureCommandFor(newSettings.packageManager) : undefined);
|
|
445
424
|
}
|
|
446
|
-
|
|
447
|
-
|
|
425
|
+
await provider.fetch();
|
|
426
|
+
const newCommit = provider.sourceInfo().commit;
|
|
427
|
+
if (!newCommit) {
|
|
428
|
+
throw new Error("Failed to resolve the fetched commit");
|
|
448
429
|
}
|
|
430
|
+
logger.info(getMessage("update.progress.range", locale, {
|
|
431
|
+
from: shortSha(source.commit),
|
|
432
|
+
to: shortSha(newCommit),
|
|
433
|
+
}));
|
|
434
|
+
const messageCollector = createMessageCollector();
|
|
435
|
+
const onPathRejected = resolvePathRejected(deps.progress, locale, logger);
|
|
436
|
+
deps.progress?.onRenderStart?.("theirs");
|
|
437
|
+
const theirsPlan = await buildRenderedPlan(provider.asTree(), newSettings, provider.materialize, messageCollector.collect, onPathRejected);
|
|
438
|
+
let baseTree = null;
|
|
439
|
+
let baseError = null;
|
|
440
|
+
try {
|
|
441
|
+
baseTree = await provider.openCommit(source.commit);
|
|
442
|
+
}
|
|
443
|
+
catch (err) {
|
|
444
|
+
baseError = err;
|
|
445
|
+
}
|
|
446
|
+
const oldHashsum = await readHashsum(projectDir);
|
|
447
|
+
const previousDependencyDirs = settings.dependencies ?? [];
|
|
448
|
+
const previousIds = await computeDependencyIds(projectDir, previousDependencyDirs, settings.packageManager);
|
|
449
|
+
let actions;
|
|
450
|
+
if (baseTree) {
|
|
451
|
+
deps.progress?.onRenderStart?.("base");
|
|
452
|
+
const basePlan = await buildRenderedPlan(baseTree, settings, baseTree.materialize, undefined, onPathRejected);
|
|
453
|
+
const states = await collectFileStates(projectDir, basePlan, theirsPlan, oldHashsum);
|
|
454
|
+
deps.progress?.onClassifyStart?.(states.length);
|
|
455
|
+
actions = await classifyAll(states, mergeFile);
|
|
456
|
+
}
|
|
457
|
+
else {
|
|
458
|
+
const states = await collectFileStates(projectDir, new Map(), theirsPlan, oldHashsum);
|
|
459
|
+
deps.progress?.onClassifyStart?.(states.length);
|
|
460
|
+
const preview = await classifyAll(states, mergeFile, {
|
|
461
|
+
keepEdited: true,
|
|
462
|
+
});
|
|
463
|
+
const editedCount = preview.filter((a) => a.outcome === "skipped-edited").length;
|
|
464
|
+
const { keepEdited } = await resolveFallbackMode({
|
|
465
|
+
baseError,
|
|
466
|
+
editedCount,
|
|
467
|
+
commit: source.commit,
|
|
468
|
+
locale,
|
|
469
|
+
isInteractive,
|
|
470
|
+
allowMissingBase,
|
|
471
|
+
keepEditedFlag,
|
|
472
|
+
prompts,
|
|
473
|
+
logger,
|
|
474
|
+
});
|
|
475
|
+
actions = keepEdited
|
|
476
|
+
? preview
|
|
477
|
+
: await classifyAll(states, mergeFile, { keepEdited: false });
|
|
478
|
+
}
|
|
479
|
+
const summary = await applyUpdateActions(projectDir, actions, deps.progress);
|
|
480
|
+
const { hashEntries, deployedAssets } = buildUpdatedRecords(oldHashsum, actions);
|
|
481
|
+
const dependencies = dependencyDirsOfPlan(theirsPlan);
|
|
482
|
+
const updatedSettings = withDependencies({
|
|
483
|
+
...newSettings,
|
|
484
|
+
createdAt: settings.createdAt,
|
|
485
|
+
assetSource: { ...source, url: targetUrl, ref: targetRef, commit: newCommit },
|
|
486
|
+
deployedAssets,
|
|
487
|
+
}, dependencies);
|
|
488
|
+
await writeSettings(projectDir, updatedSettings);
|
|
489
|
+
await writeHashsum(projectDir, hashEntries);
|
|
490
|
+
await generateMcpConfigsBestEffort(projectDir, logger, deps.generateMcpConfigs);
|
|
491
|
+
const { ensureReady } = await syncDependencyArtifactsBestEffort(projectDir, logger, deps.syncDependencyArtifacts);
|
|
492
|
+
printAssetMessages(messageCollector.drain(), logger);
|
|
493
|
+
const skipInstall = deps.skipInstall ?? false;
|
|
494
|
+
const hasConflicts = summary.conflicts.length > 0;
|
|
495
|
+
const runsInstallBuild = !isMobileSettings(newSettings);
|
|
496
|
+
if (runsInstallBuild &&
|
|
497
|
+
summary.changedFileCount > 0 &&
|
|
498
|
+
!hasConflicts &&
|
|
499
|
+
!skipInstall) {
|
|
500
|
+
runInstallBuild(projectDir, newSettings.packageManager, buildProgressCallbacks(locale, logger));
|
|
501
|
+
}
|
|
502
|
+
if (ensureReady && !skipInstall) {
|
|
503
|
+
await runEnsureBestEffort(projectDir, logger, deps.runEnsure);
|
|
504
|
+
}
|
|
505
|
+
const nextIds = await computeDependencyIds(projectDir, dependencies, newSettings.packageManager);
|
|
506
|
+
const supersededIds = [...previousIds].filter((id) => !nextIds.has(id));
|
|
507
|
+
if (supersededIds.length > 0) {
|
|
508
|
+
await pruneRuntimeIdsBestEffort(projectDir, supersededIds, deps.pruneRuntimeIds);
|
|
509
|
+
}
|
|
510
|
+
let installGuide;
|
|
511
|
+
if (runsInstallBuild && hasConflicts && !skipInstall) {
|
|
512
|
+
const [installCommand, buildCommand] = getInstallCmds(newSettings.packageManager);
|
|
513
|
+
installGuide = { installCommand, buildCommand };
|
|
514
|
+
}
|
|
515
|
+
const dependencyConflict = summary.conflicts.some((path) => isDependencyFile(path, [...previousDependencyDirs, ...dependencies]));
|
|
516
|
+
printResult(summary, locale, logger, installGuide, dependencyConflict ? ensureCommandFor(newSettings.packageManager) : undefined);
|
|
449
517
|
};
|
|
450
518
|
export const updateCommand = defineCommand({
|
|
451
519
|
meta: {
|
|
@@ -509,6 +577,10 @@ export const updateCommand = defineCommand({
|
|
|
509
577
|
type: "string",
|
|
510
578
|
description: "Maven artifactId",
|
|
511
579
|
},
|
|
580
|
+
"expo-sdk": {
|
|
581
|
+
type: "string",
|
|
582
|
+
description: "(mobile) Expo SDK major version to switch the assets to (e.g., 57)",
|
|
583
|
+
},
|
|
512
584
|
"package-manager": {
|
|
513
585
|
type: "string",
|
|
514
586
|
description: "Package manager (bun, npm, yarn, pnpm)",
|
|
@@ -560,6 +632,7 @@ export const updateCommand = defineCommand({
|
|
|
560
632
|
database: args.database,
|
|
561
633
|
javascript: args.javascript,
|
|
562
634
|
packageManager: args["package-manager"],
|
|
635
|
+
expoSdk: args["expo-sdk"],
|
|
563
636
|
preset: args.preset,
|
|
564
637
|
skipInstall: args["skip-install"],
|
|
565
638
|
assetServerUrl: args["asset-server-url"],
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { satisfies } from "semver";
|
|
2
|
-
import { isAndCondition, isOrCondition, isAccelplatformVersionCondition, isModuleCondition, isFeatureCondition, isLocaleCondition, isAgentCondition, isPackageManagerCondition, isJavascriptCondition, } from "./types.js";
|
|
2
|
+
import { isAndCondition, isOrCondition, isAccelplatformVersionCondition, isModuleCondition, isFeatureCondition, isLocaleCondition, isAgentCondition, isPackageManagerCondition, isJavascriptCondition, isProjectTypeCondition, } from "./types.js";
|
|
3
3
|
export const evaluateCondition = (condition, context) => {
|
|
4
4
|
if (condition === undefined) {
|
|
5
5
|
return true;
|
|
@@ -31,5 +31,8 @@ export const evaluateCondition = (condition, context) => {
|
|
|
31
31
|
if (isJavascriptCondition(condition)) {
|
|
32
32
|
return context.javascript === condition.javascript;
|
|
33
33
|
}
|
|
34
|
+
if (isProjectTypeCondition(condition)) {
|
|
35
|
+
return context.projectType === condition.projectType;
|
|
36
|
+
}
|
|
34
37
|
return false;
|
|
35
38
|
};
|
package/dist/core/constants.d.ts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { IapProjectSettings } from "./types.js";
|
|
2
2
|
export declare const DATABASE_OPTIONS: readonly ["postgresql", "oracle", "sqlserver"];
|
|
3
3
|
export type DatabaseOption = (typeof DATABASE_OPTIONS)[number];
|
|
4
4
|
export declare const AGENT_OPTIONS: readonly ["claude-code", "codex", "github-copilot"];
|
|
5
5
|
export type AgentOption = (typeof AGENT_OPTIONS)[number];
|
|
6
|
+
export declare const MOBILE_AGENT_OPTIONS: readonly ["claude-code", "codex"];
|
|
7
|
+
export declare const PROJECT_TYPE_OPTIONS: readonly ["iap", "mobile"];
|
|
8
|
+
export type ProjectTypeOption = (typeof PROJECT_TYPE_OPTIONS)[number];
|
|
6
9
|
export declare const LOCALE_OPTIONS: readonly ["ja", "en", "zh_CN"];
|
|
7
10
|
export type LocaleOption = (typeof LOCALE_OPTIONS)[number];
|
|
8
11
|
export declare const PACKAGE_MANAGER_OPTIONS: readonly ["bun", "npm", "yarn", "pnpm"];
|
|
@@ -15,7 +18,14 @@ export declare const RUNTIME_DIR_REL = ".accel/runtime";
|
|
|
15
18
|
export declare const PACKAGE_JSON_NAME = "package.json";
|
|
16
19
|
export declare const LOCKFILE_BY_PACKAGE_MANAGER: ReadonlyMap<string, string>;
|
|
17
20
|
export declare const lockfileFor: (packageManager: string) => string;
|
|
21
|
+
export type PackageRunner = {
|
|
22
|
+
command: string;
|
|
23
|
+
args: readonly string[];
|
|
24
|
+
userAgent?: string;
|
|
25
|
+
};
|
|
26
|
+
export declare const PACKAGE_RUNNER_BY_PACKAGE_MANAGER: ReadonlyMap<string, PackageRunner>;
|
|
27
|
+
export declare const packageRunnerFor: (packageManager: string) => PackageRunner;
|
|
18
28
|
export declare const DEPENDENCY_FILE_NAMES: ReadonlySet<string>;
|
|
19
29
|
export declare const DEFAULT_ASSET_REPO_URL = "https://github.com/accelplatform/skills";
|
|
20
30
|
export declare const DEFAULT_ASSET_REF = "production-v1";
|
|
21
|
-
export declare const DEFAULT_SETTINGS: Omit<
|
|
31
|
+
export declare const DEFAULT_SETTINGS: Omit<IapProjectSettings, "cliVersion" | "createdAt" | "deployedAssets" | "assetSource" | "projectType">;
|
package/dist/core/constants.js
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
export const DATABASE_OPTIONS = ["postgresql", "oracle", "sqlserver"];
|
|
2
2
|
export const AGENT_OPTIONS = ["claude-code", "codex", "github-copilot"];
|
|
3
|
+
export const MOBILE_AGENT_OPTIONS = [
|
|
4
|
+
"claude-code",
|
|
5
|
+
"codex",
|
|
6
|
+
];
|
|
7
|
+
export const PROJECT_TYPE_OPTIONS = [
|
|
8
|
+
"iap",
|
|
9
|
+
"mobile",
|
|
10
|
+
];
|
|
3
11
|
export const LOCALE_OPTIONS = ["ja", "en", "zh_CN"];
|
|
4
12
|
export const PACKAGE_MANAGER_OPTIONS = [
|
|
5
13
|
"bun",
|
|
@@ -24,6 +32,14 @@ export const LOCKFILE_BY_PACKAGE_MANAGER = new Map([
|
|
|
24
32
|
]);
|
|
25
33
|
export const lockfileFor = (packageManager) => LOCKFILE_BY_PACKAGE_MANAGER.get(packageManager) ??
|
|
26
34
|
LOCKFILE_BY_PACKAGE_MANAGER.get("bun");
|
|
35
|
+
export const PACKAGE_RUNNER_BY_PACKAGE_MANAGER = new Map([
|
|
36
|
+
["bun", { command: "bunx", args: [], userAgent: "bun" }],
|
|
37
|
+
["npm", { command: "npx", args: ["--yes"], userAgent: "npm" }],
|
|
38
|
+
["yarn", { command: "npx", args: ["--yes"], userAgent: "yarn" }],
|
|
39
|
+
["pnpm", { command: "pnpm", args: ["dlx"] }],
|
|
40
|
+
]);
|
|
41
|
+
export const packageRunnerFor = (packageManager) => PACKAGE_RUNNER_BY_PACKAGE_MANAGER.get(packageManager) ??
|
|
42
|
+
PACKAGE_RUNNER_BY_PACKAGE_MANAGER.get("bun");
|
|
27
43
|
export const DEPENDENCY_FILE_NAMES = new Set([
|
|
28
44
|
PACKAGE_JSON_NAME,
|
|
29
45
|
...LOCKFILE_BY_PACKAGE_MANAGER.values(),
|
|
@@ -1,10 +1,16 @@
|
|
|
1
|
+
import { isMobileSettings } from "./types.js";
|
|
1
2
|
import { findReleaseById, findReleaseBySemver, toModuleContextItems, toFeatureContextItems, } from "./catalog.js";
|
|
2
3
|
export const buildEvalContext = (settings) => {
|
|
4
|
+
if (isMobileSettings(settings)) {
|
|
5
|
+
return buildMobileEvalContext(settings);
|
|
6
|
+
}
|
|
3
7
|
const features = settings.features ?? [];
|
|
4
8
|
const release = findReleaseById(settings.accelplatformVersion.label) ??
|
|
5
9
|
findReleaseBySemver(settings.accelplatformVersion.semver);
|
|
6
10
|
return {
|
|
11
|
+
projectType: "iap",
|
|
7
12
|
accelplatformVersion: settings.accelplatformVersion,
|
|
13
|
+
expoSdk: "",
|
|
8
14
|
modules: settings.modules,
|
|
9
15
|
features,
|
|
10
16
|
moduleItems: release
|
|
@@ -25,8 +31,29 @@ export const buildEvalContext = (settings) => {
|
|
|
25
31
|
javascript: settings.javascript,
|
|
26
32
|
};
|
|
27
33
|
};
|
|
34
|
+
const buildMobileEvalContext = (settings) => ({
|
|
35
|
+
projectType: "mobile",
|
|
36
|
+
accelplatformVersion: settings.targetAccelplatformVersion,
|
|
37
|
+
expoSdk: settings.expoSdk,
|
|
38
|
+
modules: [],
|
|
39
|
+
features: [],
|
|
40
|
+
moduleItems: [],
|
|
41
|
+
featureItems: [],
|
|
42
|
+
locale: settings.locale,
|
|
43
|
+
agents: settings.agents,
|
|
44
|
+
name: settings.name,
|
|
45
|
+
artifactId: "",
|
|
46
|
+
group: "",
|
|
47
|
+
description: "",
|
|
48
|
+
database: "",
|
|
49
|
+
projectVersion: "",
|
|
50
|
+
packageManager: settings.packageManager,
|
|
51
|
+
javascript: false,
|
|
52
|
+
});
|
|
28
53
|
export const emptyEvalContext = (overrides = {}) => ({
|
|
54
|
+
projectType: "iap",
|
|
29
55
|
accelplatformVersion: { label: "", semver: "0.0.0" },
|
|
56
|
+
expoSdk: "",
|
|
30
57
|
modules: [],
|
|
31
58
|
features: [],
|
|
32
59
|
moduleItems: [],
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { ProjectType } from "./types.js";
|
|
2
|
+
export declare const isKnownProjectType: (value: unknown) => value is ProjectType;
|
|
3
|
+
export declare const assertKnownProjectType: (raw: unknown, locale: string) => void;
|
|
4
|
+
export type ProjectTypeScopedInputs = {
|
|
5
|
+
modules?: unknown;
|
|
6
|
+
features?: unknown;
|
|
7
|
+
database?: unknown;
|
|
8
|
+
artifactId?: unknown;
|
|
9
|
+
group?: unknown;
|
|
10
|
+
javascript?: unknown;
|
|
11
|
+
jugglingProject?: unknown;
|
|
12
|
+
projectVersion?: unknown;
|
|
13
|
+
description?: unknown;
|
|
14
|
+
gitInit?: unknown;
|
|
15
|
+
expoSdk?: unknown;
|
|
16
|
+
expoSkills?: unknown;
|
|
17
|
+
};
|
|
18
|
+
export declare const projectTypeOptionValues: (inputs: ProjectTypeScopedInputs) => Record<string, unknown>;
|
|
19
|
+
export declare const collectOptionsNotForProjectType: (values: Readonly<Record<string, unknown>>, projectType: ProjectType) => string[];
|
|
20
|
+
export declare const formatOptionsNotForProjectType: (options: readonly string[], projectType: ProjectType, locale: string) => string;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { PROJECT_TYPE_OPTIONS } from "./constants.js";
|
|
2
|
+
import { getMessage } from "../i18n/index.js";
|
|
3
|
+
import { sanitizeDisplayText } from "../utils/sanitize-text.js";
|
|
4
|
+
export const isKnownProjectType = (value) => PROJECT_TYPE_OPTIONS.includes(value);
|
|
5
|
+
export const assertKnownProjectType = (raw, locale) => {
|
|
6
|
+
if (typeof raw !== "object" || raw === null)
|
|
7
|
+
return;
|
|
8
|
+
const value = raw.projectType;
|
|
9
|
+
if (value === undefined || isKnownProjectType(value))
|
|
10
|
+
return;
|
|
11
|
+
throw new Error(getMessage("error.unknownProjectType", locale, {
|
|
12
|
+
value: sanitizeDisplayText(String(value)),
|
|
13
|
+
}));
|
|
14
|
+
};
|
|
15
|
+
const OPTIONS_NOT_FOR = {
|
|
16
|
+
iap: ["expo-sdk", "expo-skills"],
|
|
17
|
+
mobile: [
|
|
18
|
+
"module",
|
|
19
|
+
"feature",
|
|
20
|
+
"database",
|
|
21
|
+
"artifact-id",
|
|
22
|
+
"group",
|
|
23
|
+
"javascript",
|
|
24
|
+
"juggling-project",
|
|
25
|
+
"project-version",
|
|
26
|
+
"description",
|
|
27
|
+
"git-init",
|
|
28
|
+
],
|
|
29
|
+
};
|
|
30
|
+
export const projectTypeOptionValues = (inputs) => ({
|
|
31
|
+
module: inputs.modules,
|
|
32
|
+
feature: inputs.features,
|
|
33
|
+
database: inputs.database,
|
|
34
|
+
"artifact-id": inputs.artifactId,
|
|
35
|
+
group: inputs.group,
|
|
36
|
+
javascript: inputs.javascript,
|
|
37
|
+
"juggling-project": inputs.jugglingProject,
|
|
38
|
+
"project-version": inputs.projectVersion,
|
|
39
|
+
description: inputs.description,
|
|
40
|
+
"git-init": inputs.gitInit,
|
|
41
|
+
"expo-sdk": inputs.expoSdk,
|
|
42
|
+
"expo-skills": inputs.expoSkills,
|
|
43
|
+
});
|
|
44
|
+
export const collectOptionsNotForProjectType = (values, projectType) => OPTIONS_NOT_FOR[projectType]
|
|
45
|
+
.filter((name) => values[name] !== undefined)
|
|
46
|
+
.map((name) => (values[name] === false ? `no-${name}` : name));
|
|
47
|
+
export const formatOptionsNotForProjectType = (options, projectType, locale) => getMessage(`error.optionNotForProjectType.${projectType}`, locale, {
|
|
48
|
+
options: options.map((o) => `--${o}`).join(", "),
|
|
49
|
+
});
|
package/dist/core/types.d.ts
CHANGED
|
@@ -25,7 +25,10 @@ export type PackageManagerCondition = {
|
|
|
25
25
|
export type JavascriptCondition = {
|
|
26
26
|
javascript: boolean;
|
|
27
27
|
};
|
|
28
|
-
export type
|
|
28
|
+
export type ProjectTypeCondition = {
|
|
29
|
+
projectType: string;
|
|
30
|
+
};
|
|
31
|
+
export type LeafCondition = AccelplatformVersionCondition | ModuleCondition | FeatureCondition | LocaleCondition | AgentCondition | PackageManagerCondition | JavascriptCondition | ProjectTypeCondition;
|
|
29
32
|
export type Condition = AndCondition | OrCondition | LeafCondition;
|
|
30
33
|
export type TextReplacement = {
|
|
31
34
|
type: "text";
|
|
@@ -78,6 +81,7 @@ export type MetaJson = {
|
|
|
78
81
|
replacements?: Replacement[];
|
|
79
82
|
messages?: Message[];
|
|
80
83
|
files?: McpFileRule[];
|
|
84
|
+
mobile?: unknown;
|
|
81
85
|
};
|
|
82
86
|
export type AccelplatformVersion = {
|
|
83
87
|
label: string;
|
|
@@ -96,10 +100,21 @@ export type FeatureContextItem = {
|
|
|
96
100
|
name: string;
|
|
97
101
|
label: string;
|
|
98
102
|
};
|
|
99
|
-
export type
|
|
103
|
+
export type ProjectType = "iap" | "mobile";
|
|
104
|
+
type ProjectSettingsBase = {
|
|
100
105
|
cliVersion: string;
|
|
101
106
|
createdAt: string;
|
|
102
107
|
name: string;
|
|
108
|
+
agents: string[];
|
|
109
|
+
locale: string;
|
|
110
|
+
packageManager: string;
|
|
111
|
+
gitHooks?: boolean;
|
|
112
|
+
dependencies?: string[];
|
|
113
|
+
assetSource?: AssetSourceInfo;
|
|
114
|
+
deployedAssets: Record<string, string>;
|
|
115
|
+
};
|
|
116
|
+
export type IapProjectSettings = ProjectSettingsBase & {
|
|
117
|
+
projectType?: "iap";
|
|
103
118
|
artifactId: string;
|
|
104
119
|
group: string;
|
|
105
120
|
projectVersion: string;
|
|
@@ -108,16 +123,16 @@ export type AccelSettings = {
|
|
|
108
123
|
modules: string[];
|
|
109
124
|
features: string[];
|
|
110
125
|
database: string;
|
|
111
|
-
agents: string[];
|
|
112
126
|
javascript: boolean;
|
|
113
|
-
locale: string;
|
|
114
|
-
packageManager: string;
|
|
115
|
-
gitHooks?: boolean;
|
|
116
|
-
dependencies?: string[];
|
|
117
127
|
jugglingProject: string | null;
|
|
118
|
-
assetSource?: AssetSourceInfo;
|
|
119
|
-
deployedAssets: Record<string, string>;
|
|
120
128
|
};
|
|
129
|
+
export type MobileProjectSettings = ProjectSettingsBase & {
|
|
130
|
+
projectType: "mobile";
|
|
131
|
+
targetAccelplatformVersion: AccelplatformVersion;
|
|
132
|
+
expoSdk: string;
|
|
133
|
+
};
|
|
134
|
+
export type AccelSettings = IapProjectSettings | MobileProjectSettings;
|
|
135
|
+
export declare const isMobileSettings: (settings: AccelSettings) => settings is MobileProjectSettings;
|
|
121
136
|
export type AccelPreset = {
|
|
122
137
|
name: string;
|
|
123
138
|
label?: string;
|
|
@@ -147,7 +162,9 @@ export type AssetProvider = {
|
|
|
147
162
|
sourceInfo: () => AssetSourceInfo;
|
|
148
163
|
};
|
|
149
164
|
export type EvalContext = {
|
|
165
|
+
projectType: ProjectType;
|
|
150
166
|
accelplatformVersion: AccelplatformVersion;
|
|
167
|
+
expoSdk: string;
|
|
151
168
|
modules: string[];
|
|
152
169
|
features: string[];
|
|
153
170
|
moduleItems: ModuleContextItem[];
|
|
@@ -172,6 +189,7 @@ export declare const isLocaleCondition: (c: Condition) => c is LocaleCondition;
|
|
|
172
189
|
export declare const isAgentCondition: (c: Condition) => c is AgentCondition;
|
|
173
190
|
export declare const isPackageManagerCondition: (c: Condition) => c is PackageManagerCondition;
|
|
174
191
|
export declare const isJavascriptCondition: (c: Condition) => c is JavascriptCondition;
|
|
192
|
+
export declare const isProjectTypeCondition: (c: Condition) => c is ProjectTypeCondition;
|
|
175
193
|
export type AccelCredentials = {
|
|
176
194
|
endpoint: string;
|
|
177
195
|
apiKey: string;
|
|
@@ -252,3 +270,4 @@ export type DeployError = {
|
|
|
252
270
|
status?: number;
|
|
253
271
|
serverMessage?: string;
|
|
254
272
|
};
|
|
273
|
+
export {};
|
package/dist/core/types.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export const isMobileSettings = (settings) => settings.projectType === "mobile";
|
|
1
2
|
export const isAndCondition = (c) => "and" in c;
|
|
2
3
|
export const isOrCondition = (c) => "or" in c;
|
|
3
4
|
export const isAccelplatformVersionCondition = (c) => "accelplatformVersion" in c;
|
|
@@ -7,3 +8,4 @@ export const isLocaleCondition = (c) => "locale" in c;
|
|
|
7
8
|
export const isAgentCondition = (c) => "agent" in c;
|
|
8
9
|
export const isPackageManagerCondition = (c) => "packageManager" in c;
|
|
9
10
|
export const isJavascriptCondition = (c) => "javascript" in c;
|
|
11
|
+
export const isProjectTypeCondition = (c) => "projectType" in c;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { IapProjectSettings } from "./types.js";
|
|
2
2
|
import { type Release } from "./catalog.js";
|
|
3
3
|
import { type Validators } from "./validators.js";
|
|
4
4
|
export type PromptOptions = {
|
|
@@ -23,7 +23,7 @@ export type PromptOptions = {
|
|
|
23
23
|
skipIntro?: boolean;
|
|
24
24
|
skipValidation?: boolean;
|
|
25
25
|
};
|
|
26
|
-
export type ResolvedOptions = Omit<
|
|
26
|
+
export type ResolvedOptions = Omit<IapProjectSettings, "cliVersion" | "createdAt" | "deployedAssets" | "assetSource" | "jugglingProject" | "projectType"> & {
|
|
27
27
|
withGit: boolean;
|
|
28
28
|
jugglingProject: string | null | undefined;
|
|
29
29
|
};
|