primitive-admin 1.0.61 → 1.0.63
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 +125 -69
- package/assets/skill/skills/primitive-platform/SKILL.md +336 -37
- package/dist/bin/primitive.js +25 -14
- package/dist/bin/primitive.js.map +1 -1
- package/dist/src/commands/analytics.js +36 -16
- package/dist/src/commands/analytics.js.map +1 -1
- package/dist/src/commands/apps.js +52 -188
- package/dist/src/commands/apps.js.map +1 -1
- package/dist/src/commands/blob-buckets.js +13 -153
- package/dist/src/commands/blob-buckets.js.map +1 -1
- package/dist/src/commands/collection-type-configs.js +14 -100
- package/dist/src/commands/collection-type-configs.js.map +1 -1
- package/dist/src/commands/collections.js +47 -8
- package/dist/src/commands/collections.js.map +1 -1
- package/dist/src/commands/config.d.ts +46 -0
- package/dist/src/commands/config.js +479 -0
- package/dist/src/commands/config.js.map +1 -0
- package/dist/src/commands/connections.js +12 -7
- package/dist/src/commands/connections.js.map +1 -1
- package/dist/src/commands/cron-triggers.js +84 -176
- package/dist/src/commands/cron-triggers.js.map +1 -1
- package/dist/src/commands/database-type-configs.d.ts +2 -0
- package/dist/src/commands/database-type-configs.js +171 -0
- package/dist/src/commands/database-type-configs.js.map +1 -0
- package/dist/src/commands/database-types.js +4 -4
- package/dist/src/commands/database-types.js.map +1 -1
- package/dist/src/commands/databases.d.ts +63 -0
- package/dist/src/commands/databases.js +649 -87
- package/dist/src/commands/databases.js.map +1 -1
- package/dist/src/commands/documents.js +869 -12
- package/dist/src/commands/documents.js.map +1 -1
- package/dist/src/commands/email-templates.js +21 -128
- package/dist/src/commands/email-templates.js.map +1 -1
- package/dist/src/commands/env.d.ts +12 -1
- package/dist/src/commands/env.js +115 -26
- package/dist/src/commands/env.js.map +1 -1
- package/dist/src/commands/feature-flags.d.ts +14 -0
- package/dist/src/commands/feature-flags.js +116 -0
- package/dist/src/commands/feature-flags.js.map +1 -0
- package/dist/src/commands/group-type-configs.js +14 -109
- package/dist/src/commands/group-type-configs.js.map +1 -1
- package/dist/src/commands/init.d.ts +24 -1
- package/dist/src/commands/init.js +1194 -279
- package/dist/src/commands/init.js.map +1 -1
- package/dist/src/commands/integrations.js +166 -435
- package/dist/src/commands/integrations.js.map +1 -1
- package/dist/src/commands/metadata-category-configs.d.ts +12 -0
- package/dist/src/commands/metadata-category-configs.js +112 -0
- package/dist/src/commands/metadata-category-configs.js.map +1 -0
- package/dist/src/commands/metadata.js +33 -141
- package/dist/src/commands/metadata.js.map +1 -1
- package/dist/src/commands/prompts.js +206 -563
- package/dist/src/commands/prompts.js.map +1 -1
- package/dist/src/commands/rule-sets.d.ts +1 -1
- package/dist/src/commands/rule-sets.js +16 -132
- package/dist/src/commands/rule-sets.js.map +1 -1
- package/dist/src/commands/scripts.d.ts +10 -0
- package/dist/src/commands/scripts.js +203 -241
- package/dist/src/commands/scripts.js.map +1 -1
- package/dist/src/commands/sessions.js +17 -5
- package/dist/src/commands/sessions.js.map +1 -1
- package/dist/src/commands/sync-app-settings.d.ts +113 -70
- package/dist/src/commands/sync-app-settings.js +193 -242
- package/dist/src/commands/sync-app-settings.js.map +1 -1
- package/dist/src/commands/sync.d.ts +1904 -51
- package/dist/src/commands/sync.js +9468 -1790
- package/dist/src/commands/sync.js.map +1 -1
- package/dist/src/commands/tokens.js +8 -2
- package/dist/src/commands/tokens.js.map +1 -1
- package/dist/src/commands/users.js +92 -1
- package/dist/src/commands/users.js.map +1 -1
- package/dist/src/commands/vars.js +44 -58
- package/dist/src/commands/vars.js.map +1 -1
- package/dist/src/commands/webhooks.js +318 -156
- package/dist/src/commands/webhooks.js.map +1 -1
- package/dist/src/commands/workflows.d.ts +49 -12
- package/dist/src/commands/workflows.js +652 -1086
- package/dist/src/commands/workflows.js.map +1 -1
- package/dist/src/lib/access-rule-display.d.ts +21 -0
- package/dist/src/lib/access-rule-display.js +34 -0
- package/dist/src/lib/access-rule-display.js.map +1 -0
- package/dist/src/lib/api-client.d.ts +541 -61
- package/dist/src/lib/api-client.js +559 -102
- package/dist/src/lib/api-client.js.map +1 -1
- package/dist/src/lib/app-settings-descriptor.d.ts +180 -25
- package/dist/src/lib/app-settings-descriptor.js +403 -82
- package/dist/src/lib/app-settings-descriptor.js.map +1 -1
- package/dist/src/lib/canonical-json.d.ts +12 -0
- package/dist/src/lib/canonical-json.js +35 -0
- package/dist/src/lib/canonical-json.js.map +1 -0
- package/dist/src/lib/cli-manifest.d.ts +8 -0
- package/dist/src/lib/cli-manifest.js +1 -0
- package/dist/src/lib/cli-manifest.js.map +1 -1
- package/dist/src/lib/codegen-shared/generatedFiles.d.ts +6 -2
- package/dist/src/lib/codegen-shared/generatedFiles.js +9 -2
- package/dist/src/lib/codegen-shared/generatedFiles.js.map +1 -1
- package/dist/src/lib/codegen-shared/resolveCodegenSourceDir.d.ts +6 -6
- package/dist/src/lib/codegen-shared/resolveCodegenSourceDir.js +8 -8
- package/dist/src/lib/codegen-shared/resolveCodegenSourceDir.js.map +1 -1
- package/dist/src/lib/config-object-descriptor.d.ts +127 -0
- package/dist/src/lib/config-object-descriptor.js +658 -0
- package/dist/src/lib/config-object-descriptor.js.map +1 -0
- package/dist/src/lib/config-payload.d.ts +85 -0
- package/dist/src/lib/config-payload.js +116 -0
- package/dist/src/lib/config-payload.js.map +1 -0
- package/dist/src/lib/config-surface.d.ts +130 -0
- package/dist/src/lib/config-surface.js +300 -0
- package/dist/src/lib/config-surface.js.map +1 -0
- package/dist/src/lib/credentials-store.d.ts +10 -0
- package/dist/src/lib/credentials-store.js +23 -0
- package/dist/src/lib/credentials-store.js.map +1 -1
- package/dist/src/lib/data-input.d.ts +23 -0
- package/dist/src/lib/data-input.js +50 -0
- package/dist/src/lib/data-input.js.map +1 -0
- package/dist/src/lib/db-codegen/dbTemplates.js +1 -1
- package/dist/src/lib/db-codegen/dbTemplates.js.map +1 -1
- package/dist/src/lib/db-codegen/dbTypeIR.d.ts +1 -1
- package/dist/src/lib/env-resolver-core.d.ts +187 -0
- package/dist/src/lib/env-resolver-core.js +325 -0
- package/dist/src/lib/env-resolver-core.js.map +1 -0
- package/dist/src/lib/env-resolver.d.ts +28 -6
- package/dist/src/lib/env-resolver.js +44 -32
- package/dist/src/lib/env-resolver.js.map +1 -1
- package/dist/src/lib/generated-allowlist.js +12 -0
- package/dist/src/lib/generated-allowlist.js.map +1 -1
- package/dist/src/lib/generated-config-surfaces.d.ts +682 -0
- package/dist/src/lib/generated-config-surfaces.js +4058 -0
- package/dist/src/lib/generated-config-surfaces.js.map +1 -0
- package/dist/src/lib/generated-template-lint.d.ts +212 -0
- package/dist/src/lib/generated-template-lint.js +624 -0
- package/dist/src/lib/generated-template-lint.js.map +1 -0
- package/dist/src/lib/init-adopt.d.ts +16 -0
- package/dist/src/lib/init-adopt.js +34 -0
- package/dist/src/lib/init-adopt.js.map +1 -0
- package/dist/src/lib/init-assets.d.ts +39 -0
- package/dist/src/lib/init-assets.js +97 -0
- package/dist/src/lib/init-assets.js.map +1 -0
- package/dist/src/lib/init-client-platforms.d.ts +14 -0
- package/dist/src/lib/init-client-platforms.js +71 -0
- package/dist/src/lib/init-client-platforms.js.map +1 -0
- package/dist/src/lib/init-config.d.ts +44 -5
- package/dist/src/lib/init-config.js +80 -7
- package/dist/src/lib/init-config.js.map +1 -1
- package/dist/src/lib/init-email-redirect-uris.d.ts +37 -0
- package/dist/src/lib/init-email-redirect-uris.js +46 -0
- package/dist/src/lib/init-email-redirect-uris.js.map +1 -0
- package/dist/src/lib/init-ios-links.d.ts +90 -0
- package/dist/src/lib/init-ios-links.js +218 -0
- package/dist/src/lib/init-ios-links.js.map +1 -0
- package/dist/src/lib/init-plan.d.ts +80 -0
- package/dist/src/lib/init-plan.js +95 -0
- package/dist/src/lib/init-plan.js.map +1 -0
- package/dist/src/lib/init-production-env.d.ts +48 -0
- package/dist/src/lib/init-production-env.js +59 -0
- package/dist/src/lib/init-production-env.js.map +1 -0
- package/dist/src/lib/init-schema.d.ts +74 -0
- package/dist/src/lib/init-schema.js +358 -0
- package/dist/src/lib/init-schema.js.map +1 -0
- package/dist/src/lib/init-xcode.d.ts +33 -0
- package/dist/src/lib/init-xcode.js +114 -0
- package/dist/src/lib/init-xcode.js.map +1 -0
- package/dist/src/lib/integration-request-config.d.ts +30 -0
- package/dist/src/lib/integration-request-config.js +145 -0
- package/dist/src/lib/integration-request-config.js.map +1 -0
- package/dist/src/lib/integration-selector.d.ts +42 -0
- package/dist/src/lib/integration-selector.js +46 -0
- package/dist/src/lib/integration-selector.js.map +1 -0
- package/dist/src/lib/local-state.d.ts +55 -0
- package/dist/src/lib/local-state.js +167 -0
- package/dist/src/lib/local-state.js.map +1 -0
- package/dist/src/lib/local-test-cases.d.ts +63 -0
- package/dist/src/lib/local-test-cases.js +135 -0
- package/dist/src/lib/local-test-cases.js.map +1 -0
- package/dist/src/lib/log-inspection.d.ts +568 -0
- package/dist/src/lib/log-inspection.js +639 -0
- package/dist/src/lib/log-inspection.js.map +1 -0
- package/dist/src/lib/migration-nag.d.ts +2 -2
- package/dist/src/lib/migration-nag.js +3 -3
- package/dist/src/lib/object-status-filter.d.ts +22 -0
- package/dist/src/lib/object-status-filter.js +45 -0
- package/dist/src/lib/object-status-filter.js.map +1 -0
- package/dist/src/lib/output.d.ts +24 -1
- package/dist/src/lib/output.js +42 -1
- package/dist/src/lib/output.js.map +1 -1
- package/dist/src/lib/package-manager.d.ts +140 -0
- package/dist/src/lib/package-manager.js +305 -0
- package/dist/src/lib/package-manager.js.map +1 -0
- package/dist/src/lib/paginate.d.ts +50 -0
- package/dist/src/lib/paginate.js +53 -0
- package/dist/src/lib/paginate.js.map +1 -1
- package/dist/src/lib/platform-owned.d.ts +29 -3
- package/dist/src/lib/platform-owned.js +42 -3
- package/dist/src/lib/platform-owned.js.map +1 -1
- package/dist/src/lib/project-config.d.ts +8 -0
- package/dist/src/lib/project-config.js +30 -5
- package/dist/src/lib/project-config.js.map +1 -1
- package/dist/src/lib/query-operators.d.ts +1 -1
- package/dist/src/lib/query-operators.js +1 -1
- package/dist/src/lib/record-filter.d.ts +18 -0
- package/dist/src/lib/record-filter.js +55 -0
- package/dist/src/lib/record-filter.js.map +1 -0
- package/dist/src/lib/resolve-init-dev-port.d.ts +56 -0
- package/dist/src/lib/resolve-init-dev-port.js +55 -0
- package/dist/src/lib/resolve-init-dev-port.js.map +1 -0
- package/dist/src/lib/resolve-init-server.d.ts +64 -0
- package/dist/src/lib/resolve-init-server.js +77 -0
- package/dist/src/lib/resolve-init-server.js.map +1 -0
- package/dist/src/lib/resolve-platform.d.ts +43 -14
- package/dist/src/lib/resolve-platform.js +74 -12
- package/dist/src/lib/resolve-platform.js.map +1 -1
- package/dist/src/lib/run-status.d.ts +19 -0
- package/dist/src/lib/run-status.generated.d.ts +39 -0
- package/dist/src/lib/run-status.generated.js +66 -0
- package/dist/src/lib/run-status.generated.js.map +1 -0
- package/dist/src/lib/run-status.js +19 -0
- package/dist/src/lib/run-status.js.map +1 -0
- package/dist/src/lib/server-text-normalization.d.ts +51 -0
- package/dist/src/lib/server-text-normalization.js +90 -0
- package/dist/src/lib/server-text-normalization.js.map +1 -0
- package/dist/src/lib/server-url.d.ts +22 -0
- package/dist/src/lib/server-url.js +33 -0
- package/dist/src/lib/server-url.js.map +1 -0
- package/dist/src/lib/signing-secret-status.d.ts +81 -0
- package/dist/src/lib/signing-secret-status.js +116 -0
- package/dist/src/lib/signing-secret-status.js.map +1 -0
- package/dist/src/lib/skill-installer.js +6 -3
- package/dist/src/lib/skill-installer.js.map +1 -1
- package/dist/src/lib/snapshots.d.ts +2 -2
- package/dist/src/lib/snapshots.js +2 -2
- package/dist/src/lib/swift-codegen/dbGenerator.d.ts +15 -2
- package/dist/src/lib/swift-codegen/dbGenerator.js +250 -18
- package/dist/src/lib/swift-codegen/dbGenerator.js.map +1 -1
- package/dist/src/lib/swift-codegen/generator.d.ts +11 -2
- package/dist/src/lib/swift-codegen/generator.js +181 -7
- package/dist/src/lib/swift-codegen/generator.js.map +1 -1
- package/dist/src/lib/swift-codegen/siblingSymbols.d.ts +7 -3
- package/dist/src/lib/swift-codegen/siblingSymbols.js +4 -1
- package/dist/src/lib/swift-codegen/siblingSymbols.js.map +1 -1
- package/dist/src/lib/sync-dir-selector.d.ts +21 -0
- package/dist/src/lib/sync-dir-selector.js +30 -0
- package/dist/src/lib/sync-dir-selector.js.map +1 -0
- package/dist/src/lib/sync-paths.d.ts +39 -0
- package/dist/src/lib/sync-paths.js +70 -2
- package/dist/src/lib/sync-paths.js.map +1 -1
- package/dist/src/lib/sync-resource-types.d.ts +138 -31
- package/dist/src/lib/sync-resource-types.js +241 -47
- package/dist/src/lib/sync-resource-types.js.map +1 -1
- package/dist/src/lib/sync-selectors.d.ts +95 -0
- package/dist/src/lib/sync-selectors.js +228 -0
- package/dist/src/lib/sync-selectors.js.map +1 -0
- package/dist/src/lib/template.d.ts +62 -4
- package/dist/src/lib/template.js +147 -39
- package/dist/src/lib/template.js.map +1 -1
- package/dist/src/lib/test-case-file-names.d.ts +40 -0
- package/dist/src/lib/test-case-file-names.js +91 -0
- package/dist/src/lib/test-case-file-names.js.map +1 -0
- package/dist/src/lib/test-case-keys.d.ts +29 -0
- package/dist/src/lib/test-case-keys.js +55 -0
- package/dist/src/lib/test-case-keys.js.map +1 -0
- package/dist/src/lib/test-case-variables.d.ts +15 -0
- package/dist/src/lib/test-case-variables.js +29 -0
- package/dist/src/lib/test-case-variables.js.map +1 -0
- package/dist/src/lib/toml-database-config.d.ts +4 -4
- package/dist/src/lib/toml-database-config.js +27 -34
- package/dist/src/lib/toml-database-config.js.map +1 -1
- package/dist/src/lib/toml-metadata-config.d.ts +9 -5
- package/dist/src/lib/toml-metadata-config.js +40 -45
- package/dist/src/lib/toml-metadata-config.js.map +1 -1
- package/dist/src/lib/toml-native-form.d.ts +1 -1
- package/dist/src/lib/toml-native-form.js +1 -1
- package/dist/src/lib/toml-params-validator.d.ts +1 -1
- package/dist/src/lib/toml-params-validator.js +1 -1
- package/dist/src/lib/toml-scalar-edit.d.ts +43 -0
- package/dist/src/lib/toml-scalar-edit.js +283 -0
- package/dist/src/lib/toml-scalar-edit.js.map +1 -0
- package/dist/src/lib/user-selector.d.ts +24 -0
- package/dist/src/lib/user-selector.js +33 -0
- package/dist/src/lib/user-selector.js.map +1 -0
- package/dist/src/lib/version-check.d.ts +25 -0
- package/dist/src/lib/version-check.js +77 -8
- package/dist/src/lib/version-check.js.map +1 -1
- package/dist/src/lib/watch.d.ts +121 -0
- package/dist/src/lib/watch.js +169 -0
- package/dist/src/lib/watch.js.map +1 -0
- package/dist/src/lib/web-url.d.ts +40 -0
- package/dist/src/lib/web-url.js +76 -0
- package/dist/src/lib/web-url.js.map +1 -0
- package/dist/src/lib/workflow-apply.d.ts +69 -45
- package/dist/src/lib/workflow-apply.js +99 -72
- package/dist/src/lib/workflow-apply.js.map +1 -1
- package/dist/src/lib/workflow-codegen/generator.js +4 -4
- package/dist/src/lib/workflow-codegen/generator.js.map +1 -1
- package/dist/src/lib/workflow-codegen/invokerIR.d.ts +11 -0
- package/dist/src/lib/workflow-codegen/invokerIR.js +5 -0
- package/dist/src/lib/workflow-codegen/invokerIR.js.map +1 -1
- package/dist/src/lib/workflow-config-apply.d.ts +70 -0
- package/dist/src/lib/workflow-config-apply.js +137 -0
- package/dist/src/lib/workflow-config-apply.js.map +1 -0
- package/dist/src/lib/workflow-config-sidecar.d.ts +63 -0
- package/dist/src/lib/workflow-config-sidecar.js +96 -0
- package/dist/src/lib/workflow-config-sidecar.js.map +1 -0
- package/dist/src/lib/workflow-defaults.d.ts +29 -0
- package/dist/src/lib/workflow-defaults.js +41 -0
- package/dist/src/lib/workflow-defaults.js.map +1 -0
- package/dist/src/lib/workflow-include-preserve.d.ts +76 -0
- package/dist/src/lib/workflow-include-preserve.js +286 -0
- package/dist/src/lib/workflow-include-preserve.js.map +1 -0
- package/dist/src/lib/workflow-payload.d.ts +31 -20
- package/dist/src/lib/workflow-payload.js +100 -110
- package/dist/src/lib/workflow-payload.js.map +1 -1
- package/dist/src/lib/workflow-toml-validator.d.ts +37 -16
- package/dist/src/lib/workflow-toml-validator.js +141 -16
- package/dist/src/lib/workflow-toml-validator.js.map +1 -1
- package/dist/src/types/index.d.ts +78 -22
- package/dist/src/validators.d.ts +7 -7
- package/dist/src/validators.js +6 -6
- package/package.json +11 -6
- package/dist/src/commands/settings.d.ts +0 -15
- package/dist/src/commands/settings.js +0 -102
- package/dist/src/commands/settings.js.map +0 -1
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `config push --only <selector>` — the selection model (issue #2645).
|
|
3
|
+
*
|
|
4
|
+
* With configuration authored in TOML only, `config push` is the sole write path,
|
|
5
|
+
* so it needs a way to apply ONE object — the capability
|
|
6
|
+
* `workflows update --from-file` used to provide.
|
|
7
|
+
*
|
|
8
|
+
* `--only` is a selection PREDICATE over the existing per-directory push loops,
|
|
9
|
+
* not a second single-object apply path. The workflow leg in particular keeps
|
|
10
|
+
* going through `applyWorkflowBody`, whose PATCH → steps → deferred
|
|
11
|
+
* `syncCallable` PATCH ordering a second implementation has broken before
|
|
12
|
+
* (#807). Everything else about push — conflict detection, `--prune`,
|
|
13
|
+
* `--dry-run`, `--force` — is unchanged; `--only` decides only which files the
|
|
14
|
+
* loops look at.
|
|
15
|
+
*
|
|
16
|
+
* Grammar:
|
|
17
|
+
* <type>/<key> one of the 13 per-entity types, e.g. `workflow/order-intake`
|
|
18
|
+
* app the `app.toml` root singleton
|
|
19
|
+
* var/<key> one key of the `vars.toml` root singleton
|
|
20
|
+
*
|
|
21
|
+
* The root singletons are named explicitly rather than derived: they are
|
|
22
|
+
* deliberately outside `SYNC_RESOURCE_TYPES` (that table is per-entity layout
|
|
23
|
+
* metadata), so a selector model that walked it alone could not reach them.
|
|
24
|
+
*
|
|
25
|
+
* Key derivation reuses `PUSH_PRUNE_SPECS[].keyFromFile`, which already mirrors
|
|
26
|
+
* each type's push loop exactly (`<in-file identity> || basename`). That is what
|
|
27
|
+
* makes `--only workflow/greeting` select a file renamed to `custom.toml` that
|
|
28
|
+
* still declares `workflow.key = "greeting"`, the same way push would update it.
|
|
29
|
+
*/
|
|
30
|
+
/** A selector the operator has to fix; push must not run with it. */
|
|
31
|
+
export declare class SelectorError extends Error {
|
|
32
|
+
constructor(message: string);
|
|
33
|
+
}
|
|
34
|
+
export interface SyncSelection {
|
|
35
|
+
/** Per-entity type label → the selected keys of that type. */
|
|
36
|
+
entityKeys: Map<string, Set<string>>;
|
|
37
|
+
/** True when `app.toml` was selected. */
|
|
38
|
+
app: boolean;
|
|
39
|
+
/** Selected `vars.toml` keys. */
|
|
40
|
+
varKeys: Set<string>;
|
|
41
|
+
/** The selectors as written, for the push report. */
|
|
42
|
+
raw: string[];
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Read `--only` values into a selection. Throws `SelectorError` on anything
|
|
46
|
+
* that would silently select nothing — an unknown type, a missing key, a key
|
|
47
|
+
* on a singleton that has none.
|
|
48
|
+
*/
|
|
49
|
+
export declare function parseSyncSelectors(values: readonly string[]): SyncSelection;
|
|
50
|
+
/** True when any object of `label` is selected (or there is no selection). */
|
|
51
|
+
export declare function selectionIncludesType(selection: SyncSelection | null, label: string): boolean;
|
|
52
|
+
/**
|
|
53
|
+
* True when `app.toml` is selected (or there is no selection).
|
|
54
|
+
*
|
|
55
|
+
* The root singletons need their own predicates because they are deliberately
|
|
56
|
+
* outside `SYNC_RESOURCE_TYPES` — `selectionIncludesType` cannot answer for
|
|
57
|
+
* them. Without these, the preflight legs that read `app.toml` / `vars.toml`
|
|
58
|
+
* ran on every `--only` push and could abort it over a file the operator did
|
|
59
|
+
* not select.
|
|
60
|
+
*/
|
|
61
|
+
export declare function selectionIncludesApp(selection: SyncSelection | null): boolean;
|
|
62
|
+
/** True when any `vars.toml` key is selected (or there is no selection). */
|
|
63
|
+
export declare function selectionIncludesAnyVar(selection: SyncSelection | null): boolean;
|
|
64
|
+
/** True when `key` of `label` is selected (or there is no selection). */
|
|
65
|
+
export declare function selectionIncludesKey(selection: SyncSelection | null, label: string, key: string): boolean;
|
|
66
|
+
/**
|
|
67
|
+
* Narrow a type's file list to the selected objects. Keys are derived the same
|
|
68
|
+
* way `config push` derives them, so a renamed file that still declares its key
|
|
69
|
+
* is selected.
|
|
70
|
+
*/
|
|
71
|
+
export declare function filterFilesBySelection(selection: SyncSelection | null, label: string, dir: string, files: string[]): string[];
|
|
72
|
+
/**
|
|
73
|
+
* Selectors naming an object no local file declares.
|
|
74
|
+
*
|
|
75
|
+
* Checked before push runs so `--only workflow/typo` fails loudly. Without it
|
|
76
|
+
* a typo would select nothing, every loop would iterate an empty list, and push
|
|
77
|
+
* would report success having applied nothing at all.
|
|
78
|
+
*/
|
|
79
|
+
export declare function unmatchedSelectors(selection: SyncSelection, configDir: string): string[];
|
|
80
|
+
/** The file a selector points at, for an operator-facing message. */
|
|
81
|
+
export declare function selectorFileHint(type: string): string;
|
|
82
|
+
/**
|
|
83
|
+
* The local files of `label` that declare `key`, using the same derivation
|
|
84
|
+
* `config push` and `--only` use (`<in-file identity> || basename`).
|
|
85
|
+
*
|
|
86
|
+
* `config set` needs this for the same reason `--only` does: a file renamed away
|
|
87
|
+
* from its key — `custom.toml` declaring `workflow.key = "greeting"` — is still
|
|
88
|
+
* the object `workflow/greeting` names. Resolving `<type>/<key>` by file name
|
|
89
|
+
* alone made the two commands disagree, so the object a push would apply was
|
|
90
|
+
* not the one `config set` edited (issue #2645, review follow-up).
|
|
91
|
+
*
|
|
92
|
+
* Returns every match rather than the first: two files declaring one key is an
|
|
93
|
+
* ambiguity the operator has to resolve, not something to pick a winner for.
|
|
94
|
+
*/
|
|
95
|
+
export declare function filesDeclaringKey(configDir: string, label: string, key: string): string[];
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `config push --only <selector>` — the selection model (issue #2645).
|
|
3
|
+
*
|
|
4
|
+
* With configuration authored in TOML only, `config push` is the sole write path,
|
|
5
|
+
* so it needs a way to apply ONE object — the capability
|
|
6
|
+
* `workflows update --from-file` used to provide.
|
|
7
|
+
*
|
|
8
|
+
* `--only` is a selection PREDICATE over the existing per-directory push loops,
|
|
9
|
+
* not a second single-object apply path. The workflow leg in particular keeps
|
|
10
|
+
* going through `applyWorkflowBody`, whose PATCH → steps → deferred
|
|
11
|
+
* `syncCallable` PATCH ordering a second implementation has broken before
|
|
12
|
+
* (#807). Everything else about push — conflict detection, `--prune`,
|
|
13
|
+
* `--dry-run`, `--force` — is unchanged; `--only` decides only which files the
|
|
14
|
+
* loops look at.
|
|
15
|
+
*
|
|
16
|
+
* Grammar:
|
|
17
|
+
* <type>/<key> one of the 13 per-entity types, e.g. `workflow/order-intake`
|
|
18
|
+
* app the `app.toml` root singleton
|
|
19
|
+
* var/<key> one key of the `vars.toml` root singleton
|
|
20
|
+
*
|
|
21
|
+
* The root singletons are named explicitly rather than derived: they are
|
|
22
|
+
* deliberately outside `SYNC_RESOURCE_TYPES` (that table is per-entity layout
|
|
23
|
+
* metadata), so a selector model that walked it alone could not reach them.
|
|
24
|
+
*
|
|
25
|
+
* Key derivation reuses `PUSH_PRUNE_SPECS[].keyFromFile`, which already mirrors
|
|
26
|
+
* each type's push loop exactly (`<in-file identity> || basename`). That is what
|
|
27
|
+
* makes `--only workflow/greeting` select a file renamed to `custom.toml` that
|
|
28
|
+
* still declares `workflow.key = "greeting"`, the same way push would update it.
|
|
29
|
+
*/
|
|
30
|
+
import { existsSync, readdirSync, readFileSync } from "fs";
|
|
31
|
+
import { join } from "path";
|
|
32
|
+
import { parseConfigToml } from "./config-toml.js";
|
|
33
|
+
import { CONFIG_OBJECT_DESCRIPTORS, getConfigObjectDescriptor, } from "./config-object-descriptor.js";
|
|
34
|
+
import { PUSH_PRUNE_SPECS } from "./sync-resource-types.js";
|
|
35
|
+
import { configAuthoringError } from "./platform-owned.js";
|
|
36
|
+
/** A selector the operator has to fix; push must not run with it. */
|
|
37
|
+
export class SelectorError extends Error {
|
|
38
|
+
constructor(message) {
|
|
39
|
+
super(message);
|
|
40
|
+
this.name = "SelectorError";
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
const ENTITY_TYPES = new Set(CONFIG_OBJECT_DESCRIPTORS.filter((d) => d.resourceType).map((d) => d.type));
|
|
44
|
+
const KEY_FROM_FILE = new Map(PUSH_PRUNE_SPECS.map((spec) => [spec.resourceType.label, spec.keyFromFile]));
|
|
45
|
+
function knownTypesHint() {
|
|
46
|
+
return [...ENTITY_TYPES].sort().join(", ") + ", app, var";
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Read `--only` values into a selection. Throws `SelectorError` on anything
|
|
50
|
+
* that would silently select nothing — an unknown type, a missing key, a key
|
|
51
|
+
* on a singleton that has none.
|
|
52
|
+
*/
|
|
53
|
+
export function parseSyncSelectors(values) {
|
|
54
|
+
const raw = values
|
|
55
|
+
.flatMap((v) => String(v).split(","))
|
|
56
|
+
.map((v) => v.trim())
|
|
57
|
+
.filter((v) => v !== "");
|
|
58
|
+
if (raw.length === 0) {
|
|
59
|
+
throw new SelectorError(`--only needs at least one selector: <type>/<key>, app, or var/<key>. Types: ${knownTypesHint()}`);
|
|
60
|
+
}
|
|
61
|
+
const selection = {
|
|
62
|
+
entityKeys: new Map(),
|
|
63
|
+
app: false,
|
|
64
|
+
varKeys: new Set(),
|
|
65
|
+
raw,
|
|
66
|
+
};
|
|
67
|
+
for (const selector of raw) {
|
|
68
|
+
const slash = selector.indexOf("/");
|
|
69
|
+
const type = slash === -1 ? selector : selector.slice(0, slash);
|
|
70
|
+
const key = slash === -1 ? "" : selector.slice(slash + 1).trim();
|
|
71
|
+
if (type === "app") {
|
|
72
|
+
if (key) {
|
|
73
|
+
throw new SelectorError(`'${selector}': app.toml is a single file — use 'app' with no key`);
|
|
74
|
+
}
|
|
75
|
+
selection.app = true;
|
|
76
|
+
continue;
|
|
77
|
+
}
|
|
78
|
+
if (type === "var") {
|
|
79
|
+
if (!key) {
|
|
80
|
+
throw new SelectorError(`'${selector}': name the config var, e.g. var/API_BASE_URL`);
|
|
81
|
+
}
|
|
82
|
+
selection.varKeys.add(key);
|
|
83
|
+
continue;
|
|
84
|
+
}
|
|
85
|
+
if (!ENTITY_TYPES.has(type)) {
|
|
86
|
+
throw new SelectorError(`'${selector}': unknown configuration type '${type}'. Types: ${knownTypesHint()}`);
|
|
87
|
+
}
|
|
88
|
+
if (!key) {
|
|
89
|
+
throw new SelectorError(`'${selector}': name the object, e.g. ${type}/<key>. Run 'primitive config fields ${type}' to see its keys.`);
|
|
90
|
+
}
|
|
91
|
+
// Push skips the platform-owned namespace (#1660), so selecting one would
|
|
92
|
+
// report a successful push that applied nothing — the same silent-empty
|
|
93
|
+
// selection the checks above exist to prevent.
|
|
94
|
+
const refusal = configAuthoringError(type, key);
|
|
95
|
+
if (refusal)
|
|
96
|
+
throw new SelectorError(`'${selector}': ${refusal}`);
|
|
97
|
+
const set = selection.entityKeys.get(type) ?? new Set();
|
|
98
|
+
set.add(key);
|
|
99
|
+
selection.entityKeys.set(type, set);
|
|
100
|
+
}
|
|
101
|
+
return selection;
|
|
102
|
+
}
|
|
103
|
+
/** True when any object of `label` is selected (or there is no selection). */
|
|
104
|
+
export function selectionIncludesType(selection, label) {
|
|
105
|
+
if (!selection)
|
|
106
|
+
return true;
|
|
107
|
+
return selection.entityKeys.has(label);
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* True when `app.toml` is selected (or there is no selection).
|
|
111
|
+
*
|
|
112
|
+
* The root singletons need their own predicates because they are deliberately
|
|
113
|
+
* outside `SYNC_RESOURCE_TYPES` — `selectionIncludesType` cannot answer for
|
|
114
|
+
* them. Without these, the preflight legs that read `app.toml` / `vars.toml`
|
|
115
|
+
* ran on every `--only` push and could abort it over a file the operator did
|
|
116
|
+
* not select.
|
|
117
|
+
*/
|
|
118
|
+
export function selectionIncludesApp(selection) {
|
|
119
|
+
return !selection || selection.app;
|
|
120
|
+
}
|
|
121
|
+
/** True when any `vars.toml` key is selected (or there is no selection). */
|
|
122
|
+
export function selectionIncludesAnyVar(selection) {
|
|
123
|
+
return !selection || selection.varKeys.size > 0;
|
|
124
|
+
}
|
|
125
|
+
/** True when `key` of `label` is selected (or there is no selection). */
|
|
126
|
+
export function selectionIncludesKey(selection, label, key) {
|
|
127
|
+
if (!selection)
|
|
128
|
+
return true;
|
|
129
|
+
return !!selection.entityKeys.get(label)?.has(key);
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Narrow a type's file list to the selected objects. Keys are derived the same
|
|
133
|
+
* way `config push` derives them, so a renamed file that still declares its key
|
|
134
|
+
* is selected.
|
|
135
|
+
*/
|
|
136
|
+
export function filterFilesBySelection(selection, label, dir, files) {
|
|
137
|
+
if (!selection)
|
|
138
|
+
return files;
|
|
139
|
+
const wanted = selection.entityKeys.get(label);
|
|
140
|
+
if (!wanted || wanted.size === 0)
|
|
141
|
+
return [];
|
|
142
|
+
const keyFromFile = KEY_FROM_FILE.get(label);
|
|
143
|
+
if (!keyFromFile)
|
|
144
|
+
return [];
|
|
145
|
+
return files.filter((file) => wanted.has(keyFromFile(join(dir, file))));
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Selectors naming an object no local file declares.
|
|
149
|
+
*
|
|
150
|
+
* Checked before push runs so `--only workflow/typo` fails loudly. Without it
|
|
151
|
+
* a typo would select nothing, every loop would iterate an empty list, and push
|
|
152
|
+
* would report success having applied nothing at all.
|
|
153
|
+
*/
|
|
154
|
+
export function unmatchedSelectors(selection, configDir) {
|
|
155
|
+
const missing = [];
|
|
156
|
+
for (const [label, keys] of selection.entityKeys) {
|
|
157
|
+
const descriptor = getConfigObjectDescriptor(label);
|
|
158
|
+
const layout = descriptor?.resourceType;
|
|
159
|
+
const keyFromFile = KEY_FROM_FILE.get(label);
|
|
160
|
+
const dir = layout ? join(configDir, layout.dir) : "";
|
|
161
|
+
const declared = new Set();
|
|
162
|
+
if (layout && keyFromFile && existsSync(dir)) {
|
|
163
|
+
for (const file of readdirSync(dir)) {
|
|
164
|
+
if (!file.endsWith(layout.ext))
|
|
165
|
+
continue;
|
|
166
|
+
declared.add(keyFromFile(join(dir, file)));
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
for (const key of keys) {
|
|
170
|
+
if (!declared.has(key))
|
|
171
|
+
missing.push(`${label}/${key}`);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
if (selection.app && !existsSync(join(configDir, "app.toml"))) {
|
|
175
|
+
missing.push("app");
|
|
176
|
+
}
|
|
177
|
+
if (selection.varKeys.size > 0) {
|
|
178
|
+
const varsPath = join(configDir, "vars.toml");
|
|
179
|
+
let declared = new Set();
|
|
180
|
+
if (existsSync(varsPath)) {
|
|
181
|
+
try {
|
|
182
|
+
// `vars.toml` is a FLAT root table — `API_BASE_URL = "…"`, no section.
|
|
183
|
+
declared = new Set(Object.keys(parseConfigToml(readFileSync(varsPath, "utf-8"))));
|
|
184
|
+
}
|
|
185
|
+
catch {
|
|
186
|
+
// A malformed vars.toml is the push preflight's error to report, not
|
|
187
|
+
// this check's — treat it as "cannot tell" and stay quiet.
|
|
188
|
+
declared = selection.varKeys;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
for (const key of selection.varKeys) {
|
|
192
|
+
if (!declared.has(key))
|
|
193
|
+
missing.push(`var/${key}`);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
return missing;
|
|
197
|
+
}
|
|
198
|
+
/** The file a selector points at, for an operator-facing message. */
|
|
199
|
+
export function selectorFileHint(type) {
|
|
200
|
+
return getConfigObjectDescriptor(type)?.fileHint ?? type;
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* The local files of `label` that declare `key`, using the same derivation
|
|
204
|
+
* `config push` and `--only` use (`<in-file identity> || basename`).
|
|
205
|
+
*
|
|
206
|
+
* `config set` needs this for the same reason `--only` does: a file renamed away
|
|
207
|
+
* from its key — `custom.toml` declaring `workflow.key = "greeting"` — is still
|
|
208
|
+
* the object `workflow/greeting` names. Resolving `<type>/<key>` by file name
|
|
209
|
+
* alone made the two commands disagree, so the object a push would apply was
|
|
210
|
+
* not the one `config set` edited (issue #2645, review follow-up).
|
|
211
|
+
*
|
|
212
|
+
* Returns every match rather than the first: two files declaring one key is an
|
|
213
|
+
* ambiguity the operator has to resolve, not something to pick a winner for.
|
|
214
|
+
*/
|
|
215
|
+
export function filesDeclaringKey(configDir, label, key) {
|
|
216
|
+
const layout = getConfigObjectDescriptor(label)?.resourceType;
|
|
217
|
+
const keyFromFile = KEY_FROM_FILE.get(label);
|
|
218
|
+
if (!layout || !keyFromFile)
|
|
219
|
+
return [];
|
|
220
|
+
const dir = join(configDir, layout.dir);
|
|
221
|
+
if (!existsSync(dir))
|
|
222
|
+
return [];
|
|
223
|
+
return readdirSync(dir)
|
|
224
|
+
.filter((file) => file.endsWith(layout.ext))
|
|
225
|
+
.map((file) => join(dir, file))
|
|
226
|
+
.filter((path) => keyFromFile(path) === key);
|
|
227
|
+
}
|
|
228
|
+
//# sourceMappingURL=sync-selectors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sync-selectors.js","sourceRoot":"","sources":["../../../src/lib/sync-selectors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAC3D,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EACL,yBAAyB,EACzB,yBAAyB,GAC1B,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAE3D,qEAAqE;AACrE,MAAM,OAAO,aAAc,SAAQ,KAAK;IACtC,YAAY,OAA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AAG,EAAE,CAAC,CAAC;QACrD,CAAC;IACH,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,qEAAqE;AACrE,MAAM,UAAU,gBAAgB,CAAC,IAAY;IAC3C,OAAO,yBAAyB,CAAC,IAAI,CAAC,EAAE,QAAQ,IAAI,IAAI,CAAC;AAC3D,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,iBAAiB,CAC/B,SAAiB,EACjB,KAAa,EACb,GAAW;IAEX,MAAM,MAAM,GAAG,yBAAyB,CAAC,KAAK,CAAC,EAAE,YAAY,CAAC;IAC9D,MAAM,WAAW,GAAG,aAAa,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IAC7C,IAAI,CAAC,MAAM,IAAI,CAAC,WAAW;QAAE,OAAO,EAAE,CAAC;IACvC,MAAM,GAAG,GAAG,IAAI,CAAC,SAAS,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC;IACxC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC;QAAE,OAAO,EAAE,CAAC;IAChC,OAAO,WAAW,CAAC,GAAG,CAAC;SACpB,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;SAC3C,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;SAC9B,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC;AACjD,CAAC"}
|
|
@@ -36,12 +36,24 @@ export interface UpdateEnvResult {
|
|
|
36
36
|
envUpdated: boolean;
|
|
37
37
|
envProductionUpdated: boolean;
|
|
38
38
|
}
|
|
39
|
+
/** The backend a production build talks to, when the caller derived one. */
|
|
40
|
+
export interface ProductionEnvTarget {
|
|
41
|
+
serverUrl: string;
|
|
42
|
+
appId: string;
|
|
43
|
+
appName?: string;
|
|
44
|
+
}
|
|
39
45
|
/**
|
|
40
46
|
* Updates .env and .env.production files with the app ID and server URLs.
|
|
41
47
|
* For .env, if it doesn't exist but .env.example does, copies from example first.
|
|
42
48
|
* Returns information about which files were updated.
|
|
49
|
+
*
|
|
50
|
+
* `production` names the backend/app pair a production build should talk to.
|
|
51
|
+
* Omit it and `.env.production` points at the hosted production server with
|
|
52
|
+
* this app id — the historical behavior, which is correct for an app created
|
|
53
|
+
* there and wrong for one created anywhere else, so composed runs derive the
|
|
54
|
+
* pair from the project's own environments and pass it in (#2890).
|
|
43
55
|
*/
|
|
44
|
-
export declare function updateEnvFile(targetDir: string, appId: string, serverUrl: string, appName?: string): UpdateEnvResult;
|
|
56
|
+
export declare function updateEnvFile(targetDir: string, appId: string, serverUrl: string, appName?: string, production?: ProductionEnvTarget): UpdateEnvResult;
|
|
45
57
|
/**
|
|
46
58
|
* Runs pnpm install in the target directory.
|
|
47
59
|
* Uses npx to ensure corepack/packageManager compatibility.
|
|
@@ -69,10 +81,18 @@ export declare function gitInitialCommit(targetDir: string): Promise<void>;
|
|
|
69
81
|
* bind to one address family.
|
|
70
82
|
*/
|
|
71
83
|
export declare function isPortFree(port: number): Promise<boolean>;
|
|
84
|
+
/**
|
|
85
|
+
* Pins `server.port` in the source of a vite config. Returns the patched
|
|
86
|
+
* source, or null when the config's shape is one we can't patch — the caller
|
|
87
|
+
* must not claim success in that case.
|
|
88
|
+
*
|
|
89
|
+
* Exported for tests, which pin this against the real shipped template.
|
|
90
|
+
*/
|
|
91
|
+
export declare function patchViteConfigPort(content: string, port: number): string | null;
|
|
72
92
|
/**
|
|
73
93
|
* Pins the dev server port in vite.config.{ts,js,mts,mjs} by injecting or
|
|
74
|
-
* updating the `server.port` field. Returns true if a config file was
|
|
75
|
-
* and
|
|
94
|
+
* updating the `server.port` field. Returns true only if a config file was
|
|
95
|
+
* found *and* actually rewritten.
|
|
76
96
|
*/
|
|
77
97
|
export declare function updateViteConfig(targetDir: string, port: number): boolean;
|
|
78
98
|
/**
|
|
@@ -98,6 +118,43 @@ export { IOS_TEMPLATE_URL };
|
|
|
98
118
|
* Returns true if the file was found and updated.
|
|
99
119
|
*/
|
|
100
120
|
export declare function updatePrimitiveJson(targetDir: string, appId: string, serverUrl: string, appName?: string): boolean;
|
|
121
|
+
export interface PrimitiveJsonResult {
|
|
122
|
+
/**
|
|
123
|
+
* - `generated` — the template's resolve script wrote it from
|
|
124
|
+
* `.primitive/config.json` (a current template).
|
|
125
|
+
* - `failed` — that script ran and errored; `detail` carries its output.
|
|
126
|
+
* - `filled` — an older template's tracked file had its placeholders
|
|
127
|
+
* substituted.
|
|
128
|
+
* - `missing` — neither; the caller warns.
|
|
129
|
+
*/
|
|
130
|
+
outcome: "generated" | "failed" | "filled" | "missing";
|
|
131
|
+
detail?: string;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Gives an Apple scaffold a working `primitive.json`.
|
|
135
|
+
*
|
|
136
|
+
* In a current template that file is a BUILD PRODUCT generated from the
|
|
137
|
+
* Primitive environment in `.primitive/config.json` (#2873) — the one place
|
|
138
|
+
* the app ID and server URL are typed. `init` has just scaffolded that config,
|
|
139
|
+
* so running the template's own resolve script here means the scaffold has a
|
|
140
|
+
* `primitive.json` immediately rather than only after its first build, and
|
|
141
|
+
* there is exactly one implementation of the resolution.
|
|
142
|
+
*
|
|
143
|
+
* A template that predates the change has no such script and ships a tracked
|
|
144
|
+
* file with `__PRIMITIVE_*__` placeholders instead; filling those in keeps a
|
|
145
|
+
* new CLI working against an old template.
|
|
146
|
+
*/
|
|
147
|
+
export declare function configurePrimitiveJson(targetDir: string, appId: string, serverUrl: string, appName?: string, options?: {
|
|
148
|
+
/**
|
|
149
|
+
* The environment this run resolved, when it resolved one explicitly —
|
|
150
|
+
* `primitive -e <name> init` adopting an existing app, say. The script
|
|
151
|
+
* applies the same precedence on its own, but from the machine's point of
|
|
152
|
+
* view: without being told, it would configure the client for this
|
|
153
|
+
* machine's selection or the committed default while the run reported
|
|
154
|
+
* another app.
|
|
155
|
+
*/
|
|
156
|
+
environmentName?: string;
|
|
157
|
+
}): PrimitiveJsonResult;
|
|
101
158
|
/**
|
|
102
159
|
* Checks if Xcode command-line tools are installed.
|
|
103
160
|
*/
|
|
@@ -107,6 +164,7 @@ export declare function isXcodeInstalled(): Promise<boolean>;
|
|
|
107
164
|
*/
|
|
108
165
|
export declare function runSwiftPackageResolve(targetDir: string): Promise<void>;
|
|
109
166
|
/**
|
|
110
|
-
* Installs the primitive CLI (primitive-admin) globally using
|
|
167
|
+
* Installs the primitive CLI (primitive-admin) globally, using whichever
|
|
168
|
+
* package manager already owns a global copy — pnpm by default.
|
|
111
169
|
*/
|
|
112
170
|
export declare function installPrimitiveCli(): Promise<void>;
|