primitive-admin 1.0.61 → 1.0.62
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 +49 -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 +18 -125
- 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 +98 -25
- 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 +9 -1
- package/dist/src/commands/init.js +1056 -277
- package/dist/src/commands/init.js.map +1 -1
- package/dist/src/commands/integrations.js +136 -421
- 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.js +67 -234
- 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 +1932 -49
- package/dist/src/commands/sync.js +9521 -1769
- 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 +147 -0
- package/dist/src/lib/env-resolver-core.js +265 -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-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-ios-links.d.ts +50 -0
- package/dist/src/lib/init-ios-links.js +153 -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/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/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.js +13 -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-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/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,80 @@
|
|
|
1
|
+
import type { Platform } from "./resolve-platform.js";
|
|
2
|
+
export type InitMode = "standalone" | "multi-client" | "add-client";
|
|
3
|
+
export interface ClientPlan {
|
|
4
|
+
platform: Platform;
|
|
5
|
+
/** Absolute directory this client's template is installed into. */
|
|
6
|
+
dir: string;
|
|
7
|
+
}
|
|
8
|
+
export interface InitPlan {
|
|
9
|
+
mode: InitMode;
|
|
10
|
+
/** Every client this run scaffolds, in processing order (web first). */
|
|
11
|
+
clients: ClientPlan[];
|
|
12
|
+
/** The directory holding the ONE `.primitive/` for this app. */
|
|
13
|
+
projectRoot: string;
|
|
14
|
+
/**
|
|
15
|
+
* Whether this run writes `.primitive/config.json` and seeds the
|
|
16
|
+
* environment's credential slot. False when adopting: the config is already
|
|
17
|
+
* there and is not this run's to rewrite.
|
|
18
|
+
*/
|
|
19
|
+
writesProjectConfig: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Whether this run may create the app and point the CLI's global "current
|
|
22
|
+
* app" at it. False when adopting — the app already exists and belongs to the
|
|
23
|
+
* project config.
|
|
24
|
+
*/
|
|
25
|
+
ownsApp: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Whether this run creates the git repository and its initial commit. False
|
|
28
|
+
* when adopting: the surrounding repository owns the history, and the new
|
|
29
|
+
* files are left for the user to review and commit.
|
|
30
|
+
*/
|
|
31
|
+
initsGit: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* The one schema both clients read, or `null` in standalone mode where the
|
|
34
|
+
* client keeps the template's own copy (spec decision 1: single-client output
|
|
35
|
+
* is unchanged).
|
|
36
|
+
*/
|
|
37
|
+
canonicalSchemaPath: string | null;
|
|
38
|
+
/**
|
|
39
|
+
* Whether this run may write an app-wide `AGENTS.md` at the project root.
|
|
40
|
+
* Never over an existing file — client `AGENTS.md` files ship with their
|
|
41
|
+
* templates and an adopted repo's root file is the user's.
|
|
42
|
+
*/
|
|
43
|
+
writesRootAgents: boolean;
|
|
44
|
+
}
|
|
45
|
+
export interface PlanInitInput {
|
|
46
|
+
/** The resolved platforms, in canonical order. */
|
|
47
|
+
platforms: Platform[];
|
|
48
|
+
/** Absolute directory the command was pointed at. */
|
|
49
|
+
targetDir: string;
|
|
50
|
+
/**
|
|
51
|
+
* The nearest ancestor project root, passed ONLY when it differs from
|
|
52
|
+
* `targetDir` — `primitive init .` at an existing project root keeps its
|
|
53
|
+
* merge behavior rather than adopting itself.
|
|
54
|
+
*/
|
|
55
|
+
ancestorProjectRoot?: string | null;
|
|
56
|
+
}
|
|
57
|
+
/** Resolve the layout for this run. */
|
|
58
|
+
export declare function planInit(input: PlanInitInput): InitPlan;
|
|
59
|
+
export interface InitGuardInput {
|
|
60
|
+
/** The init config's `action`, when a non-interactive config is in effect. */
|
|
61
|
+
action?: "create" | "use-existing" | "add-client";
|
|
62
|
+
/** Whether an init config is in effect at all. */
|
|
63
|
+
hasConfig: boolean;
|
|
64
|
+
/** The nearest ancestor project root, or null/undefined outside a project. */
|
|
65
|
+
ancestorProjectRoot?: string | null;
|
|
66
|
+
/** `app_id` from a `use-existing` init config. */
|
|
67
|
+
configAppId?: string;
|
|
68
|
+
/** `--use-existing-app-id`. */
|
|
69
|
+
flagAppId?: string;
|
|
70
|
+
/** The adopted environment's `appId`, when adopting. */
|
|
71
|
+
environmentAppId?: string;
|
|
72
|
+
/** The adopted environment's name, for the error messages. */
|
|
73
|
+
environmentName?: string;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Everything a run must be refused for, checked before any download, any API
|
|
77
|
+
* call and any write. Returns the user-facing message, or `null` when the run
|
|
78
|
+
* may proceed.
|
|
79
|
+
*/
|
|
80
|
+
export declare function checkInitGuards(input: InitGuardInput): string | null;
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What shape does this `primitive init` run produce? (#2890)
|
|
3
|
+
*
|
|
4
|
+
* One Primitive app can have several clients — a web client and a native
|
|
5
|
+
* client — and they are one app: one appId, one project config, one exported
|
|
6
|
+
* server-config tree, one model schema. `init` therefore composes one of three
|
|
7
|
+
* layouts, and the choice decides everything downstream:
|
|
8
|
+
*
|
|
9
|
+
* standalone — one client, no surrounding project. Today's flat scaffold,
|
|
10
|
+
* unchanged: the client IS the project root.
|
|
11
|
+
* multi-client — several clients, no surrounding project. Each client gets a
|
|
12
|
+
* platform-named subdirectory; the project config, the git
|
|
13
|
+
* repository and the canonical schema live at the root.
|
|
14
|
+
* add-client — an ancestor `.primitive/config.json` already exists. The run
|
|
15
|
+
* ADOPTS it: no nested project config, no nested git
|
|
16
|
+
* repository, no app creation, no commit. This is the path the
|
|
17
|
+
* issue opens with — running init in a subdirectory used to
|
|
18
|
+
* scaffold a second project that had to be partly undone.
|
|
19
|
+
*
|
|
20
|
+
* Pure on purpose: the layout and the guards are the part that is expensive to
|
|
21
|
+
* get wrong and impossible to assert from a half-written scaffold.
|
|
22
|
+
*/
|
|
23
|
+
import { join } from "path";
|
|
24
|
+
import { PROJECT_CONFIG_DISPLAY_NAME } from "./project-config.js";
|
|
25
|
+
/** Resolve the layout for this run. */
|
|
26
|
+
export function planInit(input) {
|
|
27
|
+
const adopting = Boolean(input.ancestorProjectRoot);
|
|
28
|
+
const projectRoot = adopting ? input.ancestorProjectRoot : input.targetDir;
|
|
29
|
+
const composed = adopting || input.platforms.length > 1;
|
|
30
|
+
// One client in an adopt run lands exactly where the user pointed the
|
|
31
|
+
// command; anything else gets a platform-named subdirectory, which is what
|
|
32
|
+
// makes `web/` and `ios/` siblings under one root.
|
|
33
|
+
const useSubdirectories = input.platforms.length > 1;
|
|
34
|
+
const clients = input.platforms.map((platform) => ({
|
|
35
|
+
platform,
|
|
36
|
+
dir: useSubdirectories ? join(input.targetDir, platform) : input.targetDir,
|
|
37
|
+
}));
|
|
38
|
+
const mode = adopting
|
|
39
|
+
? "add-client"
|
|
40
|
+
: input.platforms.length > 1
|
|
41
|
+
? "multi-client"
|
|
42
|
+
: "standalone";
|
|
43
|
+
return {
|
|
44
|
+
mode,
|
|
45
|
+
clients,
|
|
46
|
+
projectRoot,
|
|
47
|
+
writesProjectConfig: !adopting,
|
|
48
|
+
ownsApp: !adopting,
|
|
49
|
+
initsGit: !adopting,
|
|
50
|
+
canonicalSchemaPath: composed
|
|
51
|
+
? join(projectRoot, "models", "models.toml")
|
|
52
|
+
: null,
|
|
53
|
+
writesRootAgents: composed,
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Everything a run must be refused for, checked before any download, any API
|
|
58
|
+
* call and any write. Returns the user-facing message, or `null` when the run
|
|
59
|
+
* may proceed.
|
|
60
|
+
*/
|
|
61
|
+
export function checkInitGuards(input) {
|
|
62
|
+
const root = input.ancestorProjectRoot;
|
|
63
|
+
if (!root) {
|
|
64
|
+
// `add-client` describes adopting a project that is not there.
|
|
65
|
+
if (input.action === "add-client") {
|
|
66
|
+
return (`action = "add-client" adds a client to an existing Primitive app, but there is no ` +
|
|
67
|
+
`${PROJECT_CONFIG_DISPLAY_NAME} in this directory or any parent. ` +
|
|
68
|
+
`Run init from inside the app's repository, or use action = "create" to start a new app.`);
|
|
69
|
+
}
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
72
|
+
const envName = input.environmentName ?? "the selected environment";
|
|
73
|
+
// Creating a SECOND app inside a repository that already has one is the
|
|
74
|
+
// nesting this change removes.
|
|
75
|
+
if (input.action === "create") {
|
|
76
|
+
return (`action = "create" would create a second Primitive app inside the existing project at ${root}. ` +
|
|
77
|
+
`Use action = "add-client" to add this client to the app that project already targets.`);
|
|
78
|
+
}
|
|
79
|
+
if (!input.environmentAppId) {
|
|
80
|
+
return (`The "${envName}" environment in ${root}/${PROJECT_CONFIG_DISPLAY_NAME} has no appId, so there is no app to add this client to. ` +
|
|
81
|
+
`Set one with \`primitive env add <name> --api-url <url> --app-id <appId>\`, or select an environment that has one with \`primitive env use <name>\`.`);
|
|
82
|
+
}
|
|
83
|
+
// Naming an app explicitly is allowed only when it is the SAME app: a
|
|
84
|
+
// different one would wire this client to a backend the rest of the repo does
|
|
85
|
+
// not target.
|
|
86
|
+
const named = input.flagAppId ?? (input.action === "use-existing" ? input.configAppId : undefined);
|
|
87
|
+
if (named && named !== input.environmentAppId) {
|
|
88
|
+
const source = input.flagAppId ? "--use-existing-app-id" : '`app_id` (action = "use-existing")';
|
|
89
|
+
return (`${source} names app ${named}, but the "${envName}" environment of the project at ${root} targets app ${input.environmentAppId}. ` +
|
|
90
|
+
`A client added to this repository belongs to that app — drop the app id and use action = "add-client", ` +
|
|
91
|
+
`or run init outside this project to scaffold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AAI,KAAK,IAAI,KAAK,KAAK,KAAK,CAAC,gBAAgB,EAAE,CAAC;QAC9C,MAAM,MAAM,GAAG,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,uBAAuB,CAAC,CAAC,CAAC,oCAAoC,CAAC;QAChG,OAAO,CACL,GAAG,MAAM,cAAc,KAAK,cAAc,OAAO,mCAAmC,IAAI,gBAAgB,KAAK,CAAC,gBAAgB,IAAI;YAClI,yGAAyG;YACzG,8DAA8D,CAC/D,CAAC;IACJ,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which backend a scaffolded client's PRODUCTION build talks to (#2890).
|
|
3
|
+
*
|
|
4
|
+
* `init` used to write the hosted production URL into `.env.production`
|
|
5
|
+
* unconditionally, alongside the app ID of the app it had just created. On the
|
|
6
|
+
* hosted server those agree. On any other one — a self-hosted server, a staging
|
|
7
|
+
* server, an alpha channel — they do not: the production build points at a
|
|
8
|
+
* backend the app ID does not exist on, and the mismatch only shows up after a
|
|
9
|
+
* deploy.
|
|
10
|
+
*
|
|
11
|
+
* So a composed run derives the pair from the project's own environments
|
|
12
|
+
* instead, and only falls back to the old behavior where it was right anyway:
|
|
13
|
+
*
|
|
14
|
+
* 1. a `prod` environment, then a `production` one — the team already said
|
|
15
|
+
* which backend/app pair production means
|
|
16
|
+
* 2. otherwise, when this run targets the hosted production server, the
|
|
17
|
+
* hosted production URL with this app (today's output)
|
|
18
|
+
* 3. otherwise the selected environment's own server and app — one backend,
|
|
19
|
+
* one app, consistently
|
|
20
|
+
*
|
|
21
|
+
* Standalone runs keep calling the old path verbatim, so a single-client
|
|
22
|
+
* scaffold's output is unchanged (spec decision 1).
|
|
23
|
+
*/
|
|
24
|
+
export interface ProductionRuntime {
|
|
25
|
+
serverUrl: string;
|
|
26
|
+
appId: string;
|
|
27
|
+
appName?: string;
|
|
28
|
+
/** Which rule chose it, for the message init prints. */
|
|
29
|
+
source: "environment" | "hosted-production" | "selected";
|
|
30
|
+
/** The environment name, when one was used. */
|
|
31
|
+
environmentName?: string;
|
|
32
|
+
}
|
|
33
|
+
export interface ResolveProductionRuntimeInput {
|
|
34
|
+
/** The project's environments, keyed by name. */
|
|
35
|
+
environments?: Record<string, {
|
|
36
|
+
apiUrl?: string;
|
|
37
|
+
appId?: string;
|
|
38
|
+
appName?: string;
|
|
39
|
+
} | undefined>;
|
|
40
|
+
/** The server this run targets. */
|
|
41
|
+
selectedServerUrl: string;
|
|
42
|
+
/** The app this run scaffolds against. */
|
|
43
|
+
selectedAppId: string;
|
|
44
|
+
selectedAppName?: string;
|
|
45
|
+
/** The hosted production server URL. */
|
|
46
|
+
productionServerUrl: string;
|
|
47
|
+
}
|
|
48
|
+
export declare function resolveProductionRuntime(input: ResolveProductionRuntimeInput): ProductionRuntime;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which backend a scaffolded client's PRODUCTION build talks to (#2890).
|
|
3
|
+
*
|
|
4
|
+
* `init` used to write the hosted production URL into `.env.production`
|
|
5
|
+
* unconditionally, alongside the app ID of the app it had just created. On the
|
|
6
|
+
* hosted server those agree. On any other one — a self-hosted server, a staging
|
|
7
|
+
* server, an alpha channel — they do not: the production build points at a
|
|
8
|
+
* backend the app ID does not exist on, and the mismatch only shows up after a
|
|
9
|
+
* deploy.
|
|
10
|
+
*
|
|
11
|
+
* So a composed run derives the pair from the project's own environments
|
|
12
|
+
* instead, and only falls back to the old behavior where it was right anyway:
|
|
13
|
+
*
|
|
14
|
+
* 1. a `prod` environment, then a `production` one — the team already said
|
|
15
|
+
* which backend/app pair production means
|
|
16
|
+
* 2. otherwise, when this run targets the hosted production server, the
|
|
17
|
+
* hosted production URL with this app (today's output)
|
|
18
|
+
* 3. otherwise the selected environment's own server and app — one backend,
|
|
19
|
+
* one app, consistently
|
|
20
|
+
*
|
|
21
|
+
* Standalone runs keep calling the old path verbatim, so a single-client
|
|
22
|
+
* scaffold's output is unchanged (spec decision 1).
|
|
23
|
+
*/
|
|
24
|
+
/** Trailing-slash-insensitive comparison, as elsewhere in init. */
|
|
25
|
+
function sameServer(a, b) {
|
|
26
|
+
return a.replace(/\/+$/, "") === b.replace(/\/+$/, "");
|
|
27
|
+
}
|
|
28
|
+
export function resolveProductionRuntime(input) {
|
|
29
|
+
const environments = input.environments ?? {};
|
|
30
|
+
// `prod` first, deliberately: a repo with both names has one of them as the
|
|
31
|
+
// real one, and `prod` is what `primitive init` and the templates use.
|
|
32
|
+
for (const name of ["prod", "production"]) {
|
|
33
|
+
const env = environments[name];
|
|
34
|
+
if (env?.apiUrl && env?.appId) {
|
|
35
|
+
return {
|
|
36
|
+
serverUrl: env.apiUrl,
|
|
37
|
+
appId: env.appId,
|
|
38
|
+
appName: env.appName ?? input.selectedAppName,
|
|
39
|
+
source: "environment",
|
|
40
|
+
environmentName: name,
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
if (sameServer(input.selectedServerUrl, input.productionServerUrl)) {
|
|
45
|
+
return {
|
|
46
|
+
serverUrl: input.productionServerUrl,
|
|
47
|
+
appId: input.selectedAppId,
|
|
48
|
+
appName: input.selectedAppName,
|
|
49
|
+
source: "hosted-production",
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
return {
|
|
53
|
+
serverUrl: input.selectedServerUrl,
|
|
54
|
+
appId: input.selectedAppId,
|
|
55
|
+
appName: input.selectedAppName,
|
|
56
|
+
source: "selected",
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=init-production-env.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init-production-env.js","sourceRoot":"","sources":["../../../src/lib/init-production-env.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AA2BH,mEAAmE;AACnE,SAAS,UAAU,CAAC,CAAS,EAAE,CAAS;IACtC,OAAO,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;AACzD,CAAC;AAED,MAAM,UAAU,wBAAwB,CACtC,KAAoC;IAEpC,MAAM,YAAY,GAAG,KAAK,CAAC,YAAY,IAAI,EAAE,CAAC;IAC9C,4EAA4E;IAC5E,uEAAuE;IACvE,KAAK,MAAM,IAAI,IAAI,CAAC,MAAM,EAAE,YAAY,CAAC,EAAE,CAAC;QAC1C,MAAM,GAAG,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC;QAC/B,IAAI,GAAG,EAAE,MAAM,IAAI,GAAG,EAAE,KAAK,EAAE,CAAC;YAC9B,OAAO;gBACL,SAAS,EAAE,GAAG,CAAC,MAAM;gBACrB,KAAK,EAAE,GAAG,CAAC,KAAK;gBAChB,OAAO,EAAE,GAAG,CAAC,OAAO,IAAI,KAAK,CAAC,eAAe;gBAC7C,MAAM,EAAE,aAAa;gBACrB,eAAe,EAAE,IAAI;aACtB,CAAC;QACJ,CAAC;IACH,CAAC;IAED,IAAI,UAAU,CAAC,KAAK,CAAC,iBAAiB,EAAE,KAAK,CAAC,mBAAmB,CAAC,EAAE,CAAC;QACnE,OAAO;YACL,SAAS,EAAE,KAAK,CAAC,mBAAmB;YACpC,KAAK,EAAE,KAAK,CAAC,aAAa;YAC1B,OAAO,EAAE,KAAK,CAAC,eAAe;YAC9B,MAAM,EAAE,mBAAmB;SAC5B,CAAC;IACJ,CAAC;IAED,OAAO;QACL,SAAS,EAAE,KAAK,CAAC,iBAAiB;QAClC,KAAK,EAAE,KAAK,CAAC,aAAa;QAC1B,OAAO,EAAE,KAAK,CAAC,eAAe;QAC9B,MAAM,EAAE,UAAU;KACnB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import type { Platform } from "./resolve-platform.js";
|
|
2
|
+
/** The canonical schema's path, relative to the project root. */
|
|
3
|
+
export declare const CANONICAL_SCHEMA_RELATIVE: string;
|
|
4
|
+
/**
|
|
5
|
+
* A POSIX-style relative specifier from `fromDir` to `toFile`, always prefixed
|
|
6
|
+
* with `./` or `../` — what both an import specifier and a `-i` argument need.
|
|
7
|
+
*/
|
|
8
|
+
export declare function relativeSchemaPath(fromDir: string, toFile: string): string;
|
|
9
|
+
/**
|
|
10
|
+
* The schema a freshly installed client template ships, or null when it has
|
|
11
|
+
* none (the Swift starter is comment-only but the file is still there).
|
|
12
|
+
*/
|
|
13
|
+
export declare function findClientSchema(clientDir: string, platform: Platform): string | null;
|
|
14
|
+
/** The Swift target's source directory (`Sources/<AppName>`), if there is one. */
|
|
15
|
+
export declare function findSwiftTargetDir(clientDir: string): string | null;
|
|
16
|
+
/**
|
|
17
|
+
* The models a schema declares, in the order it declares them.
|
|
18
|
+
*
|
|
19
|
+
* `[models.<name>]`, `[models.<name>.fields.<field>]` and the array form all
|
|
20
|
+
* name the same model; the loader treats the first path segment after `models`
|
|
21
|
+
* as the model name, and so does this.
|
|
22
|
+
*/
|
|
23
|
+
export declare function declaredModelNames(toml: string): string[];
|
|
24
|
+
/**
|
|
25
|
+
* The app's one schema has to declare every model its clients read.
|
|
26
|
+
*
|
|
27
|
+
* A client's template ships both a starter schema and code generated from it —
|
|
28
|
+
* the web template's store reads `UserPref`, and the model generator refuses a
|
|
29
|
+
* schema with no models at all. So composing the shared schema is not "pick a
|
|
30
|
+
* starter": it is the base schema (an existing client's, when one is being
|
|
31
|
+
* promoted) PLUS every model a client being added declares and the base does
|
|
32
|
+
* not. Nothing is ever overwritten — a model the base already declares is the
|
|
33
|
+
* app's definition of it, and stays exactly as it is.
|
|
34
|
+
*/
|
|
35
|
+
export declare function composeSchemaContent(input: {
|
|
36
|
+
/** The schema the app already has, or the one being promoted to the root. */
|
|
37
|
+
base: string;
|
|
38
|
+
/** The starter schemas of the clients this run is adding. */
|
|
39
|
+
starters: string[];
|
|
40
|
+
}): {
|
|
41
|
+
content: string;
|
|
42
|
+
added: string[];
|
|
43
|
+
};
|
|
44
|
+
/** What `wireClientToSchema` actually rewrote, for the caller to report. */
|
|
45
|
+
export interface SchemaWiringResult {
|
|
46
|
+
/** Files rewritten or created so this client reads the shared schema. */
|
|
47
|
+
rewired: string[];
|
|
48
|
+
/** The client-local schema copy that was removed, if any. */
|
|
49
|
+
removed?: string;
|
|
50
|
+
/** Set when the client's shape was not recognized and nothing was rewired. */
|
|
51
|
+
error?: string;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Points one client at the shared schema and drops its own copy.
|
|
55
|
+
*
|
|
56
|
+
* Writes the new wiring BEFORE removing the client-local schema, so a failure
|
|
57
|
+
* leaves a client that still has a schema rather than one with neither.
|
|
58
|
+
*/
|
|
59
|
+
export declare function wireClientToSchema(clientDir: string, platform: Platform, schemaPath: string): SchemaWiringResult;
|
|
60
|
+
/**
|
|
61
|
+
* Why this client cannot be pointed at the shared schema, or null when it can.
|
|
62
|
+
*
|
|
63
|
+
* Separate from the wiring itself because the answer decides whether the run
|
|
64
|
+
* happens at all: a client that keeps its own schema while the app has another
|
|
65
|
+
* is the two-copies layout the shared schema exists to prevent, so a caller
|
|
66
|
+
* asks this BEFORE it writes the shared file — before the download, when the
|
|
67
|
+
* client already exists.
|
|
68
|
+
*/
|
|
69
|
+
export declare function checkClientWiring(clientDir: string, platform: Platform, schemaPath: string): string | null;
|
|
70
|
+
/**
|
|
71
|
+
* Writes the canonical schema, creating `models/` if needed. Never overwrites:
|
|
72
|
+
* an existing shared schema is the app's, not this run's.
|
|
73
|
+
*/
|
|
74
|
+
export declare function writeCanonicalSchema(schemaPath: string, content: string): boolean;
|