primitive-admin 1.1.0-alpha.4 → 1.1.0-alpha.40
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 +325 -31
- package/assets/skill/skills/primitive-platform/SKILL.md +281 -0
- package/dist/bin/primitive.d.ts +2 -0
- package/dist/bin/primitive.js +266 -16
- package/dist/bin/primitive.js.map +1 -1
- package/dist/src/commands/admins.d.ts +2 -0
- package/dist/src/commands/admins.js +123 -18
- package/dist/src/commands/admins.js.map +1 -1
- package/dist/src/commands/analytics.d.ts +2 -0
- package/dist/src/commands/analytics.js +464 -55
- package/dist/src/commands/analytics.js.map +1 -1
- package/dist/src/commands/apps.d.ts +2 -0
- package/dist/src/commands/apps.js +55 -13
- package/dist/src/commands/apps.js.map +1 -1
- package/dist/src/commands/auth.d.ts +2 -0
- package/dist/src/commands/auth.js +177 -7
- package/dist/src/commands/auth.js.map +1 -1
- package/dist/src/commands/blob-buckets.d.ts +2 -0
- package/dist/src/commands/blob-buckets.js +422 -0
- package/dist/src/commands/blob-buckets.js.map +1 -0
- package/dist/src/commands/catalog.d.ts +2 -0
- package/dist/src/commands/catalog.js +34 -35
- package/dist/src/commands/catalog.js.map +1 -1
- package/dist/src/commands/collection-type-configs.d.ts +2 -0
- package/dist/src/commands/collection-type-configs.js +178 -0
- package/dist/src/commands/collection-type-configs.js.map +1 -0
- package/dist/src/commands/collections.d.ts +2 -0
- package/dist/src/commands/collections.js +515 -0
- package/dist/src/commands/collections.js.map +1 -0
- package/dist/src/commands/comparisons.d.ts +2 -0
- package/dist/src/commands/comparisons.js +6 -6
- package/dist/src/commands/comparisons.js.map +1 -1
- package/dist/src/commands/cron-triggers.d.ts +2 -0
- package/dist/src/commands/cron-triggers.js +357 -0
- package/dist/src/commands/cron-triggers.js.map +1 -0
- package/dist/src/commands/database-types.d.ts +2 -0
- package/dist/src/commands/database-types.js +471 -0
- package/dist/src/commands/database-types.js.map +1 -0
- package/dist/src/commands/databases.d.ts +2 -0
- package/dist/src/commands/databases.js +1462 -83
- package/dist/src/commands/databases.js.map +1 -1
- package/dist/src/commands/documents.d.ts +2 -0
- package/dist/src/commands/documents.js +518 -11
- package/dist/src/commands/documents.js.map +1 -1
- package/dist/src/commands/email-templates.d.ts +2 -0
- package/dist/src/commands/email-templates.js +281 -0
- package/dist/src/commands/email-templates.js.map +1 -0
- package/dist/src/commands/env.d.ts +12 -0
- package/dist/src/commands/env.js +260 -0
- package/dist/src/commands/env.js.map +1 -0
- package/dist/src/commands/group-type-configs.d.ts +2 -0
- package/dist/src/commands/group-type-configs.js +181 -0
- package/dist/src/commands/group-type-configs.js.map +1 -0
- package/dist/src/commands/groups.d.ts +2 -0
- package/dist/src/commands/groups.js +45 -43
- package/dist/src/commands/groups.js.map +1 -1
- package/dist/src/commands/guides.d.ts +159 -0
- package/dist/src/commands/guides.js +449 -35
- package/dist/src/commands/guides.js.map +1 -1
- package/dist/src/commands/init.d.ts +17 -0
- package/dist/src/commands/init.js +811 -201
- package/dist/src/commands/init.js.map +1 -1
- package/dist/src/commands/integrations.d.ts +2 -0
- package/dist/src/commands/integrations.js +533 -46
- package/dist/src/commands/integrations.js.map +1 -1
- package/dist/src/commands/llm.d.ts +2 -0
- package/dist/src/commands/llm.js +4 -2
- package/dist/src/commands/llm.js.map +1 -1
- package/dist/src/commands/prompts.d.ts +2 -0
- package/dist/src/commands/prompts.js +50 -52
- package/dist/src/commands/prompts.js.map +1 -1
- package/dist/src/commands/rule-sets.d.ts +3 -0
- package/dist/src/commands/rule-sets.js +388 -0
- package/dist/src/commands/rule-sets.js.map +1 -0
- package/dist/src/commands/scripts.d.ts +2 -0
- package/dist/src/commands/scripts.js +667 -0
- package/dist/src/commands/scripts.js.map +1 -0
- package/dist/src/commands/secrets.d.ts +2 -0
- package/dist/src/commands/secrets.js +108 -0
- package/dist/src/commands/secrets.js.map +1 -0
- package/dist/src/commands/skill.d.ts +2 -0
- package/dist/src/commands/skill.js +29 -0
- package/dist/src/commands/skill.js.map +1 -0
- package/dist/src/commands/sync.d.ts +174 -0
- package/dist/src/commands/sync.js +4392 -235
- package/dist/src/commands/sync.js.map +1 -1
- package/dist/src/commands/tokens.d.ts +2 -0
- package/dist/src/commands/tokens.js +122 -19
- package/dist/src/commands/tokens.js.map +1 -1
- package/dist/src/commands/users.d.ts +2 -0
- package/dist/src/commands/users.js +440 -22
- package/dist/src/commands/users.js.map +1 -1
- package/dist/src/commands/waitlist.d.ts +2 -0
- package/dist/src/commands/waitlist.js +10 -10
- package/dist/src/commands/waitlist.js.map +1 -1
- package/dist/src/commands/webhooks.d.ts +2 -0
- package/dist/src/commands/webhooks.js +391 -0
- package/dist/src/commands/webhooks.js.map +1 -0
- package/dist/src/commands/workflows.d.ts +49 -0
- package/dist/src/commands/workflows.js +1009 -123
- package/dist/src/commands/workflows.js.map +1 -1
- package/dist/src/lib/api-client.d.ts +1272 -0
- package/dist/src/lib/api-client.js +1115 -83
- package/dist/src/lib/api-client.js.map +1 -1
- package/dist/src/lib/auth-flow.d.ts +8 -0
- package/dist/src/lib/block-layout.d.ts +160 -0
- package/dist/src/lib/block-layout.js +451 -0
- package/dist/src/lib/block-layout.js.map +1 -0
- package/dist/src/lib/cli-manifest.d.ts +60 -0
- package/dist/src/lib/cli-manifest.js +70 -0
- package/dist/src/lib/cli-manifest.js.map +1 -0
- package/dist/src/lib/config.d.ts +53 -0
- package/dist/src/lib/config.js +92 -53
- package/dist/src/lib/config.js.map +1 -1
- package/dist/src/lib/confirm-prompt.d.ts +83 -0
- package/dist/src/lib/confirm-prompt.js +110 -0
- package/dist/src/lib/confirm-prompt.js.map +1 -0
- package/dist/src/lib/constants.d.ts +2 -0
- package/dist/src/lib/constants.js +3 -0
- package/dist/src/lib/constants.js.map +1 -0
- package/dist/src/lib/crash-handlers.d.ts +20 -0
- package/dist/src/lib/crash-handlers.js +49 -0
- package/dist/src/lib/crash-handlers.js.map +1 -0
- package/dist/src/lib/credentials-store.d.ts +79 -0
- package/dist/src/lib/credentials-store.js +307 -0
- package/dist/src/lib/credentials-store.js.map +1 -0
- package/dist/src/lib/csv.d.ts +48 -0
- package/dist/src/lib/csv.js +177 -0
- package/dist/src/lib/csv.js.map +1 -0
- package/dist/src/lib/db-codegen/dbFingerprint.d.ts +10 -0
- package/dist/src/lib/db-codegen/dbFingerprint.js +17 -0
- package/dist/src/lib/db-codegen/dbFingerprint.js.map +1 -0
- package/dist/src/lib/db-codegen/dbGenerator.d.ts +111 -0
- package/dist/src/lib/db-codegen/dbGenerator.js +371 -0
- package/dist/src/lib/db-codegen/dbGenerator.js.map +1 -0
- package/dist/src/lib/db-codegen/dbNaming.d.ts +45 -0
- package/dist/src/lib/db-codegen/dbNaming.js +104 -0
- package/dist/src/lib/db-codegen/dbNaming.js.map +1 -0
- package/dist/src/lib/db-codegen/dbTemplates.d.ts +97 -0
- package/dist/src/lib/db-codegen/dbTemplates.js +159 -0
- package/dist/src/lib/db-codegen/dbTemplates.js.map +1 -0
- package/dist/src/lib/db-codegen/dbTsTypes.d.ts +78 -0
- package/dist/src/lib/db-codegen/dbTsTypes.js +112 -0
- package/dist/src/lib/db-codegen/dbTsTypes.js.map +1 -0
- package/dist/src/lib/env-resolver.d.ts +62 -0
- package/dist/src/lib/env-resolver.js +121 -0
- package/dist/src/lib/env-resolver.js.map +1 -0
- package/dist/src/lib/fetch.d.ts +5 -0
- package/dist/src/lib/generated-allowlist.d.ts +28 -0
- package/dist/src/lib/generated-allowlist.js +213 -0
- package/dist/src/lib/generated-allowlist.js.map +1 -0
- package/dist/src/lib/init-config.d.ts +59 -0
- package/dist/src/lib/init-config.js +113 -0
- package/dist/src/lib/init-config.js.map +1 -0
- package/dist/src/lib/migration-nag.d.ts +49 -0
- package/dist/src/lib/migration-nag.js +163 -0
- package/dist/src/lib/migration-nag.js.map +1 -0
- package/dist/src/lib/output.d.ts +86 -0
- package/dist/src/lib/output.js +150 -8
- package/dist/src/lib/output.js.map +1 -1
- package/dist/src/lib/paginate.d.ts +33 -0
- package/dist/src/lib/paginate.js +42 -0
- package/dist/src/lib/paginate.js.map +1 -0
- package/dist/src/lib/project-config.d.ts +97 -0
- package/dist/src/lib/project-config.js +209 -0
- package/dist/src/lib/project-config.js.map +1 -0
- package/dist/src/lib/query-operators.d.ts +43 -0
- package/dist/src/lib/query-operators.js +80 -0
- package/dist/src/lib/query-operators.js.map +1 -0
- package/dist/src/lib/refresh-admin-credentials.d.ts +65 -0
- package/dist/src/lib/refresh-admin-credentials.js +103 -0
- package/dist/src/lib/refresh-admin-credentials.js.map +1 -0
- package/dist/src/lib/resolve-platform.d.ts +45 -0
- package/dist/src/lib/resolve-platform.js +43 -0
- package/dist/src/lib/resolve-platform.js.map +1 -0
- package/dist/src/lib/skill-installer.d.ts +23 -0
- package/dist/src/lib/skill-installer.js +135 -0
- package/dist/src/lib/skill-installer.js.map +1 -0
- package/dist/src/lib/snapshots.d.ts +99 -0
- package/dist/src/lib/snapshots.js +357 -0
- package/dist/src/lib/snapshots.js.map +1 -0
- package/dist/src/lib/sync-paths.d.ts +72 -0
- package/dist/src/lib/sync-paths.js +130 -0
- package/dist/src/lib/sync-paths.js.map +1 -0
- package/dist/src/lib/template.d.ts +97 -0
- package/dist/src/lib/template.js +336 -62
- package/dist/src/lib/template.js.map +1 -1
- package/dist/src/lib/token-inject.d.ts +56 -0
- package/dist/src/lib/token-inject.js +204 -0
- package/dist/src/lib/token-inject.js.map +1 -0
- package/dist/src/lib/toml-database-config.d.ts +152 -0
- package/dist/src/lib/toml-database-config.js +600 -0
- package/dist/src/lib/toml-database-config.js.map +1 -0
- package/dist/src/lib/toml-metadata-config.d.ts +108 -0
- package/dist/src/lib/toml-metadata-config.js +371 -0
- package/dist/src/lib/toml-metadata-config.js.map +1 -0
- package/dist/src/lib/toml-params-validator.d.ts +129 -0
- package/dist/src/lib/toml-params-validator.js +298 -0
- package/dist/src/lib/toml-params-validator.js.map +1 -0
- package/dist/src/lib/version-check.d.ts +10 -0
- package/dist/src/lib/version-check.js +172 -0
- package/dist/src/lib/version-check.js.map +1 -0
- package/dist/src/lib/workflow-apply.d.ts +66 -0
- package/dist/src/lib/workflow-apply.js +117 -0
- package/dist/src/lib/workflow-apply.js.map +1 -0
- package/dist/src/lib/workflow-fragments.d.ts +41 -0
- package/dist/src/lib/workflow-fragments.js +121 -0
- package/dist/src/lib/workflow-fragments.js.map +1 -0
- package/dist/src/lib/workflow-toml-validator.d.ts +95 -0
- package/dist/src/lib/workflow-toml-validator.js +323 -0
- package/dist/src/lib/workflow-toml-validator.js.map +1 -0
- package/dist/src/types/index.d.ts +520 -0
- package/dist/src/validators.d.ts +64 -0
- package/dist/src/validators.js +63 -0
- package/dist/src/validators.js.map +1 -0
- package/package.json +18 -4
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sync data path resolution.
|
|
3
|
+
*
|
|
4
|
+
* Per issue #373, sync state is scoped by environment AND by app:
|
|
5
|
+
*
|
|
6
|
+
* <projectRoot>/.primitive/sync/<env>/<appId>/
|
|
7
|
+
*
|
|
8
|
+
* This ensures that switching environments (dev -> prod) or apps never
|
|
9
|
+
* clobbers sync state from another slot. Push to dev and then to prod
|
|
10
|
+
* see independent "last synced" pointers, so prod won't falsely believe
|
|
11
|
+
* dev's changes are already in sync.
|
|
12
|
+
*
|
|
13
|
+
* When the user still passes `--dir <path>` (the legacy flag) we honor
|
|
14
|
+
* it and store sync state inside that directory, same as before. This
|
|
15
|
+
* keeps pre-project-config workflows working.
|
|
16
|
+
*/
|
|
17
|
+
export interface ResolveSyncDirOptions {
|
|
18
|
+
/** The resolved app ID for this sync operation. */
|
|
19
|
+
appId: string;
|
|
20
|
+
/**
|
|
21
|
+
* If the user passed `--dir <path>` on the command line, forward it
|
|
22
|
+
* here. Explicit user input always wins.
|
|
23
|
+
*/
|
|
24
|
+
userDir?: string;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Returns the directory that should hold TOML files + sync state for the
|
|
28
|
+
* current sync operation.
|
|
29
|
+
*
|
|
30
|
+
* Resolution order:
|
|
31
|
+
* 1. If userDir is set, return it as-is (legacy behavior).
|
|
32
|
+
* 2. If we're in project mode, return
|
|
33
|
+
* <projectRoot>/.primitive/sync/<env>/<appId>
|
|
34
|
+
* 3. Otherwise fall back to "./config" (the old default).
|
|
35
|
+
*/
|
|
36
|
+
export declare function resolveSyncDir(options: ResolveSyncDirOptions): string;
|
|
37
|
+
/**
|
|
38
|
+
* Returns the snapshot-backups root for the slot a given sync operation
|
|
39
|
+
* belongs to (issue #578, Phase 1). Snapshots reuse the SAME resolution chain
|
|
40
|
+
* as `resolveSyncDir` (the resolved `ResolvedEnvironment` + `safeEnv()`), so
|
|
41
|
+
* the backup tree can never drift from the live sync tree — there is no
|
|
42
|
+
* parallel `{projectRoot, env, appId}` mini-model.
|
|
43
|
+
*
|
|
44
|
+
* Resolution order mirrors `resolveSyncDir`:
|
|
45
|
+
* 1. If userDir (legacy `--dir`) is set, snapshots live in a sibling
|
|
46
|
+
* `<userDir>/.snapshots/` so revert works without a project root
|
|
47
|
+
* (Fork 4 — designed explicitly).
|
|
48
|
+
* 2. In project mode, the project sibling
|
|
49
|
+
* `<projectRoot>/.primitive/sync-backups/<env>/<appId>/`.
|
|
50
|
+
* 3. Otherwise (bare `./config` legacy default), `./config-snapshots`.
|
|
51
|
+
*/
|
|
52
|
+
export declare function resolveSnapshotsRoot(options: ResolveSyncDirOptions): string;
|
|
53
|
+
export declare function assertSafePathComponent(value: string, label: string): void;
|
|
54
|
+
/**
|
|
55
|
+
* Returns true if the path we'd use for sync data is the auto-resolved
|
|
56
|
+
* project-mode path (vs. a user-supplied --dir).
|
|
57
|
+
*/
|
|
58
|
+
export declare function isAutoResolvedSyncDir(userDir: string | undefined): boolean;
|
|
59
|
+
/**
|
|
60
|
+
* Ensures the sync directory exists, creating it (and parents) if
|
|
61
|
+
* necessary. Returns the path.
|
|
62
|
+
*/
|
|
63
|
+
export declare function ensureSyncDir(options: ResolveSyncDirOptions): string;
|
|
64
|
+
/**
|
|
65
|
+
* Checks whether an old-style sync state file exists at `./config/.primitive-sync.json`
|
|
66
|
+
* (the pre-project-config default path). Returns a warning message if found and
|
|
67
|
+
* the current operation is using a different (project-mode) path, or null otherwise.
|
|
68
|
+
*
|
|
69
|
+
* Callers can display this once at the start of sync commands so users know
|
|
70
|
+
* their old sync data won't be picked up automatically.
|
|
71
|
+
*/
|
|
72
|
+
export declare function checkLegacySyncMigration(currentSyncDir: string): string | null;
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sync data path resolution.
|
|
3
|
+
*
|
|
4
|
+
* Per issue #373, sync state is scoped by environment AND by app:
|
|
5
|
+
*
|
|
6
|
+
* <projectRoot>/.primitive/sync/<env>/<appId>/
|
|
7
|
+
*
|
|
8
|
+
* This ensures that switching environments (dev -> prod) or apps never
|
|
9
|
+
* clobbers sync state from another slot. Push to dev and then to prod
|
|
10
|
+
* see independent "last synced" pointers, so prod won't falsely believe
|
|
11
|
+
* dev's changes are already in sync.
|
|
12
|
+
*
|
|
13
|
+
* When the user still passes `--dir <path>` (the legacy flag) we honor
|
|
14
|
+
* it and store sync state inside that directory, same as before. This
|
|
15
|
+
* keeps pre-project-config workflows working.
|
|
16
|
+
*/
|
|
17
|
+
import { existsSync, mkdirSync } from "fs";
|
|
18
|
+
import { join } from "path";
|
|
19
|
+
import { getCurrentEnvironment } from "./env-resolver.js";
|
|
20
|
+
/**
|
|
21
|
+
* Returns the directory that should hold TOML files + sync state for the
|
|
22
|
+
* current sync operation.
|
|
23
|
+
*
|
|
24
|
+
* Resolution order:
|
|
25
|
+
* 1. If userDir is set, return it as-is (legacy behavior).
|
|
26
|
+
* 2. If we're in project mode, return
|
|
27
|
+
* <projectRoot>/.primitive/sync/<env>/<appId>
|
|
28
|
+
* 3. Otherwise fall back to "./config" (the old default).
|
|
29
|
+
*/
|
|
30
|
+
export function resolveSyncDir(options) {
|
|
31
|
+
if (options.userDir)
|
|
32
|
+
return options.userDir;
|
|
33
|
+
const env = safeEnv();
|
|
34
|
+
if (env) {
|
|
35
|
+
// Defence-in-depth: appId is expected to be a ULID from the server, but
|
|
36
|
+
// we must never trust it blindly when building file-system paths. Reject
|
|
37
|
+
// anything that contains path separators or `..` sequences before
|
|
38
|
+
// joining it into <projectRoot>/.primitive/sync/...
|
|
39
|
+
assertSafePathComponent(options.appId, "appId");
|
|
40
|
+
return join(env.projectRoot, ".primitive", "sync", env.name, options.appId);
|
|
41
|
+
}
|
|
42
|
+
return "./config";
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Returns the snapshot-backups root for the slot a given sync operation
|
|
46
|
+
* belongs to (issue #578, Phase 1). Snapshots reuse the SAME resolution chain
|
|
47
|
+
* as `resolveSyncDir` (the resolved `ResolvedEnvironment` + `safeEnv()`), so
|
|
48
|
+
* the backup tree can never drift from the live sync tree — there is no
|
|
49
|
+
* parallel `{projectRoot, env, appId}` mini-model.
|
|
50
|
+
*
|
|
51
|
+
* Resolution order mirrors `resolveSyncDir`:
|
|
52
|
+
* 1. If userDir (legacy `--dir`) is set, snapshots live in a sibling
|
|
53
|
+
* `<userDir>/.snapshots/` so revert works without a project root
|
|
54
|
+
* (Fork 4 — designed explicitly).
|
|
55
|
+
* 2. In project mode, the project sibling
|
|
56
|
+
* `<projectRoot>/.primitive/sync-backups/<env>/<appId>/`.
|
|
57
|
+
* 3. Otherwise (bare `./config` legacy default), `./config-snapshots`.
|
|
58
|
+
*/
|
|
59
|
+
export function resolveSnapshotsRoot(options) {
|
|
60
|
+
if (options.userDir) {
|
|
61
|
+
return join(options.userDir, ".snapshots");
|
|
62
|
+
}
|
|
63
|
+
const env = safeEnv();
|
|
64
|
+
if (env) {
|
|
65
|
+
// Same defence-in-depth as resolveSyncDir: never trust appId blindly when
|
|
66
|
+
// building a file-system path.
|
|
67
|
+
assertSafePathComponent(options.appId, "appId");
|
|
68
|
+
return join(env.projectRoot, ".primitive", "sync-backups", env.name, options.appId);
|
|
69
|
+
}
|
|
70
|
+
return "./config-snapshots";
|
|
71
|
+
}
|
|
72
|
+
export function assertSafePathComponent(value, label) {
|
|
73
|
+
if (typeof value !== "string" ||
|
|
74
|
+
value.length === 0 ||
|
|
75
|
+
/[\\/]/.test(value) ||
|
|
76
|
+
value.includes("..") ||
|
|
77
|
+
value === "." ||
|
|
78
|
+
value === "") {
|
|
79
|
+
throw new Error(`Invalid ${label} for file path: ${value}`);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Returns true if the path we'd use for sync data is the auto-resolved
|
|
84
|
+
* project-mode path (vs. a user-supplied --dir).
|
|
85
|
+
*/
|
|
86
|
+
export function isAutoResolvedSyncDir(userDir) {
|
|
87
|
+
if (userDir)
|
|
88
|
+
return false;
|
|
89
|
+
return safeEnv() !== null;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Ensures the sync directory exists, creating it (and parents) if
|
|
93
|
+
* necessary. Returns the path.
|
|
94
|
+
*/
|
|
95
|
+
export function ensureSyncDir(options) {
|
|
96
|
+
const dir = resolveSyncDir(options);
|
|
97
|
+
if (!existsSync(dir)) {
|
|
98
|
+
mkdirSync(dir, { recursive: true });
|
|
99
|
+
}
|
|
100
|
+
return dir;
|
|
101
|
+
}
|
|
102
|
+
function safeEnv() {
|
|
103
|
+
try {
|
|
104
|
+
return getCurrentEnvironment();
|
|
105
|
+
}
|
|
106
|
+
catch {
|
|
107
|
+
return null;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Checks whether an old-style sync state file exists at `./config/.primitive-sync.json`
|
|
112
|
+
* (the pre-project-config default path). Returns a warning message if found and
|
|
113
|
+
* the current operation is using a different (project-mode) path, or null otherwise.
|
|
114
|
+
*
|
|
115
|
+
* Callers can display this once at the start of sync commands so users know
|
|
116
|
+
* their old sync data won't be picked up automatically.
|
|
117
|
+
*/
|
|
118
|
+
export function checkLegacySyncMigration(currentSyncDir) {
|
|
119
|
+
const legacySync = join(".", "config", ".primitive-sync.json");
|
|
120
|
+
if (!existsSync(legacySync))
|
|
121
|
+
return null;
|
|
122
|
+
// Only warn if the resolved dir is different from the legacy default.
|
|
123
|
+
const legacyDir = join(".", "config");
|
|
124
|
+
if (currentSyncDir === legacyDir)
|
|
125
|
+
return null;
|
|
126
|
+
return (`Detected old sync state at ./config/.primitive-sync.json. ` +
|
|
127
|
+
`Sync data now lives at ${currentSyncDir}. ` +
|
|
128
|
+
`Run 'primitive sync pull' to re-sync into the new location.`);
|
|
129
|
+
}
|
|
130
|
+
//# sourceMappingURL=sync-paths.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sync-paths.js","sourceRoot":"","sources":["../../../src/lib/sync-paths.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
declare const IOS_TEMPLATE_URL = "https://api.github.com/repos/Primitive-Labs/primitive-ios-template/tarball/main";
|
|
2
|
+
export interface PrepareTemplateOptions {
|
|
3
|
+
templateUrl?: string;
|
|
4
|
+
onProgress?: (status: string) => void;
|
|
5
|
+
}
|
|
6
|
+
export interface PreparedTemplate {
|
|
7
|
+
install(targetDir: string): void;
|
|
8
|
+
cleanup(): void;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Check if a directory is empty.
|
|
12
|
+
*/
|
|
13
|
+
export declare function isDirectoryEmpty(dir: string): boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Downloads and validates the Primitive app template in a temporary staging
|
|
16
|
+
* directory. Nothing is written to the final target directory until install()
|
|
17
|
+
* is called.
|
|
18
|
+
*/
|
|
19
|
+
export declare function prepareTemplate(options?: PrepareTemplateOptions): Promise<PreparedTemplate>;
|
|
20
|
+
export interface UpdateEnvResult {
|
|
21
|
+
envUpdated: boolean;
|
|
22
|
+
envProductionUpdated: boolean;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Updates .env and .env.production files with the app ID and server URLs.
|
|
26
|
+
* For .env, if it doesn't exist but .env.example does, copies from example first.
|
|
27
|
+
* Returns information about which files were updated.
|
|
28
|
+
*/
|
|
29
|
+
export declare function updateEnvFile(targetDir: string, appId: string, serverUrl: string, appName?: string): UpdateEnvResult;
|
|
30
|
+
/**
|
|
31
|
+
* Runs pnpm install in the target directory.
|
|
32
|
+
* Uses npx to ensure corepack/packageManager compatibility.
|
|
33
|
+
*/
|
|
34
|
+
export declare function runPnpmInstall(targetDir: string): Promise<void>;
|
|
35
|
+
/**
|
|
36
|
+
* Checks if pnpm is installed globally.
|
|
37
|
+
*/
|
|
38
|
+
export declare function isPnpmInstalled(): Promise<boolean>;
|
|
39
|
+
/**
|
|
40
|
+
* Installs pnpm globally using npm.
|
|
41
|
+
*/
|
|
42
|
+
export declare function installPnpmGlobally(): Promise<void>;
|
|
43
|
+
/**
|
|
44
|
+
* Checks if the primitive CLI is installed and available in PATH.
|
|
45
|
+
* Checks for the `primitive` command directly, which covers installs via
|
|
46
|
+
* npm, pnpm, yarn, or any other package manager.
|
|
47
|
+
*/
|
|
48
|
+
export declare function isPrimitiveCliInstalled(): Promise<boolean>;
|
|
49
|
+
export declare function gitInitRepo(targetDir: string): Promise<void>;
|
|
50
|
+
export declare function gitInitialCommit(targetDir: string): Promise<void>;
|
|
51
|
+
/**
|
|
52
|
+
* Checks whether a TCP port is currently in use on localhost.
|
|
53
|
+
* Tries both IPv4 (127.0.0.1) and IPv6 (::1) since a server may only
|
|
54
|
+
* bind to one address family.
|
|
55
|
+
*/
|
|
56
|
+
export declare function isPortFree(port: number): Promise<boolean>;
|
|
57
|
+
/**
|
|
58
|
+
* Pins the dev server port in vite.config.{ts,js,mts,mjs} by injecting or
|
|
59
|
+
* updating the `server.port` field. Returns true if a config file was found
|
|
60
|
+
* and patched.
|
|
61
|
+
*/
|
|
62
|
+
export declare function updateViteConfig(targetDir: string, port: number): boolean;
|
|
63
|
+
/**
|
|
64
|
+
* Updates port-sensitive env vars (VITE_OAUTH_REDIRECT_URI, VITE_BASE_URL)
|
|
65
|
+
* in the project's .env file to point at the given localhost port.
|
|
66
|
+
*/
|
|
67
|
+
export declare function updateEnvPort(targetDir: string, port: number): void;
|
|
68
|
+
/**
|
|
69
|
+
* Starting from `startPort` (default 5173), finds the first free port and
|
|
70
|
+
* returns which ports were already occupied and which port vite will bind to.
|
|
71
|
+
* `exhausted` is true when all checked ports were occupied and the returned
|
|
72
|
+
* port is a best-guess beyond the checked range.
|
|
73
|
+
*/
|
|
74
|
+
export declare function findDevPort(startPort?: number, maxChecks?: number): Promise<{
|
|
75
|
+
availablePort: number;
|
|
76
|
+
takenPorts: number[];
|
|
77
|
+
exhausted: boolean;
|
|
78
|
+
}>;
|
|
79
|
+
export { IOS_TEMPLATE_URL };
|
|
80
|
+
/**
|
|
81
|
+
* Updates primitive.json in the iOS template with app ID, server URL, and app name.
|
|
82
|
+
* Replaces __PRIMITIVE_*__ placeholder values.
|
|
83
|
+
* Returns true if the file was found and updated.
|
|
84
|
+
*/
|
|
85
|
+
export declare function updatePrimitiveJson(targetDir: string, appId: string, serverUrl: string, appName?: string): boolean;
|
|
86
|
+
/**
|
|
87
|
+
* Checks if Xcode command-line tools are installed.
|
|
88
|
+
*/
|
|
89
|
+
export declare function isXcodeInstalled(): Promise<boolean>;
|
|
90
|
+
/**
|
|
91
|
+
* Runs `swift package resolve` in the target directory to download SPM dependencies.
|
|
92
|
+
*/
|
|
93
|
+
export declare function runSwiftPackageResolve(targetDir: string): Promise<void>;
|
|
94
|
+
/**
|
|
95
|
+
* Installs the primitive CLI (primitive-admin) globally using npm.
|
|
96
|
+
*/
|
|
97
|
+
export declare function installPrimitiveCli(): Promise<void>;
|