@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.
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
@@ -1,6 +1,7 @@
1
1
  import { getMessage } from "../i18n/index.js";
2
2
  import { createClackLogger } from "./clack-logger.js";
3
3
  import { displayWidth } from "./format.js";
4
+ import { sanitizeDisplayText } from "../utils/sanitize-text.js";
4
5
  const formatList = (values, emptyLabel) => values.length > 0 ? values.join(", ") : emptyLabel;
5
6
  const formatString = (value, emptyLabel) => value.length > 0 ? value : emptyLabel;
6
7
  const formatBoolean = (value) => (value ? "true" : "false");
@@ -47,6 +48,9 @@ export const buildSummaryBody = (settings, outputDir, locale) => {
47
48
  },
48
49
  { labelKey: "summary.outputDir", value: outputDir },
49
50
  ];
51
+ return formatRows(rows, locale);
52
+ };
53
+ const formatRows = (rows, locale) => {
50
54
  const labels = rows.map((r) => getMessage(r.labelKey, locale));
51
55
  const maxLabelWidth = Math.max(...labels.map((l) => displayWidth(l)));
52
56
  return rows
@@ -57,6 +61,40 @@ export const buildSummaryBody = (settings, outputDir, locale) => {
57
61
  })
58
62
  .join("\n");
59
63
  };
64
+ export const buildMobileSummaryBody = (settings, outputDir, externalCommands, locale) => {
65
+ const empty = getMessage("summary.empty", locale);
66
+ const s = (value) => sanitizeDisplayText(String(value ?? ""));
67
+ const body = formatRows([
68
+ { labelKey: "summary.label.name", value: s(settings.name) },
69
+ {
70
+ labelKey: "summary.label.targetAccelplatformVersion",
71
+ value: s(settings.targetAccelplatformVersion.label),
72
+ },
73
+ { labelKey: "summary.label.expoSdk", value: s(settings.expoSdk) },
74
+ {
75
+ labelKey: "summary.label.agents",
76
+ value: s(formatList(settings.agents, empty)),
77
+ },
78
+ { labelKey: "summary.label.locale", value: s(settings.locale) },
79
+ {
80
+ labelKey: "summary.label.packageManager",
81
+ value: s(settings.packageManager),
82
+ },
83
+ { labelKey: "summary.outputDir", value: outputDir },
84
+ ], locale);
85
+ if (externalCommands.length === 0)
86
+ return body;
87
+ return [
88
+ body,
89
+ "",
90
+ `${getMessage("summary.label.externalCommands", locale)}:`,
91
+ ...externalCommands.map((c) => ` ${c}`),
92
+ getMessage("summary.externalNote", locale),
93
+ ].join("\n");
94
+ };
95
+ export const printMobileSummary = (settings, outputDir, externalCommands, locale, logger = createClackLogger()) => {
96
+ logger.note(buildMobileSummaryBody(settings, outputDir, externalCommands, locale), getMessage("summary.heading", locale));
97
+ };
60
98
  export const printSummary = (settings, outputDir, locale, logger = createClackLogger()) => {
61
99
  logger.note(buildSummaryBody(settings, outputDir, locale), getMessage("summary.heading", locale));
62
100
  };
package/dist/lib.d.ts CHANGED
@@ -1,9 +1,13 @@
1
1
  export { runDeploy, type RunDeployDeps, type DeployPrompts, type DeployRunResult, type SetupRunOutcome, type ConfirmInfo, } from "./commands/deploy.js";
2
2
  export { runLogin, type RunLoginDeps } from "./commands/login.js";
3
3
  export { runInit, type RunInitDeps } from "./commands/init.js";
4
- export { runUpdate, createUpdateFallbackAbortedError, isUpdateFallbackAbortedError, type RunUpdateDeps, type UpdatePrompts, type FallbackMode, type SettingsSourceChoice, } from "./commands/update.js";
4
+ export { runUpdate, createUpdateFallbackAbortedError, isUpdateFallbackAbortedError, type RunUpdateDeps, type UpdatePrompts, type FallbackMode, type SettingsSourceChoice, type MobileUpdateValues, } from "./commands/update.js";
5
5
  export { runSwitch, type RunSwitchDeps, type SwitchPrompts, } from "./commands/switch.js";
6
6
  export { runAttach, type RunAttachDeps } from "./commands/attach.js";
