@dboio/cli 0.19.0 → 0.19.1
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/package.json +1 -1
- package/src/commands/clone.js +33 -28
package/package.json
CHANGED
package/src/commands/clone.js
CHANGED
|
@@ -1095,34 +1095,8 @@ export async function performClone(source, options = {}) {
|
|
|
1095
1095
|
const effectiveDomain = options.domain || config.domain;
|
|
1096
1096
|
let appJson;
|
|
1097
1097
|
|
|
1098
|
-
//
|
|
1098
|
+
// Load local schema (server fetch deferred until after auth validation)
|
|
1099
1099
|
let schema = await loadSchema();
|
|
1100
|
-
let shouldFetch = !schema || options.schema;
|
|
1101
|
-
if (!shouldFetch && schema) {
|
|
1102
|
-
try {
|
|
1103
|
-
shouldFetch = await isSchemaStale({ domain: effectiveDomain, verbose: options.verbose });
|
|
1104
|
-
if (shouldFetch) log.dim(` Server schema is newer — refreshing _system dependency baseline`);
|
|
1105
|
-
} catch {
|
|
1106
|
-
// Can't check — continue with local schema
|
|
1107
|
-
}
|
|
1108
|
-
}
|
|
1109
|
-
if (shouldFetch) {
|
|
1110
|
-
try {
|
|
1111
|
-
schema = await fetchSchema({ domain: effectiveDomain, verbose: options.verbose });
|
|
1112
|
-
await saveSchema(schema);
|
|
1113
|
-
log.dim(` Refreshed _system dependency baseline`);
|
|
1114
|
-
} catch (err) {
|
|
1115
|
-
if (!schema) log.warn(` Could not fetch schema: ${err.message}`);
|
|
1116
|
-
// Continue with stale schema or null
|
|
1117
|
-
}
|
|
1118
|
-
}
|
|
1119
|
-
|
|
1120
|
-
// Regenerate metadata_schema.json for any new entity types
|
|
1121
|
-
if (schema) {
|
|
1122
|
-
const existing = await loadMetadataSchema();
|
|
1123
|
-
const updated = generateMetadataFromSchema(schema, existing ?? {});
|
|
1124
|
-
await saveMetadataSchema(updated);
|
|
1125
|
-
}
|
|
1126
1100
|
|
|
1127
1101
|
// Step 1: Source mismatch detection (skip in pull mode)
|
|
1128
1102
|
// Warn when the user provides an explicit source that differs from the stored one.
|
|
@@ -1148,7 +1122,9 @@ export async function performClone(source, options = {}) {
|
|
|
1148
1122
|
}
|
|
1149
1123
|
}
|
|
1150
1124
|
|
|
1151
|
-
// Step 2: Load the app JSON — retry loop with fallback prompt on failure
|
|
1125
|
+
// Step 2: Load the app JSON — retry loop with fallback prompt on failure.
|
|
1126
|
+
// This runs BEFORE schema/dependency sync so that the login prompt fires
|
|
1127
|
+
// here if the session is expired (not buried inside a silent dependency clone).
|
|
1152
1128
|
let activeSource = source;
|
|
1153
1129
|
while (true) {
|
|
1154
1130
|
try {
|
|
@@ -1178,6 +1154,35 @@ export async function performClone(source, options = {}) {
|
|
|
1178
1154
|
throw new Error('Invalid app JSON: missing UID or children');
|
|
1179
1155
|
}
|
|
1180
1156
|
|
|
1157
|
+
// Fetch schema if missing, explicitly requested, or server has a newer version.
|
|
1158
|
+
// Runs AFTER app fetch so that login prompt fires first on expired session.
|
|
1159
|
+
let shouldFetchSchema = !schema || options.schema;
|
|
1160
|
+
if (!shouldFetchSchema && schema) {
|
|
1161
|
+
try {
|
|
1162
|
+
shouldFetchSchema = await isSchemaStale({ domain: effectiveDomain, verbose: options.verbose });
|
|
1163
|
+
if (shouldFetchSchema) log.dim(` Server schema is newer — refreshing _system dependency baseline`);
|
|
1164
|
+
} catch {
|
|
1165
|
+
// Can't check — continue with local schema
|
|
1166
|
+
}
|
|
1167
|
+
}
|
|
1168
|
+
if (shouldFetchSchema) {
|
|
1169
|
+
try {
|
|
1170
|
+
schema = await fetchSchema({ domain: effectiveDomain, verbose: options.verbose });
|
|
1171
|
+
await saveSchema(schema);
|
|
1172
|
+
log.dim(` Refreshed _system dependency baseline`);
|
|
1173
|
+
} catch (err) {
|
|
1174
|
+
if (!schema) log.warn(` Could not fetch schema: ${err.message}`);
|
|
1175
|
+
// Continue with stale schema or null
|
|
1176
|
+
}
|
|
1177
|
+
}
|
|
1178
|
+
|
|
1179
|
+
// Regenerate metadata_schema.json for any new entity types
|
|
1180
|
+
if (schema) {
|
|
1181
|
+
const existing = await loadMetadataSchema();
|
|
1182
|
+
const updated = generateMetadataFromSchema(schema, existing ?? {});
|
|
1183
|
+
await saveMetadataSchema(updated);
|
|
1184
|
+
}
|
|
1185
|
+
|
|
1181
1186
|
// Domain change detection
|
|
1182
1187
|
if (effectiveDomain) {
|
|
1183
1188
|
const { changed, proceed } = await checkDomainChange(effectiveDomain, options);
|