primitive-admin 1.1.0-alpha.74 → 1.1.0-alpha.75
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/dist/bin/primitive.js +12 -11
- package/dist/bin/primitive.js.map +1 -1
- package/dist/src/commands/collection-type-configs.js +1 -1
- package/dist/src/commands/collection-type-configs.js.map +1 -1
- package/dist/src/commands/config.js +8 -4
- package/dist/src/commands/config.js.map +1 -1
- package/dist/src/commands/database-type-configs.js +1 -1
- package/dist/src/commands/database-type-configs.js.map +1 -1
- package/dist/src/commands/databases.js +25 -31
- package/dist/src/commands/databases.js.map +1 -1
- package/dist/src/commands/documents.js +9 -24
- package/dist/src/commands/documents.js.map +1 -1
- package/dist/src/commands/env.d.ts +1 -1
- package/dist/src/commands/env.js +14 -11
- package/dist/src/commands/env.js.map +1 -1
- package/dist/src/commands/functions.js +135 -1
- package/dist/src/commands/functions.js.map +1 -1
- package/dist/src/commands/groups.js +1 -1
- package/dist/src/commands/groups.js.map +1 -1
- package/dist/src/commands/init.d.ts +12 -15
- package/dist/src/commands/init.js +36 -77
- package/dist/src/commands/init.js.map +1 -1
- package/dist/src/commands/rule-sets.js +1 -1
- package/dist/src/commands/rule-sets.js.map +1 -1
- package/dist/src/commands/scripts.js +17 -4
- package/dist/src/commands/scripts.js.map +1 -1
- package/dist/src/commands/sync-app-settings.js +2 -4
- package/dist/src/commands/sync-app-settings.js.map +1 -1
- package/dist/src/commands/sync.d.ts +2 -2
- package/dist/src/commands/sync.js +544 -346
- package/dist/src/commands/sync.js.map +1 -1
- package/dist/src/commands/workflows.js +1 -1
- package/dist/src/lib/api-client.d.ts +7 -1
- package/dist/src/lib/api-client.js +8 -2
- package/dist/src/lib/api-client.js.map +1 -1
- package/dist/src/lib/app-match-guard.d.ts +44 -0
- package/dist/src/lib/app-match-guard.js +72 -0
- package/dist/src/lib/app-match-guard.js.map +1 -0
- package/dist/src/lib/codegen-shared/resolveCodegenSourceDir.d.ts +11 -8
- package/dist/src/lib/codegen-shared/resolveCodegenSourceDir.js +108 -54
- package/dist/src/lib/codegen-shared/resolveCodegenSourceDir.js.map +1 -1
- package/dist/src/lib/config.d.ts +2 -2
- package/dist/src/lib/config.js +2 -2
- package/dist/src/lib/credentials-store.d.ts +3 -3
- package/dist/src/lib/credentials-store.js +3 -3
- package/dist/src/lib/credentials-store.js.map +1 -1
- package/dist/src/lib/document-export-permissions.d.ts +30 -0
- package/dist/src/lib/document-export-permissions.js +54 -0
- package/dist/src/lib/document-export-permissions.js.map +1 -0
- package/dist/src/lib/env-resolver-core.d.ts +41 -9
- package/dist/src/lib/env-resolver-core.js +84 -13
- package/dist/src/lib/env-resolver-core.js.map +1 -1
- package/dist/src/lib/env-resolver.d.ts +3 -3
- package/dist/src/lib/env-resolver.js +2 -2
- package/dist/src/lib/function-bundle.d.ts +11 -1
- package/dist/src/lib/function-bundle.js +13 -1
- package/dist/src/lib/function-bundle.js.map +1 -1
- package/dist/src/lib/function-collect.d.ts +101 -0
- package/dist/src/lib/function-collect.js +339 -0
- package/dist/src/lib/function-collect.js.map +1 -0
- package/dist/src/lib/function-db-types.d.ts +149 -0
- package/dist/src/lib/function-db-types.js +587 -0
- package/dist/src/lib/function-db-types.js.map +1 -0
- package/dist/src/lib/function-grants-preflight.d.ts +118 -0
- package/dist/src/lib/function-grants-preflight.js +213 -0
- package/dist/src/lib/function-grants-preflight.js.map +1 -0
- package/dist/src/lib/function-sync.d.ts +34 -0
- package/dist/src/lib/function-sync.js +103 -0
- package/dist/src/lib/function-sync.js.map +1 -1
- package/dist/src/lib/generated-config-surfaces.d.ts +388 -0
- package/dist/src/lib/generated-config-surfaces.js +757 -7
- package/dist/src/lib/generated-config-surfaces.js.map +1 -1
- package/dist/src/lib/generated-sdk-types.d.ts +12 -0
- package/dist/src/lib/generated-sdk-types.js +13 -0
- package/dist/src/lib/generated-sdk-types.js.map +1 -0
- package/dist/src/lib/init-adopt.js +2 -2
- package/dist/src/lib/init-adopt.js.map +1 -1
- package/dist/src/lib/init-assets.js +3 -3
- package/dist/src/lib/init-config.d.ts +1 -1
- package/dist/src/lib/init-ios-links.js +1 -1
- package/dist/src/lib/init-ios-links.js.map +1 -1
- package/dist/src/lib/init-plan.d.ts +1 -1
- package/dist/src/lib/init-plan.js +1 -1
- package/dist/src/lib/init-xcode.d.ts +2 -2
- package/dist/src/lib/init-xcode.js +6 -5
- package/dist/src/lib/init-xcode.js.map +1 -1
- package/dist/src/lib/local-state.d.ts +1 -1
- package/dist/src/lib/local-state.js +1 -1
- package/dist/src/lib/local-test-cases.d.ts +1 -1
- package/dist/src/lib/local-test-cases.js +2 -1
- package/dist/src/lib/local-test-cases.js.map +1 -1
- package/dist/src/lib/migration-nag.d.ts +2 -2
- package/dist/src/lib/migration-nag.js +4 -3
- package/dist/src/lib/migration-nag.js.map +1 -1
- package/dist/src/lib/project-config.d.ts +23 -20
- package/dist/src/lib/project-config.js +27 -45
- package/dist/src/lib/project-config.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/generator.d.ts +1 -1
- package/dist/src/lib/swift-codegen/generator.js +1 -1
- package/dist/src/lib/sync-dir-selector.d.ts +1 -1
- package/dist/src/lib/sync-dir-selector.js +1 -1
- package/dist/src/lib/sync-paths.d.ts +52 -16
- package/dist/src/lib/sync-paths.js +68 -22
- package/dist/src/lib/sync-paths.js.map +1 -1
- package/dist/src/lib/sync-resource-types.d.ts +2 -2
- package/dist/src/lib/sync-resource-types.js +2 -2
- package/dist/src/lib/template.d.ts +2 -2
- package/dist/src/lib/template.js +2 -2
- package/dist/src/lib/test-case-keys.d.ts +1 -1
- package/dist/src/lib/test-case-keys.js +1 -1
- package/dist/src/lib/workflow-codegen/generator.d.ts +1 -1
- package/dist/src/lib/workflow-codegen/generator.js +1 -1
- package/package.json +3 -3
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* Both commands read a set of `*.toml` schemas out of a synced sub-directory
|
|
6
6
|
* (`workflows/` or `database-type-configs/`) and render `*.generated.ts` beside them.
|
|
7
7
|
* Historically each command located that source directory by scanning EVERY
|
|
8
|
-
*
|
|
8
|
+
* `primitive/<env>/<subdir>` slot and either hard-erroring on
|
|
9
9
|
* more than one (`workflows`) or silently merging across environments
|
|
10
10
|
* (`databases`, via a `seenTypes` dedup). Neither did any environment
|
|
11
11
|
* resolution, so `PRIMITIVE_ENV=dev workflows codegen` would happily generate
|
|
@@ -15,8 +15,10 @@
|
|
|
15
15
|
*
|
|
16
16
|
* This helper resolves the source directory the same way every other CLI
|
|
17
17
|
* command targets an environment: `--env` → `PRIMITIVE_ENV` →
|
|
18
|
-
* `defaultEnvironment` → single-env → error. `--dir`
|
|
19
|
-
*
|
|
18
|
+
* `defaultEnvironment` → single-env → error. `--dir` remains an explicit
|
|
19
|
+
* override; `--app` is no longer one — since #3153 the tree path carries no
|
|
20
|
+
* app segment, so an app the environment does not name is refused on every
|
|
21
|
+
* branch, `--dir` included. It returns ONLY the resolved source directory; TOML
|
|
20
22
|
* collection, type filtering/dedup, and output-dir defaulting stay in each
|
|
21
23
|
* command.
|
|
22
24
|
*
|
|
@@ -32,11 +34,12 @@
|
|
|
32
34
|
* - Preserve the `--app`-alone legacy fallback: when `--app` is given, NO
|
|
33
35
|
* environment was explicitly requested, and env resolution fails (or there
|
|
34
36
|
* is no project config / legacy bare-dir mode), scan
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
* integration
|
|
39
|
-
*
|
|
37
|
+
* `primitive/<env>/<subdir>`, resolving when exactly one environment has
|
|
38
|
+
* it and erroring (naming the candidates) otherwise. This keeps the
|
|
39
|
+
* existing integration contract
|
|
40
|
+
* (`cli/tests/integration/workflows-codegen.test.ts`) intact. A
|
|
41
|
+
* `stale-layout` refusal is rethrown rather than falling in here — the
|
|
42
|
+
* scan is exactly the old-tree read the refusal exists to prevent.
|
|
40
43
|
* - Do NOT fall through to that scan when an environment WAS explicitly named
|
|
41
44
|
* (`--env` or `PRIMITIVE_ENV`) but is invalid/unknown: surface the
|
|
42
45
|
* resolver's error instead, so an explicit env selection never silently
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* Both commands read a set of `*.toml` schemas out of a synced sub-directory
|
|
6
6
|
* (`workflows/` or `database-type-configs/`) and render `*.generated.ts` beside them.
|
|
7
7
|
* Historically each command located that source directory by scanning EVERY
|
|
8
|
-
*
|
|
8
|
+
* `primitive/<env>/<subdir>` slot and either hard-erroring on
|
|
9
9
|
* more than one (`workflows`) or silently merging across environments
|
|
10
10
|
* (`databases`, via a `seenTypes` dedup). Neither did any environment
|
|
11
11
|
* resolution, so `PRIMITIVE_ENV=dev workflows codegen` would happily generate
|
|
@@ -15,8 +15,10 @@
|
|
|
15
15
|
*
|
|
16
16
|
* This helper resolves the source directory the same way every other CLI
|
|
17
17
|
* command targets an environment: `--env` → `PRIMITIVE_ENV` →
|
|
18
|
-
* `defaultEnvironment` → single-env → error. `--dir`
|
|
19
|
-
*
|
|
18
|
+
* `defaultEnvironment` → single-env → error. `--dir` remains an explicit
|
|
19
|
+
* override; `--app` is no longer one — since #3153 the tree path carries no
|
|
20
|
+
* app segment, so an app the environment does not name is refused on every
|
|
21
|
+
* branch, `--dir` included. It returns ONLY the resolved source directory; TOML
|
|
20
22
|
* collection, type filtering/dedup, and output-dir defaulting stay in each
|
|
21
23
|
* command.
|
|
22
24
|
*
|
|
@@ -32,20 +34,23 @@
|
|
|
32
34
|
* - Preserve the `--app`-alone legacy fallback: when `--app` is given, NO
|
|
33
35
|
* environment was explicitly requested, and env resolution fails (or there
|
|
34
36
|
* is no project config / legacy bare-dir mode), scan
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
* integration
|
|
39
|
-
*
|
|
37
|
+
* `primitive/<env>/<subdir>`, resolving when exactly one environment has
|
|
38
|
+
* it and erroring (naming the candidates) otherwise. This keeps the
|
|
39
|
+
* existing integration contract
|
|
40
|
+
* (`cli/tests/integration/workflows-codegen.test.ts`) intact. A
|
|
41
|
+
* `stale-layout` refusal is rethrown rather than falling in here — the
|
|
42
|
+
* scan is exactly the old-tree read the refusal exists to prevent.
|
|
40
43
|
* - Do NOT fall through to that scan when an environment WAS explicitly named
|
|
41
44
|
* (`--env` or `PRIMITIVE_ENV`) but is invalid/unknown: surface the
|
|
42
45
|
* resolver's error instead, so an explicit env selection never silently
|
|
43
46
|
* generates code from a different synced environment.
|
|
44
47
|
*/
|
|
45
|
-
import { existsSync, readdirSync } from "fs";
|
|
48
|
+
import { existsSync, readdirSync, statSync } from "fs";
|
|
46
49
|
import { basename, dirname, join } from "path";
|
|
47
|
-
import {
|
|
48
|
-
import {
|
|
50
|
+
import { assertAppMatchesEnvironment } from "../app-match-guard.js";
|
|
51
|
+
import { PrimitiveEnvError, PROJECT_TREE_DIR } from "../env-resolver-core.js";
|
|
52
|
+
import { getCurrentEnvironment, getExplicitEnvName, getProjectConfig, } from "../env-resolver.js";
|
|
53
|
+
import { resolveSyncDir } from "../sync-paths.js";
|
|
49
54
|
/**
|
|
50
55
|
* Resolves the single source directory a codegen command should read its
|
|
51
56
|
* `*.toml` schemas from. Throws a plain `Error` (with a user-facing message)
|
|
@@ -55,7 +60,18 @@ export function resolveCodegenSourceDir(args) {
|
|
|
55
60
|
const { subdir, options } = args;
|
|
56
61
|
const cwd = args.cwd ?? process.cwd();
|
|
57
62
|
// 1. --dir is an explicit override: use <dir>/<subdir> verbatim.
|
|
63
|
+
//
|
|
64
|
+
// Naming the directory answers WHERE to read; it does not answer which
|
|
65
|
+
// app the caller may run as. An --app the environment does not name is
|
|
66
|
+
// the same mismatch every other tree command refuses (#3153, F1), and
|
|
67
|
+
// hearing about it must not depend on how the directory was chosen — so
|
|
68
|
+
// the guard runs here too, before the directory is touched. When the
|
|
69
|
+
// environment cannot be resolved at all there is nothing to compare
|
|
70
|
+
// against and nothing to confuse: the tree was named outright.
|
|
58
71
|
if (options.syncDir) {
|
|
72
|
+
if (options.app) {
|
|
73
|
+
assertAppMatchesEnvironment(options.app, safeCurrentEnvironment(), "codegen");
|
|
74
|
+
}
|
|
59
75
|
return requireExisting(join(options.syncDir, subdir), subdir, undefined);
|
|
60
76
|
}
|
|
61
77
|
// 2. Resolve the active environment. Call getCurrentEnvironment() directly
|
|
@@ -78,8 +94,13 @@ export function resolveCodegenSourceDir(args) {
|
|
|
78
94
|
env = getCurrentEnvironment();
|
|
79
95
|
}
|
|
80
96
|
catch (err) {
|
|
97
|
+
// A project holding the pre-#3153 layout must never fall into the scan:
|
|
98
|
+
// the scan is what would read the old tree, which is the one outcome the
|
|
99
|
+
// refusal exists to prevent.
|
|
100
|
+
if (err instanceof PrimitiveEnvError && err.kind === "stale-layout")
|
|
101
|
+
throw err;
|
|
81
102
|
if (options.app && !explicitEnvRequested) {
|
|
82
|
-
return scanSyncTree({ subdir,
|
|
103
|
+
return scanSyncTree({ subdir, cwd, app: options.app });
|
|
83
104
|
}
|
|
84
105
|
throw err;
|
|
85
106
|
}
|
|
@@ -88,68 +109,101 @@ export function resolveCodegenSourceDir(args) {
|
|
|
88
109
|
// credentials slot naming a different app would be a codegen run reading
|
|
89
110
|
// another app's tree.
|
|
90
111
|
if (env) {
|
|
91
|
-
|
|
92
|
-
//
|
|
93
|
-
//
|
|
94
|
-
|
|
95
|
-
|
|
112
|
+
// The app is the environment's, and only the environment's: the tree path
|
|
113
|
+
// no longer carries one (#3153). An --app naming a different app would
|
|
114
|
+
// generate this environment's types from another app's schema, so it is
|
|
115
|
+
// refused here, before any file is read.
|
|
116
|
+
assertAppMatchesEnvironment(options.app, env, "codegen");
|
|
117
|
+
const dir = join(resolveSyncDir(), subdir);
|
|
118
|
+
return requireExisting(dir, subdir, env.config.appId);
|
|
96
119
|
}
|
|
97
|
-
// 4. Legacy / bare-dir mode (no
|
|
98
|
-
//
|
|
99
|
-
return scanSyncTree({ subdir,
|
|
120
|
+
// 4. Legacy / bare-dir mode (no primitive/config.json): scan the tree.
|
|
121
|
+
// This preserves the pre-#1510 behavior; #3154 deletes it outright.
|
|
122
|
+
return scanSyncTree({ subdir, cwd, app: options.app });
|
|
100
123
|
}
|
|
101
124
|
/**
|
|
102
|
-
*
|
|
103
|
-
*
|
|
104
|
-
*
|
|
105
|
-
*
|
|
125
|
+
* The resolved environment, or null when none can be resolved — the form the
|
|
126
|
+
* `--dir` branch needs, where an unresolvable environment is not an error but
|
|
127
|
+
* simply nothing to check the app against. Every other branch surfaces the
|
|
128
|
+
* resolver's error, which is what makes an explicit `--env` selection binding.
|
|
129
|
+
*/
|
|
130
|
+
function safeCurrentEnvironment() {
|
|
131
|
+
try {
|
|
132
|
+
return getCurrentEnvironment();
|
|
133
|
+
}
|
|
134
|
+
catch {
|
|
135
|
+
return null;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Legacy fallback: scan `<cwd>/primitive/<env>/<subdir>` for a source
|
|
140
|
+
* directory. Resolves to the single match; errors clearly on zero or on
|
|
141
|
+
* ambiguity (naming the candidate envs), which `--env` resolves. #3154 deletes
|
|
142
|
+
* this branch.
|
|
143
|
+
*
|
|
144
|
+
* The tree path no longer carries the app segment that used to partition this
|
|
145
|
+
* scan (#3153), so when the project config IS readable — the environment just
|
|
146
|
+
* could not be selected — `--app` narrows the candidates itself: an
|
|
147
|
+
* environment the config binds to another app is not a directory this app's
|
|
148
|
+
* codegen may read. Without a config there is nothing to check against (bare
|
|
149
|
+
* mode), and every environment directory is a candidate as before.
|
|
106
150
|
*/
|
|
107
151
|
function scanSyncTree(args) {
|
|
108
|
-
const { subdir,
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
if (appId)
|
|
112
|
-
assertSafePathComponent(appId, "appId");
|
|
113
|
-
const root = join(cwd, ".primitive", "sync");
|
|
152
|
+
const { subdir, cwd, app } = args;
|
|
153
|
+
const boundEnvs = app ? environmentsNamingApp(app) : null;
|
|
154
|
+
const root = join(cwd, PROJECT_TREE_DIR);
|
|
114
155
|
const found = [];
|
|
115
156
|
if (existsSync(root)) {
|
|
116
157
|
for (const envName of readdirSync(root)) {
|
|
117
158
|
const envDir = join(root, envName);
|
|
159
|
+
// `primitive/` also holds config.json; only directories are environments.
|
|
118
160
|
try {
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
continue;
|
|
122
|
-
const candidate = join(envDir, app, subdir);
|
|
123
|
-
if (existsSync(candidate))
|
|
124
|
-
found.push(candidate);
|
|
125
|
-
}
|
|
161
|
+
if (!statSync(envDir).isDirectory())
|
|
162
|
+
continue;
|
|
126
163
|
}
|
|
127
164
|
catch {
|
|
128
|
-
|
|
165
|
+
continue;
|
|
129
166
|
}
|
|
167
|
+
if (boundEnvs && !boundEnvs.has(envName))
|
|
168
|
+
continue;
|
|
169
|
+
const candidate = join(envDir, subdir);
|
|
170
|
+
if (existsSync(candidate))
|
|
171
|
+
found.push(candidate);
|
|
130
172
|
}
|
|
131
173
|
}
|
|
132
174
|
if (found.length === 0) {
|
|
133
|
-
throw new Error(notFoundMessage(subdir,
|
|
175
|
+
throw new Error(notFoundMessage(subdir, boundEnvs ? app : undefined));
|
|
134
176
|
}
|
|
135
177
|
if (found.length > 1) {
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
];
|
|
140
|
-
throw new Error(`App "${appId}" has a ${subdir}/ directory under multiple environments: ` +
|
|
141
|
-
`${envs.join(", ")}.\n` +
|
|
142
|
-
found.map((d) => ` ${d}`).join("\n") +
|
|
143
|
-
`\nPass --env <name> or --dir to select one.`);
|
|
144
|
-
}
|
|
145
|
-
const apps = [...new Set(found.map((d) => basename(dirname(d))))];
|
|
146
|
-
throw new Error(`Found ${subdir}/ directories for more than one app/env:\n` +
|
|
178
|
+
const envs = [...new Set(found.map((d) => basename(dirname(d))))];
|
|
179
|
+
throw new Error(`Found ${subdir}/ directories under more than one environment: ` +
|
|
180
|
+
`${envs.join(", ")}.\n` +
|
|
147
181
|
found.map((d) => ` ${d}`).join("\n") +
|
|
148
|
-
`\nCodegen writes into one output dir, so it must run against one
|
|
149
|
-
`Pass --
|
|
182
|
+
`\nCodegen writes into one output dir, so it must run against one ` +
|
|
183
|
+
`environment. Pass --env <name> or --dir to select one.`);
|
|
150
184
|
}
|
|
151
185
|
return found[0];
|
|
152
186
|
}
|
|
187
|
+
/**
|
|
188
|
+
* The environments the project config binds to `app`, or null when there is no
|
|
189
|
+
* readable project config (bare mode: nothing to narrow the scan with).
|
|
190
|
+
*/
|
|
191
|
+
function environmentsNamingApp(app) {
|
|
192
|
+
let config;
|
|
193
|
+
try {
|
|
194
|
+
config = getProjectConfig();
|
|
195
|
+
}
|
|
196
|
+
catch {
|
|
197
|
+
// A config that cannot be read cannot vouch for any environment; the scan
|
|
198
|
+
// stays as wide as it was rather than inventing a binding.
|
|
199
|
+
return null;
|
|
200
|
+
}
|
|
201
|
+
if (!config)
|
|
202
|
+
return null;
|
|
203
|
+
return new Set(Object.entries(config.environments)
|
|
204
|
+
.filter(([, entry]) => entry.appId === app)
|
|
205
|
+
.map(([name]) => name));
|
|
206
|
+
}
|
|
153
207
|
/** Verifies `dir` exists, throwing the standard "no source dir" error otherwise. */
|
|
154
208
|
function requireExisting(dir, subdir, appId) {
|
|
155
209
|
if (!existsSync(dir)) {
|
|
@@ -159,8 +213,8 @@ function requireExisting(dir, subdir, appId) {
|
|
|
159
213
|
}
|
|
160
214
|
function notFoundMessage(subdir, appId) {
|
|
161
215
|
return appId
|
|
162
|
-
? `No ${subdir}/ directory found for app "${appId}" under
|
|
163
|
-
`
|
|
216
|
+
? `No ${subdir}/ directory found for app "${appId}" under primitive/<env>/. ` +
|
|
217
|
+
`Pass --dir, or run \`primitive config pull\` first.`
|
|
164
218
|
: `No ${subdir}/ directory found. Pass --dir or run \`primitive config pull\` first.`;
|
|
165
219
|
}
|
|
166
220
|
//# sourceMappingURL=resolveCodegenSourceDir.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolveCodegenSourceDir.js","sourceRoot":"","sources":["../../../../src/lib/codegen-shared/resolveCodegenSourceDir.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"resolveCodegenSourceDir.js","sourceRoot":"","sources":["../../../../src/lib/codegen-shared/resolveCodegenSourceDir.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AAEH,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,IAAI,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC/C,OAAO,EAAE,2BAA2B,EAAE,MAAM,uBAAuB,CAAC;AACpE,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC9E,OAAO,EACL,qBAAqB,EACrB,kBAAkB,EAClB,gBAAgB,GACjB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAsBlD;;;;GAIG;AACH,MAAM,UAAU,uBAAuB,CAAC,IAAiC;IACvE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;IACjC,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;IAEtC,iEAAiE;IACjE,EAAE;IACF,0EAA0E;IAC1E,0EAA0E;IAC1E,yEAAyE;IACzE,2EAA2E;IAC3E,wEAAwE;IACxE,uEAAuE;IACvE,kEAAkE;IAClE,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;QACpB,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;YAChB,2BAA2B,CAAC,OAAO,CAAC,GAAG,EAAE,sBAAsB,EAAE,EAAE,SAAS,CAAC,CAAC;QAChF,CAAC;QACD,OAAO,eAAe,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,MAAM,CA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AAI,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,CACzB,CAAC;AACJ,CAAC;AAED,oFAAoF;AACpF,SAAS,eAAe,CACtB,GAAW,EACX,MAAc,EACd,KAAyB;IAEzB,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;QACrB,MAAM,IAAI,KAAK,CAAC,eAAe,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC;IAClD,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED,SAAS,eAAe,CAAC,MAAc,EAAE,KAAyB;IAChE,OAAO,KAAK;QACV,CAAC,CAAC,MAAM,MAAM,8BAA8B,KAAK,4BAA4B;YACzE,qDAAqD;QACzD,CAAC,CAAC,MAAM,MAAM,uEAAuE,CAAC;AAC1F,CAAC"}
|
package/dist/src/lib/config.d.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* ~/.primitive/credentials.json and a handful of helpers here. After the
|
|
6
6
|
* project-config overhaul (issue #373) credentials live per-environment
|
|
7
7
|
* inside `<projectRoot>/.primitive/credentials.json` when a
|
|
8
|
-
*
|
|
8
|
+
* primitive/config.json is in scope, and fall back to the legacy global
|
|
9
9
|
* file otherwise.
|
|
10
10
|
*
|
|
11
11
|
* The rest of the CLI continues to import from this module, so we keep
|
|
@@ -50,7 +50,7 @@ export declare function getServerUrl(): string;
|
|
|
50
50
|
* - Project mode → the active environment's `apiUrl` (canonical). Lets
|
|
51
51
|
* getCurrentEnvironment() throw on an unresolvable env (ambiguous/unknown
|
|
52
52
|
* --env) so the caller can fail loudly instead of silently targeting prod.
|
|
53
|
-
* - Legacy mode (no
|
|
53
|
+
* - Legacy mode (no primitive/config.json) → DEFAULT_SERVER_URL, which
|
|
54
54
|
* honors the PRIMITIVE_SERVER_URL escape hatch (constants.ts).
|
|
55
55
|
*
|
|
56
56
|
* The trailing slash is stripped so callers can build `${url}/admin/api/...`.
|
package/dist/src/lib/config.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* ~/.primitive/credentials.json and a handful of helpers here. After the
|
|
6
6
|
* project-config overhaul (issue #373) credentials live per-environment
|
|
7
7
|
* inside `<projectRoot>/.primitive/credentials.json` when a
|
|
8
|
-
*
|
|
8
|
+
* primitive/config.json is in scope, and fall back to the legacy global
|
|
9
9
|
* file otherwise.
|
|
10
10
|
*
|
|
11
11
|
* The rest of the CLI continues to import from this module, so we keep
|
|
@@ -100,7 +100,7 @@ export function getServerUrl() {
|
|
|
100
100
|
* - Project mode → the active environment's `apiUrl` (canonical). Lets
|
|
101
101
|
* getCurrentEnvironment() throw on an unresolvable env (ambiguous/unknown
|
|
102
102
|
* --env) so the caller can fail loudly instead of silently targeting prod.
|
|
103
|
-
* - Legacy mode (no
|
|
103
|
+
* - Legacy mode (no primitive/config.json) → DEFAULT_SERVER_URL, which
|
|
104
104
|
* honors the PRIMITIVE_SERVER_URL escape hatch (constants.ts).
|
|
105
105
|
*
|
|
106
106
|
* The trailing slash is stripped so callers can build `${url}/admin/api/...`.
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* }
|
|
16
16
|
* }
|
|
17
17
|
*
|
|
18
|
-
* Mode B (legacy mode): no
|
|
18
|
+
* Mode B (legacy mode): no primitive/config.json in scope, so we fall back to
|
|
19
19
|
* ~/.primitive/credentials.json
|
|
20
20
|
* with the flat Credentials shape the CLI has always used.
|
|
21
21
|
*
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
import type { Credentials } from "../types/index.js";
|
|
26
26
|
export declare const PROJECT_LOCAL_DIR = ".primitive";
|
|
27
27
|
export declare const PROJECT_CREDENTIALS_FILENAME = "credentials.json";
|
|
28
|
-
/** Returns true when a
|
|
28
|
+
/** Returns true when a primitive/config.json is in scope (project mode active). */
|
|
29
29
|
export declare function isProjectMode(): boolean;
|
|
30
30
|
/**
|
|
31
31
|
* Returns the path to the credentials file that will be used, based on
|
|
@@ -38,7 +38,7 @@ export declare function getCredentialsFilePath(): string;
|
|
|
38
38
|
* callers don't need to change.
|
|
39
39
|
*
|
|
40
40
|
* In project mode, we blend the per-env stored creds with the serverUrl
|
|
41
|
-
* and appId from
|
|
41
|
+
* and appId from primitive/config.json to produce the Credentials the rest of
|
|
42
42
|
* the CLI expects.
|
|
43
43
|
*/
|
|
44
44
|
export declare function loadCredentialsStore(): Credentials | null;
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* }
|
|
16
16
|
* }
|
|
17
17
|
*
|
|
18
|
-
* Mode B (legacy mode): no
|
|
18
|
+
* Mode B (legacy mode): no primitive/config.json in scope, so we fall back to
|
|
19
19
|
* ~/.primitive/credentials.json
|
|
20
20
|
* with the flat Credentials shape the CLI has always used.
|
|
21
21
|
*
|
|
@@ -59,7 +59,7 @@ function stripRetiredCurrentApp(value) {
|
|
|
59
59
|
}
|
|
60
60
|
return value;
|
|
61
61
|
}
|
|
62
|
-
/** Returns true when a
|
|
62
|
+
/** Returns true when a primitive/config.json is in scope (project mode active). */
|
|
63
63
|
export function isProjectMode() {
|
|
64
64
|
return getProjectConfig() !== null;
|
|
65
65
|
}
|
|
@@ -160,7 +160,7 @@ function writeProjectCredentialsFile(projectRoot, file) {
|
|
|
160
160
|
* callers don't need to change.
|
|
161
161
|
*
|
|
162
162
|
* In project mode, we blend the per-env stored creds with the serverUrl
|
|
163
|
-
* and appId from
|
|
163
|
+
* and appId from primitive/config.json to produce the Credentials the rest of
|
|
164
164
|
* the CLI expects.
|
|
165
165
|
*/
|
|
166
166
|
export function loadCredentialsStore() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"credentials-store.js","sourceRoot":"","sources":["../../../src/lib/credentials-store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,EACL,SAAS,EACT,UAAU,EACV,SAAS,EACT,YAAY,EACZ,UAAU,EACV,aAAa,GACd,MAAM,IAAI,CAAC;AACZ,OAAO,EAAE,OAAO,EAAE,MAAM,IAAI,C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C,OAAO;QAC5B,KAAK,EAAE,WAAW,CAAC,KAAK;QACxB,IAAI,EAAE,WAAW,CAAC,IAAI;QACtB,IAAI,EAAE,WAAW,CAAC,IAAI;QACtB,gBAAgB,EAAE,WAAW,CAAC,gBAAgB;KAC/C,CAAC;IACF,2BAA2B,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC;AACjD,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,6BAA6B;IAC3C,MAAM,GAAG,GAAG,yBAAyB,EAAE,CAAC;IACxC,IAAI,CAAC,GAAG;QAAE,OAAO,EAAE,CAAC;IACpB,MAAM,IAAI,GAAG,0BAA0B,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;IACzD,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;AACxC,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,qBAAqB;IACnC,OAAO,qBAAqB,EAAE,CAAC;AACjC,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `permissions.json` rows `primitive documents export` writes.
|
|
3
|
+
*
|
|
4
|
+
* Extracted from `exportSingleDocument` (#2951) so the shape change it went
|
|
5
|
+
* through is testable without a server. The export used to merge the legacy
|
|
6
|
+
* `GET /documents/:id/invitations` array — filtering `accepted` and
|
|
7
|
+
* `expiresAt` client-side — into the permission rows. That route is removed;
|
|
8
|
+
* pending entries now come from `GET /documents/:id/pending-invitations`,
|
|
9
|
+
* which returns a `{ items }` envelope of deferred grants the server has
|
|
10
|
+
* already filtered down to unresolved, unexpired, still-invited ones.
|
|
11
|
+
*
|
|
12
|
+
* The export tolerates the pending read failing (an older server answers 403
|
|
13
|
+
* or 404): the caller swallows the error and passes `null`, and the export
|
|
14
|
+
* still writes the permission rows.
|
|
15
|
+
*/
|
|
16
|
+
export interface ExportedPermissionRow {
|
|
17
|
+
email: string;
|
|
18
|
+
permission: string;
|
|
19
|
+
grantedAt?: string;
|
|
20
|
+
source?: "invitation";
|
|
21
|
+
status?: "pending";
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Merge a document's permission rows and its pending deferred grants into the
|
|
25
|
+
* single email-keyed list `permissions.json` carries.
|
|
26
|
+
*
|
|
27
|
+
* @param permissionsResponse - `GET /documents/:id/permissions`, or `null` when the read failed.
|
|
28
|
+
* @param pendingResponse - `GET /documents/:id/pending-invitations`, or `null` when the read failed.
|
|
29
|
+
*/
|
|
30
|
+
export declare function buildPermissionsExport(permissionsResponse: unknown, pendingResponse: unknown): ExportedPermissionRow[];
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `permissions.json` rows `primitive documents export` writes.
|
|
3
|
+
*
|
|
4
|
+
* Extracted from `exportSingleDocument` (#2951) so the shape change it went
|
|
5
|
+
* through is testable without a server. The export used to merge the legacy
|
|
6
|
+
* `GET /documents/:id/invitations` array — filtering `accepted` and
|
|
7
|
+
* `expiresAt` client-side — into the permission rows. That route is removed;
|
|
8
|
+
* pending entries now come from `GET /documents/:id/pending-invitations`,
|
|
9
|
+
* which returns a `{ items }` envelope of deferred grants the server has
|
|
10
|
+
* already filtered down to unresolved, unexpired, still-invited ones.
|
|
11
|
+
*
|
|
12
|
+
* The export tolerates the pending read failing (an older server answers 403
|
|
13
|
+
* or 404): the caller swallows the error and passes `null`, and the export
|
|
14
|
+
* still writes the permission rows.
|
|
15
|
+
*/
|
|
16
|
+
/** Unwrap a list that may arrive bare, or under `items`, or under a named key. */
|
|
17
|
+
function rows(value, key) {
|
|
18
|
+
if (Array.isArray(value))
|
|
19
|
+
return value;
|
|
20
|
+
if (value && typeof value === "object") {
|
|
21
|
+
const envelope = value;
|
|
22
|
+
for (const candidate of ["items", key]) {
|
|
23
|
+
if (Array.isArray(envelope[candidate]))
|
|
24
|
+
return envelope[candidate];
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return [];
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Merge a document's permission rows and its pending deferred grants into the
|
|
31
|
+
* single email-keyed list `permissions.json` carries.
|
|
32
|
+
*
|
|
33
|
+
* @param permissionsResponse - `GET /documents/:id/permissions`, or `null` when the read failed.
|
|
34
|
+
* @param pendingResponse - `GET /documents/:id/pending-invitations`, or `null` when the read failed.
|
|
35
|
+
*/
|
|
36
|
+
export function buildPermissionsExport(permissionsResponse, pendingResponse) {
|
|
37
|
+
const granted = rows(permissionsResponse, "permissions")
|
|
38
|
+
.filter((p) => p?.email)
|
|
39
|
+
.map((p) => ({
|
|
40
|
+
email: p.email,
|
|
41
|
+
permission: p.permission,
|
|
42
|
+
grantedAt: p.grantedAt,
|
|
43
|
+
}));
|
|
44
|
+
const pending = rows(pendingResponse, "invitations")
|
|
45
|
+
.filter((i) => i?.email)
|
|
46
|
+
.map((i) => ({
|
|
47
|
+
email: i.email,
|
|
48
|
+
permission: i.permission,
|
|
49
|
+
source: "invitation",
|
|
50
|
+
status: "pending",
|
|
51
|
+
}));
|
|
52
|
+
return [...granted, ...pending];
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=document-export-permissions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"document-export-permissions.js","sourceRoot":"","sources":["../../../src/lib/document-export-permissions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAUH,kFAAkF;AAClF,SAAS,IAAI,CAAC,KAAc,EAAE,GAAW;IACvC,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IACvC,IAAI,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QACvC,MAAM,QAAQ,GAAG,KAAgC,CAAC;QAClD,KAAK,MAAM,SAAS,IAAI,CAAC,OAAO,EAAE,GAAG,CAAC,EAAE,CAAC;YACvC,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;gBAAE,OAAO,QAAQ,CAAC,SAAS,CAAU,CAAC;QAC9E,CAAC;IACH,CAAC;IACD,OAAO,EAAE,CAAC;AACZ,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,sBAAsB,CACpC,mBAA4B,EAC5B,eAAwB;IAExB,MAAM,OAAO,GAAG,IAAI,CAAC,mBAAmB,EAAE,aAAa,CAAC;SACrD,MAAM,CAAC,CAAC,CAAM,EAAE,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC;SAC5B,GAAG,CAAC,CAAC,CAAM,EAAE,EAAE,CAAC,CAAC;QAChB,KAAK,EAAE,CAAC,CAAC,KAAK;QACd,UAAU,EAAE,CAAC,CAAC,UAAU;QACxB,SAAS,EAAE,CAAC,CAAC,SAAS;KACvB,CAAC,CAAC,CAAC;IAEN,MAAM,OAAO,GAAG,IAAI,CAAC,eAAe,EAAE,aAAa,CAAC;SACjD,MAAM,CAAC,CAAC,CAAM,EAAE,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC;SAC5B,GAAG,CAAC,CAAC,CAAM,EAAE,EAAE,CAAC,CAAC;QAChB,KAAK,EAAE,CAAC,CAAC,KAAK;QACd,UAAU,EAAE,CAAC,CAAC,UAAU;QACxB,MAAM,EAAE,YAAqB;QAC7B,MAAM,EAAE,SAAkB;KAC3B,CAAC,CAAC,CAAC;IAEN,OAAO,CAAC,GAAG,OAAO,EAAE,GAAG,OAAO,CAAC,CAAC;AAClC,CAAC"}
|
|
@@ -29,20 +29,39 @@
|
|
|
29
29
|
* 4. defaultEnvironment (the committed team default)
|
|
30
30
|
* 5. the sole environment, if there is exactly one
|
|
31
31
|
*/
|
|
32
|
-
/** Schema version of
|
|
32
|
+
/** Schema version of `primitive/config.json` this core understands. */
|
|
33
33
|
export declare const PRIMITIVE_CONFIG_VERSION = 1;
|
|
34
34
|
/** Schema version of `.primitive/local.json` this core writes and reads. */
|
|
35
35
|
export declare const PRIMITIVE_LOCAL_STATE_VERSION = 1;
|
|
36
|
-
|
|
36
|
+
/**
|
|
37
|
+
* The two directories, split apart by #3153 so one name never means two
|
|
38
|
+
* things: `primitive/` is the COMMITTED tree (the config and every
|
|
39
|
+
* environment's TOML), `.primitive/` is MACHINE-LOCAL state (credentials, this
|
|
40
|
+
* machine's selection, snapshot backups) and is gitignored whole.
|
|
41
|
+
*/
|
|
42
|
+
export declare const PROJECT_TREE_DIR = "primitive";
|
|
43
|
+
export declare const PROJECT_LOCAL_STATE_DIR = ".primitive";
|
|
37
44
|
export declare const PROJECT_CONFIG_FILENAME = "config.json";
|
|
38
45
|
export declare const LOCAL_STATE_FILENAME = "local.json";
|
|
39
|
-
export declare const PROJECT_CONFIG_DISPLAY_NAME = "
|
|
46
|
+
export declare const PROJECT_CONFIG_DISPLAY_NAME = "primitive/config.json";
|
|
40
47
|
export declare const LOCAL_STATE_DISPLAY_NAME = ".primitive/local.json";
|
|
48
|
+
/** The docs-site slug of the migration procedure (#3155 publishes the page). */
|
|
49
|
+
export declare const MIGRATION_GUIDE_SLUG = "getting-started/cli-project-migration";
|
|
50
|
+
/**
|
|
51
|
+
* The one refusal for a project still holding the pre-#3153 layout.
|
|
52
|
+
*
|
|
53
|
+
* There is no fallback read: a tool that quietly read `.primitive/sync/` after
|
|
54
|
+
* the move would let a half-migrated project look healthy while push and pull
|
|
55
|
+
* disagreed about which tree is the truth. So every reader — this core, the
|
|
56
|
+
* generated Vite-plugin copy, the Swift pre-build script — stops here and names
|
|
57
|
+
* the document that says what to move where.
|
|
58
|
+
*/
|
|
59
|
+
export declare function staleLayoutMessage(detail: string): string;
|
|
41
60
|
/**
|
|
42
61
|
* Error kinds callers branch on. Every failure is one of these — no reader is
|
|
43
62
|
* ever left guessing what a broken config meant.
|
|
44
63
|
*/
|
|
45
|
-
export type PrimitiveEnvErrorKind = "missing-config" | "malformed-config" | "unsupported-version" | "corrupt-local-state" | "unknown-environment" | "no-selection" | "missing-app-id";
|
|
64
|
+
export type PrimitiveEnvErrorKind = "missing-config" | "malformed-config" | "unsupported-version" | "corrupt-local-state" | "unknown-environment" | "no-selection" | "missing-app-id" | "stale-layout";
|
|
46
65
|
export declare class PrimitiveEnvError extends Error {
|
|
47
66
|
readonly kind: PrimitiveEnvErrorKind;
|
|
48
67
|
readonly path?: string;
|
|
@@ -152,22 +171,35 @@ export interface ResolveOptions {
|
|
|
152
171
|
*/
|
|
153
172
|
export declare function deriveWsUrl(apiUrl: string): string;
|
|
154
173
|
/**
|
|
155
|
-
* Finds
|
|
174
|
+
* Finds `primitive/config.json` by walking up from `cwd`, or returns the
|
|
156
175
|
* PRIMITIVE_PROJECT_CONFIG override when it is set (and exists).
|
|
176
|
+
*
|
|
177
|
+
* The override is checked for provenance BEFORE the file is read (#3153, F2):
|
|
178
|
+
* it bypasses the walk, so without this an old-layout config could be handed
|
|
179
|
+
* straight to a reader and defeat the cutover.
|
|
180
|
+
*
|
|
181
|
+
* Every return is checked against the root it implies, not just the levels the
|
|
182
|
+
* walk passed through: this is the one function every reader goes through —
|
|
183
|
+
* `resolvePrimitiveEnv` and the CLI's own `loadProjectConfig`/`findProjectRoot`
|
|
184
|
+
* alike — so a half-migrated project must be refused HERE, or the commands that
|
|
185
|
+
* never call `resolvePrimitiveEnv` would read the new tree with the old one
|
|
186
|
+
* still beside it.
|
|
157
187
|
*/
|
|
158
188
|
export declare function findPrimitiveConfigPath(options?: {
|
|
159
189
|
cwd?: string;
|
|
160
190
|
env?: Record<string, string | undefined>;
|
|
161
191
|
}): string | null;
|
|
162
192
|
/**
|
|
163
|
-
* The project root for a config path: the parent of
|
|
193
|
+
* The project root for a config path: the parent of `primitive/`, or the
|
|
164
194
|
* containing directory when the config was pointed at directly (a fixture via
|
|
165
|
-
* PRIMITIVE_PROJECT_CONFIG, which is not inside a
|
|
195
|
+
* PRIMITIVE_PROJECT_CONFIG, which is not inside a `primitive/` directory).
|
|
166
196
|
*/
|
|
167
197
|
export declare function projectRootForConfigPath(configPath: string): string;
|
|
168
198
|
/**
|
|
169
|
-
*
|
|
170
|
-
* config
|
|
199
|
+
* Machine-local state lives under the project root's `.primitive/`, not beside
|
|
200
|
+
* the config — the config is committed now, and the two must not share a
|
|
201
|
+
* directory. A fixture-pointed bare config still gets its own `.primitive/`
|
|
202
|
+
* in its own directory, so it never picks up a real project's selection.
|
|
171
203
|
*/
|
|
172
204
|
export declare function localStatePathForConfigPath(configPath: string): string;
|
|
173
205
|
/**
|