7
+ export { listMobileSdkOptions, type ListMobileSdkOptionsInput, } from "./commands/mobile-sdk-options.js";
8
+ export type { MobileMeta } from "./asset/mobile-meta.js";
9
+ export type { MobilePrompts } from "./interactive/mobile-prompts.js";
10
+ export type { RunExternalCommand, ExternalCommandRequest, ExternalCommandResult, ExternalCommandKind, } from "./utils/external-command.js";
7
11
  export { runDetach, type RunDetachDeps, type DetachPrompts, type DetachResult, } from "./commands/detach.js";
8
12
  export type { Logger, Spinner } from "./core/logger.js";
9
13
  export { createClackLogger } from "./interactive/clack-logger.js";
@@ -16,7 +20,7 @@ export { createFileAssetProvider } from "./asset/file-provider.js";
16
20
  export { createCancelledError, isCancelledError, isAbortError, normalizeAbort, markReported, isReportedError, } from "./core/errors.js";
17
21
  export { isDeployError, makeDeployError } from "./deploy/api-client.js";
18
22
  export { isGitAuthError, isGitObjectMissingError, isGitPackCorruptError, isGitServerUnsupportedError, } from "./git/errors.js";
19
- export { createValidators, createReleaseValidators, createPresetNameValidator, type Validator, type Validators, type ReleaseValidators, } from "./core/validators.js";
23
+ export { createValidators, createReleaseValidators, createPresetNameValidator, createMobileValidators, type Validator, type Validators, type ReleaseValidators, type MobileValidators, } from "./core/validators.js";
20
24
  export { validateNonInteractive, validateCliValues, validateCatalogValues, collectSettingsErrors, checkProjectDirAvailable, type PromptOptions, type ResolvedOptions, } from "./core/validation.js";
21
25
  export { resolveJugglingProject, type JugglingResolved, } from "./juggling/resolve.js";
22
26
  export { readCredentials, normalizeEndpoint, resolveCredentialInputs, } from "./utils/credentials.js";
@@ -26,9 +30,11 @@ export { verifyCredentialsLoop, type VerifyDeps } from "./interactive/credential
26
30
  export { getReleases, findReleaseById, findReleaseBySemver, resolveAccelplatformVersion, resolveLabel, findModuleByCatalogId, toModuleContextItems, toFeatureContextItems, type Release, type ModuleEntry, type FunctionEntry, type Labels, } from "./core/catalog.js";
27
31
  export { configurePaths, getPackageRoot, getCliVersion, } from "./core/paths.js";
28
32
  export { readSettingsSafe, ACCEL_DIR } from "./utils/settings-io.js";
29
- export { listPresetSummaries, formatPresetDisplayName, readPreset, loadAndValidatePreset, writePreset, deletePreset, presetExists, validatePresetSchema, collectPresetCatalogErrors, type PresetSummary, } from "./utils/preset-io.js";
33
+ export { listPresetSummaries, formatPresetDisplayName, readPreset, loadAndValidatePreset, loadAndValidateMobilePreset, writePreset, deletePreset, presetExists, validatePresetSchema, collectPresetCatalogErrors, type PresetSummary, } from "./utils/preset-io.js";
30
34
  export { resolveCacheRoot, cacheReposDir, listCacheRepos, directorySize, clearCacheRepos, type CacheRepoEntry, } from "./git/object-cache.js";
31
- export { DATABASE_OPTIONS, AGENT_OPTIONS, LOCALE_OPTIONS, PACKAGE_MANAGER_OPTIONS, DEFAULT_SETTINGS, DEFAULT_ASSET_REPO_URL, DEFAULT_ASSET_REF, type DatabaseOption, type AgentOption, type LocaleOption, type PackageManagerOption, } from "./core/constants.js";
35
+ export { DATABASE_OPTIONS, AGENT_OPTIONS, MOBILE_AGENT_OPTIONS, LOCALE_OPTIONS, PACKAGE_MANAGER_OPTIONS, PROJECT_TYPE_OPTIONS, DEFAULT_SETTINGS, DEFAULT_ASSET_REPO_URL, DEFAULT_ASSET_REF, type DatabaseOption, type AgentOption, type LocaleOption, type PackageManagerOption, type ProjectTypeOption, } from "./core/constants.js";
32
36
  export { detectAgents, detectDefaultAgents, } from "./interactive/agent-detect.js";
33
- export type { AccelSettings, AccelCredentials, AccelPreset, AssetProvider, AssetSourceInfo, HashsumEntry, DeployError, MessageLevel, StagingResponse, SetupConfigResponse, SampleSetupConfigResponse, } from "./core/types.js";
37
+ export { isMobileSettings } from "./core/types.js";
38
+ export { isKnownProjectType } from "./core/project-type.js";
39
+ export type { AccelSettings, IapProjectSettings, MobileProjectSettings, ProjectType, AccelCredentials, AccelPreset, AssetProvider, AssetSourceInfo, HashsumEntry, DeployError, MessageLevel, StagingResponse, SetupConfigResponse, SampleSetupConfigResponse, } from "./core/types.js";
34
40
  export type { DeployFile } from "./deploy/deploy-files.js";
package/dist/lib.js CHANGED
@@ -4,6 +4,7 @@ export { runInit } from "./commands/init.js";
4
4
  export { runUpdate, createUpdateFallbackAbortedError, isUpdateFallbackAbortedError, } from "./commands/update.js";
5
5
  export { runSwitch, } from "./commands/switch.js";
6
6
  export { runAttach } from "./commands/attach.js";
7
+ export { listMobileSdkOptions, } from "./commands/mobile-sdk-options.js";
7
8
  export { runDetach, } from "./commands/detach.js";
8
9
  export { createClackLogger } from "./interactive/clack-logger.js";
9
10
  export { deployAssets, ROOT_SECTION, } from "./asset/deployer.js";
@@ -13,7 +14,7 @@ export { createFileAssetProvider } from "./asset/file-provider.js";
13
14
  export { createCancelledError, isCancelledError, isAbortError, normalizeAbort, markReported, isReportedError, } from "./core/errors.js";
14
15
  export { isDeployError, makeDeployError } from "./deploy/api-client.js";
15
16
  export { isGitAuthError, isGitObjectMissingError, isGitPackCorruptError, isGitServerUnsupportedError, } from "./git/errors.js";
16
- export { createValidators, createReleaseValidators, createPresetNameValidator, } from "./core/validators.js";
17
+ export { createValidators, createReleaseValidators, createPresetNameValidator, createMobileValidators, } from "./core/validators.js";
17
18
  export { validateNonInteractive, validateCliValues, validateCatalogValues, collectSettingsErrors, checkProjectDirAvailable, } from "./core/validation.js";
18
19
  export { resolveJugglingProject, } from "./juggling/resolve.js";
19
20
  export { readCredentials, normalizeEndpoint, resolveCredentialInputs, } from "./utils/credentials.js";
@@ -23,7 +24,9 @@ export { verifyCredentialsLoop } from "./interactive/credential-auth.js";
23
24
  export { getReleases, findReleaseById, findReleaseBySemver, resolveAccelplatformVersion, resolveLabel, findModuleByCatalogId, toModuleContextItems, toFeatureContextItems, } from "./core/catalog.js";
24
25
  export { configurePaths, getPackageRoot, getCliVersion, } from "./core/paths.js";
25
26
  export { readSettingsSafe, ACCEL_DIR } from "./utils/settings-io.js";
26
- export { listPresetSummaries, formatPresetDisplayName, readPreset, loadAndValidatePreset, writePreset, deletePreset, presetExists, validatePresetSchema, collectPresetCatalogErrors, } from "./utils/preset-io.js";
27
+ export { listPresetSummaries, formatPresetDisplayName, readPreset, loadAndValidatePreset, loadAndValidateMobilePreset, writePreset, deletePreset, presetExists, validatePresetSchema, collectPresetCatalogErrors, } from "./utils/preset-io.js";
27
28
  export { resolveCacheRoot, cacheReposDir, listCacheRepos, directorySize, clearCacheRepos, } from "./git/object-cache.js";
28
- export { DATABASE_OPTIONS, AGENT_OPTIONS, LOCALE_OPTIONS, PACKAGE_MANAGER_OPTIONS, DEFAULT_SETTINGS, DEFAULT_ASSET_REPO_URL, DEFAULT_ASSET_REF, } from "./core/constants.js";
29
+ export { DATABASE_OPTIONS, AGENT_OPTIONS, MOBILE_AGENT_OPTIONS, LOCALE_OPTIONS, PACKAGE_MANAGER_OPTIONS, PROJECT_TYPE_OPTIONS, DEFAULT_SETTINGS, DEFAULT_ASSET_REPO_URL, DEFAULT_ASSET_REF, } from "./core/constants.js";
29
30
  export { detectAgents, detectDefaultAgents, } from "./interactive/agent-detect.js";
31
+ export { isMobileSettings } from "./core/types.js";
32
+ export { isKnownProjectType } from "./core/project-type.js";
@@ -2,4 +2,5 @@ export declare const toCamelCase: (s: string) => string;
2
2
  export declare const toKebabCase: (s: string) => string;
3
3
  export declare const lastFlagValue: (v: unknown) => string | undefined;
4
4
  export declare const collectRepeatedFlag: (rawArgs: readonly string[], name: string) => string[];
5
+ export declare const wasFlagSpecified: (rawArgs: readonly string[], name: string) => boolean;
5
6
  export declare const splitList: (v: unknown) => string[] | undefined;
@@ -28,4 +28,20 @@ export const collectRepeatedFlag = (rawArgs, name) => {
28
28
  }
29
29
  return out;
30
30
  };
31
+ export const wasFlagSpecified = (rawArgs, name) => {
32
+ const spellings = [...new Set([name, toCamelCase(name), toKebabCase(name)])];
33
+ const names = new Set(spellings.flatMap((s) => [
34
+ `--${s}`,
35
+ `--no-${s}`,
36
+ `--no${s[0].toUpperCase()}${s.slice(1)}`,
37
+ ]));
38
+ for (const token of rawArgs) {
39
+ if (token === "--")
40
+ break;
41
+ const flag = token.split("=", 1)[0];
42
+ if (names.has(flag))
43
+ return true;
44
+ }
45
+ return false;
46
+ };
31
47
  export const splitList = (v) => typeof v === "string" ? v.split(",").map((s) => s.trim()) : undefined;
@@ -0,0 +1,8 @@
1
+ export declare const readExpoVersionRange: (projectDir: string) => Promise<string | undefined>;
2
+ export declare const detectExpoSdk: (range: string) => string | undefined;
3
+ export declare const detectProjectExpoSdk: (projectDir: string) => Promise<string | undefined>;
4
+ export type CreatedProjectState = {
5
+ hasPackageJson: boolean;
6
+ installed: boolean;
7
+ };
8
+ export declare const inspectCreatedProject: (projectDir: string, packageManager: string) => Promise<CreatedProjectState>;
@@ -0,0 +1,54 @@
1
+ import { readFile, stat } from "node:fs/promises";
2
+ import { join } from "node:path";
3
+ import { minVersion } from "semver";
4
+ import { PACKAGE_JSON_NAME, lockfileFor } from "../core/constants.js";
5
+ export const readExpoVersionRange = async (projectDir) => {
6
+ let pkg;
7
+ try {
8
+ pkg = JSON.parse(await readFile(join(projectDir, PACKAGE_JSON_NAME), "utf-8"));
9
+ }
10
+ catch {
11
+ return undefined;
12
+ }
13
+ if (typeof pkg !== "object" || pkg === null)
14
+ return undefined;
15
+ for (const field of ["dependencies", "devDependencies"]) {
16
+ const deps = pkg[field];
17
+ if (typeof deps !== "object" || deps === null)
18
+ continue;
19
+ const range = deps.expo;
20
+ if (typeof range === "string")
21
+ return range;
22
+ }
23
+ return undefined;
24
+ };
25
+ export const detectExpoSdk = (range) => {
26
+ try {
27
+ const major = minVersion(range)?.major;
28
+ return major !== undefined && major > 0 ? String(major) : undefined;
29
+ }
30
+ catch {
31
+ return undefined;
32
+ }
33
+ };
34
+ export const detectProjectExpoSdk = async (projectDir) => {
35
+ const range = await readExpoVersionRange(projectDir);
36
+ return range === undefined ? undefined : detectExpoSdk(range);
37
+ };
38
+ const exists = async (path) => {
39
+ try {
40
+ await stat(path);
41
+ return true;
42
+ }
43
+ catch {
44
+ return false;
45
+ }
46
+ };
47
+ export const inspectCreatedProject = async (projectDir, packageManager) => {
48
+ const [hasPackageJson, hasLockfile, hasNodeModules] = await Promise.all([
49
+ exists(join(projectDir, PACKAGE_JSON_NAME)),
50
+ exists(join(projectDir, lockfileFor(packageManager))),
51
+ exists(join(projectDir, "node_modules")),
52
+ ]);
53
+ return { hasPackageJson, installed: hasLockfile && hasNodeModules };
54
+ };
@@ -0,0 +1,68 @@
1
+ import { execFileSync } from "node:child_process";
2
+ import type { MobileMeta } from "../asset/mobile-meta.js";
3
+ export type ExternalCommandKind = "createExpo" | "expoSkills";
4
+ export type ExternalCommandRequest = {
5
+ kind: ExternalCommandKind;
6
+ command: string;
7
+ args: string[];
8
+ cwd: string;
9
+ env: Record<string, string>;
10
+ requires: string[];
11
+ signal?: AbortSignal;
12
+ };
13
+ export type ExternalCommandResult = {
14
+ launched: false;
15
+ missing: string;
16
+ } | {
17
+ launched: true;
18
+ exitCode: number | null;
19
+ outputTail: string[];
20
+ };
21
+ export type RunExternalCommand = (req: ExternalCommandRequest) => Promise<ExternalCommandResult>;
22
+ export declare const buildChildEnv: (base: NodeJS.ProcessEnv, extra: Record<string, string>) => NodeJS.ProcessEnv;
23
+ export type SpawnSpec = {
24
+ file: string;
25
+ args: string[];
26
+ shell: boolean;
27
+ };
28
+ export declare const buildSpawnSpec: (req: Pick<ExternalCommandRequest, "command" | "args">, platform: NodeJS.Platform) => SpawnSpec;
29
+ export declare const taskkillLocation: (env: NodeJS.ProcessEnv) => {
30
+ file: string;
31
+ cwd: string;
32
+ } | undefined;
33
+ export type ProcessTreeKillerOptions = {
34
+ platform: NodeJS.Platform;
35
+ env: NodeJS.ProcessEnv;
36
+ execFileSync?: typeof execFileSync;
37
+ kill?: (pid: number, signal: NodeJS.Signals) => void;
38
+ };
39
+ export declare const createProcessTreeKiller: (options: ProcessTreeKillerOptions) => (pid: number) => void;
40
+ export type ExternalCommandRunnerOptions = {
41
+ platform?: NodeJS.Platform;
42
+ commandExists?: (command: string) => boolean;
43
+ killProcessTree?: (pid: number) => void;
44
+ processEvents?: Pick<NodeJS.EventEmitter, "on" | "removeListener" | "listenerCount">;
45
+ raiseSignal?: (signal: NodeJS.Signals) => void;
46
+ };
47
+ export declare const createExternalCommandRunner: (options?: ExternalCommandRunnerOptions) => RunExternalCommand;
48
+ export declare const runExternalCommand: RunExternalCommand;
49
+ export declare const formatOutputTail: (outputTail: readonly string[]) => string;
50
+ export declare const formatCommandLine: (req: Pick<ExternalCommandRequest, "command" | "args">) => string;
51
+ export declare const buildCreateExpoRequest: (opts: {
52
+ createExpo: MobileMeta["createExpo"];
53
+ name: string;
54
+ parentDir: string;
55
+ packageManager: string;
56
+ skipInstall: boolean;
57
+ signal?: AbortSignal;
58
+ }) => ExternalCommandRequest;
59
+ export declare const EXPO_SKILLS_AGENTS: readonly string[];
60
+ export declare const expoSkillsAgentsFor: (agents: readonly string[]) => string[];
61
+ export declare const buildSkillsAddRequest: (opts: {
62
+ expoSkills: NonNullable<MobileMeta["expoSkills"]>;
63
+ agents: readonly string[];
64
+ projectDir: string;
65
+ packageManager: string;
66
+ signal?: AbortSignal;
67
+ }) => ExternalCommandRequest;
68
+ export declare const formatManualSkillsCommand: (expoSkills: NonNullable<MobileMeta["expoSkills"]>, agents: readonly string[]) => string;
@@ -0,0 +1,238 @@
1
+ import { execFileSync, spawn } from "node:child_process";
2
+ import path from "node:path";
3
+ import { commandExists as defaultCommandExists } from "./command-exists.js";
4
+ import { sanitizeDisplayBlock } from "./sanitize-text.js";
5
+ import { packageRunnerFor } from "../core/constants.js";
6
+ const OUTPUT_TAIL_LINES = 200;
7
+ const MAX_LINE_LENGTH = 4096;
8
+ const WITHHELD_ENV_KEYS = ["ACCEL_API_KEY", "ACCEL_ENDPOINT"];
9
+ export const buildChildEnv = (base, extra) => {
10
+ const env = { ...base };
11
+ for (const key of Object.keys(env)) {
12
+ if (WITHHELD_ENV_KEYS.includes(key.toUpperCase()))
13
+ delete env[key];
14
+ }
15
+ return { ...env, NoDefaultCurrentDirectoryInExePath: "1", ...extra };
16
+ };
17
+ const FAILURE_TAIL_LINES = 20;
18
+ const SAFE_TOKEN_PATTERN = /^[A-Za-z0-9@._~/:=-]+$/;
19
+ export const buildSpawnSpec = (req, platform) => {
20
+ if (platform !== "win32") {
21
+ return { file: req.command, args: [...req.args], shell: false };
22
+ }
23
+ const tokens = [req.command, ...req.args];
24
+ const unsafe = tokens.find((t) => !SAFE_TOKEN_PATTERN.test(t));
25
+ if (unsafe !== undefined) {
26
+ throw new Error(`Refusing to run an external command with an unsafe token: ${JSON.stringify(unsafe)}`);
27
+ }
28
+ return { file: tokens.join(" "), args: [], shell: true };
29
+ };
30
+ const createLineTail = (limit) => {
31
+ const lines = [];
32
+ const push = (line) => {
33
+ lines.push(line);
34
+ if (lines.length > limit)
35
+ lines.shift();
36
+ };
37
+ const createSink = () => {
38
+ let partial = "";
39
+ return {
40
+ write: (chunk) => {
41
+ const parts = (partial + chunk).split(/\r\n|\n/);
42
+ partial = (parts.pop() ?? "").slice(-MAX_LINE_LENGTH);
43
+ parts.forEach((line) => push(line.slice(-MAX_LINE_LENGTH)));
44
+ },
45
+ flush: () => {
46
+ if (partial !== "")
47
+ push(partial);
48
+ partial = "";
49
+ },
50
+ };
51
+ };
52
+ return { createSink, lines: () => [...lines] };
53
+ };
54
+ const INTERRUPT_SIGNALS = ["SIGINT", "SIGTERM", "SIGHUP"];
55
+ const TASKKILL_TIMEOUT_MS = 5000;
56
+ const WINDOWS_ROOT_PATTERN = /^[A-Za-z]:\\/;
57
+ export const taskkillLocation = (env) => {
58
+ const root = env.SystemRoot;
59
+ if (root === undefined || !WINDOWS_ROOT_PATTERN.test(root))
60
+ return undefined;
61
+ const system32 = path.win32.join(root, "System32");
62
+ return { file: path.win32.join(system32, "taskkill.exe"), cwd: system32 };
63
+ };
64
+ export const createProcessTreeKiller = (options) => (pid) => {
65
+ if (!Number.isSafeInteger(pid) || pid <= 1)
66
+ return;
67
+ try {
68
+ if (options.platform === "win32") {
69
+ const taskkill = taskkillLocation(options.env);
70
+ if (taskkill === undefined)
71
+ return;
72
+ (options.execFileSync ?? execFileSync)(taskkill.file, ["/PID", String(pid), "/T", "/F"], {
73
+ cwd: taskkill.cwd,
74
+ stdio: "ignore",
75
+ windowsHide: true,
76
+ timeout: TASKKILL_TIMEOUT_MS,
77
+ });
78
+ }
79
+ else {
80
+ (options.kill ?? ((p, s) => process.kill(p, s)))(-pid, "SIGTERM");
81
+ }
82
+ }
83
+ catch {
84
+ }
85
+ };
86
+ const createAbortError = (signal) => Object.assign(new Error("The operation was aborted", { cause: signal?.reason }), { name: "AbortError" });
87
+ export const createExternalCommandRunner = (options = {}) => async (req) => {
88
+ const exists = options.commandExists ?? defaultCommandExists;
89
+ for (const command of [req.command, ...req.requires]) {
90
+ if (!exists(command))
91
+ return { launched: false, missing: command };
92
+ }
93
+ const platform = options.platform ?? process.platform;
94
+ const spec = buildSpawnSpec(req, platform);
95
+ const killTree = options.killProcessTree ??
96
+ createProcessTreeKiller({ platform, env: process.env });
97
+ const events = options.processEvents ?? process;
98
+ const raiseSignal = options.raiseSignal ?? ((s) => process.kill(process.pid, s));
99
+ return new Promise((resolve, reject) => {
100
+ if (req.signal?.aborted) {
101
+ reject(createAbortError(req.signal));
102
+ return;
103
+ }
104
+ const tail = createLineTail(OUTPUT_TAIL_LINES);
105
+ const child = spawn(spec.file, spec.args, {
106
+ cwd: req.cwd,
107
+ env: buildChildEnv(process.env, req.env),
108
+ stdio: ["ignore", "pipe", "pipe"],
109
+ shell: spec.shell,
110
+ windowsHide: true,
111
+ detached: platform !== "win32",
112
+ });
113
+ const sinks = [child.stdout, child.stderr].map((stream) => {
114
+ const sink = tail.createSink();
115
+ stream.setEncoding("utf-8");
116
+ stream.on("data", sink.write);
117
+ return sink;
118
+ });
119
+ let settled = false;
120
+ const terminate = () => {
121
+ if (child.pid === undefined ||
122
+ child.exitCode !== null ||
123
+ child.signalCode !== null) {
124
+ return;
125
+ }
126
+ killTree(child.pid);
127
+ };
128
+ const stopInterruptHandling = () => {
129
+ INTERRUPT_SIGNALS.forEach((s) => events.removeListener(s, onSignal));
130
+ req.signal?.removeEventListener("abort", interrupt);
131
+ };
132
+ const interrupt = () => {
133
+ stopInterruptHandling();
134
+ terminate();
135
+ if (settled)
136
+ return;
137
+ settled = true;
138
+ reject(createAbortError(req.signal));
139
+ };
140
+ const onSignal = (signal) => {
141
+ interrupt();
142
+ if (events.listenerCount(signal) === 0)
143
+ raiseSignal(signal);
144
+ };
145
+ const finish = () => {
146
+ stopInterruptHandling();
147
+ events.removeListener("exit", terminate);
148
+ };
149
+ events.on("exit", terminate);
150
+ INTERRUPT_SIGNALS.forEach((s) => events.on(s, onSignal));
151
+ req.signal?.addEventListener("abort", interrupt, { once: true });
152
+ child.on("error", (err) => {
153
+ finish();
154
+ if (settled)
155
+ return;
156
+ settled = true;
157
+ if (err.code === "ENOENT") {
158
+ resolve({ launched: false, missing: req.command });
159
+ }
160
+ else {
161
+ reject(err);
162
+ }
163
+ });
164
+ child.on("close", (code) => {
165
+ finish();
166
+ if (settled)
167
+ return;
168
+ settled = true;
169
+ sinks.forEach((s) => s.flush());
170
+ resolve({ launched: true, exitCode: code, outputTail: tail.lines() });
171
+ });
172
+ });
173
+ };
174
+ export const runExternalCommand = createExternalCommandRunner();
175
+ export const formatOutputTail = (outputTail) => sanitizeDisplayBlock(outputTail.slice(-FAILURE_TAIL_LINES).join("\n"));
176
+ export const formatCommandLine = (req) => [req.command, ...req.args].join(" ");
177
+ const runnerEnv = (packageManager) => {
178
+ const { userAgent } = packageRunnerFor(packageManager);
179
+ return userAgent ? { npm_config_user_agent: `${userAgent}/accel` } : {};
180
+ };
181
+ export const buildCreateExpoRequest = (opts) => {
182
+ const runner = packageRunnerFor(opts.packageManager);
183
+ return {
184
+ kind: "createExpo",
185
+ command: runner.command,
186
+ args: [
187
+ ...runner.args,
188
+ opts.createExpo.package,
189
+ opts.name,
190
+ "--template",
191
+ opts.createExpo.template,
192
+ "--yes",
193
+ "--no-agents-md",
194
+ ...(opts.skipInstall ? ["--no-install"] : []),
195
+ ],
196
+ cwd: opts.parentDir,
197
+ env: {
198
+ CI: "1",
199
+ EXPO_NO_TELEMETRY: "1",
200
+ ...runnerEnv(opts.packageManager),
201
+ },
202
+ requires: ["npm"],
203
+ signal: opts.signal,
204
+ };
205
+ };
206
+ export const EXPO_SKILLS_AGENTS = ["codex"];
207
+ export const expoSkillsAgentsFor = (agents) => EXPO_SKILLS_AGENTS.filter((a) => agents.includes(a));
208
+ const skillsAddArgs = (expoSkills, agents) => [
209
+ "add",
210
+ expoSkills.source,
211
+ "--skill",
212
+ ...expoSkills.skills,
213
+ "--agent",
214
+ ...agents,
215
+ "--copy",
216
+ ];
217
+ export const buildSkillsAddRequest = (opts) => {
218
+ const runner = packageRunnerFor(opts.packageManager);
219
+ return {
220
+ kind: "expoSkills",
221
+ command: runner.command,
222
+ args: [
223
+ ...runner.args,
224
+ opts.expoSkills.package,
225
+ ...skillsAddArgs(opts.expoSkills, opts.agents),
226
+ "-y",
227
+ ],
228
+ cwd: opts.projectDir,
229
+ env: {
230
+ CI: "1",
231
+ DISABLE_TELEMETRY: "1",
232
+ ...runnerEnv(opts.packageManager),
233
+ },
234
+ requires: ["git"],
235
+ signal: opts.signal,
236
+ };
237
+ };
238
+ export const formatManualSkillsCommand = (expoSkills, agents) => ["npx", expoSkills.package, ...skillsAddArgs(expoSkills, agents)].join(" ");
@@ -22,3 +22,4 @@ export declare const validatePresetSchema: (raw: unknown, expectedName: string,
22
22
  export declare const collectPresetCatalogErrors: (preset: AccelPreset, release: Release, locale: string) => string[];
23
23
  export declare const readPreset: (projectDir: string, name: string, locale: string) => Promise<AccelPreset>;
24
24
  export declare const loadAndValidatePreset: (projectDir: string, name: string, releaseId: string, locale: string) => Promise<AccelPreset>;
25
+ export declare const loadAndValidateMobilePreset: (projectDir: string, name: string, locale: string) => Promise<AccelPreset>;
@@ -1,6 +1,6 @@
1
1
  import { readFile, writeFile, mkdir, readdir, rm, stat } from "node:fs/promises";
2
2
  import { join } from "node:path";
3
- import { PRESET_NAME_PATTERN, createPresetNameValidator, createReleaseValidators, createValidators, } from "../core/validators.js";
3
+ import { PRESET_NAME_PATTERN, createMobileValidators, createPresetNameValidator, createReleaseValidators, createValidators, } from "../core/validators.js";
4
4
  import { findReleaseById } from "../core/catalog.js";
5
5
  import { getMessage } from "../i18n/index.js";
6
6
  import { ACCEL_DIR } from "./settings-io.js";
@@ -165,3 +165,20 @@ export const loadAndValidatePreset = async (projectDir, name, releaseId, locale)
165
165
  }
166
166
  return preset;
167
167
  };
168
+ export const loadAndValidateMobilePreset = async (projectDir, name, locale) => {
169
+ const preset = await readPreset(projectDir, name, locale);
170
+ const errors = [];
171
+ if (preset.modules.length > 0 || preset.features.length > 0) {
172
+ errors.push(getMessage("preset.error.mobileModules", locale));
173
+ }
174
+ const agentValidator = createMobileValidators(locale).agent;
175
+ for (const agent of preset.agents) {
176
+ const error = agentValidator(agent);
177
+ if (error)
178
+ errors.push(error);
179
+ }
180
+ if (errors.length > 0) {
181
+ throw invalidPresetError(name, errors.map((e) => sanitizeDisplayText(e)), locale);
182
+ }
183
+ return preset;
184
+ };
@@ -5,6 +5,7 @@ export declare const ensureAccelDir: (projectDir: string) => Promise<string>;
5
5
  export declare const writeSettings: (projectDir: string, settings: AccelSettings) => Promise<void>;
6
6
  export declare const readSettings: (projectDir: string) => Promise<AccelSettings>;
7
7
  export declare const readSettingsSafe: (projectDir: string) => Promise<AccelSettings | null>;
8
+ export declare const readProjectSettings: (projectDir: string, locale: string) => Promise<AccelSettings | null>;
8
9
  export declare const serializeHashsum: (entries: HashsumEntry[]) => string;
9
10
  export declare const parseHashsum: (content: string) => HashsumEntry[];
10
11
  export declare const writeHashsum: (projectDir: string, entries: HashsumEntry[]) => Promise<void>;
@@ -1,5 +1,6 @@
1
1
  import { readFile, writeFile, mkdir } from "node:fs/promises";
2
2
  import { join } from "node:path";
3
+ import { assertKnownProjectType } from "../core/project-type.js";
3
4
  import { isSafeRelPath } from "./safe-rel-path.js";
4
5
  import { ACCEL_DIR } from "../core/constants.js";
5
6
  export { ACCEL_DIR };
@@ -28,6 +29,17 @@ export const readSettingsSafe = async (projectDir) => {
28
29
  return null;
29
30
  }
30
31
  };
32
+ export const readProjectSettings = async (projectDir, locale) => {
33
+ let raw;
34
+ try {
35
+ raw = JSON.parse(await readFile(join(projectDir, ACCEL_DIR, SETTINGS_FILE), "utf-8"));
36
+ }
37
+ catch {
38
+ return null;
39
+ }
40
+ assertKnownProjectType(raw, locale);
41
+ return raw;
42
+ };
31
43
  export const serializeHashsum = (entries) => {
32
44
  const sorted = [...entries].sort((a, b) => a.filePath.localeCompare(b.filePath));
33
45
  return sorted
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@intra-mart/accel",
3
- "version": "1.0.0-rc.202609290758",
3
+ "version": "2.0.0-dev.202610210621",
4
4
  "type": "module",
5
5
  "description": "CLI tool for intra-mart Accel Platform development",
6
6
  "author": "INTRAMART CORPORATION",