instant-cli 0.22.95 → 0.22.96-experimental.add-posthog-frontend.20386914944.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/.turbo/turbo-build.log +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +21 -17
- package/dist/index.js.map +1 -1
- package/package.json +4 -6
- package/src/index.js +30 -29
- package/__tests__/mergeSchema.test.ts +0 -197
- package/dist/util/mergeSchema.d.ts +0 -2
- package/dist/util/mergeSchema.d.ts.map +0 -1
- package/dist/util/mergeSchema.js +0 -334
- package/dist/util/mergeSchema.js.map +0 -1
- package/src/util/mergeSchema.js +0 -364
package/.turbo/turbo-build.log
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.js"],"names":[],"mappings":"AAq8DA,8EAQC;AA+ED;;;;;EAKE"}
|
package/dist/index.js
CHANGED
|
@@ -38,7 +38,6 @@ import { buildAutoRenameSelector } from './rename.js';
|
|
|
38
38
|
import { loadEnv } from './util/loadEnv.js';
|
|
39
39
|
import { isHeadlessEnvironment } from './util/isHeadlessEnvironment.js';
|
|
40
40
|
import { getSchemaReadCandidates, getPermsReadCandidates, getSchemaPathToWrite, getPermsPathToWrite, } from './util/findConfigCandidates.js';
|
|
41
|
-
import { mergeSchema } from './util/mergeSchema.js';
|
|
42
41
|
const execAsync = promisify(exec);
|
|
43
42
|
loadEnv();
|
|
44
43
|
const dev = Boolean(process.env.INSTANT_CLI_DEV);
|
|
@@ -354,7 +353,6 @@ program
|
|
|
354
353
|
.argument('[schema|perms|all]', 'Which configuration to push. Defaults to `all`')
|
|
355
354
|
.option('-a --app <app-id>', 'App ID to push to. Defaults to *_INSTANT_APP_ID in .env')
|
|
356
355
|
.option('-p --package <react|react-native|core|admin>', 'Which package to automatically install if there is not one installed already.')
|
|
357
|
-
.option('--experimental-type-preservation', "[Experimental] Preserve manual type changes like `status: i.json<'online' | 'offline'>()` when doing `instant-cli pull schema`")
|
|
358
356
|
.description('Pull schema and perm files from production.')
|
|
359
357
|
.addHelpText('after', `
|
|
360
358
|
Environment Variables:
|
|
@@ -506,7 +504,7 @@ function handlePull(bag, opts) {
|
|
|
506
504
|
error('No app ID detected. Please specify one with --app or set up with `instant-cli init`');
|
|
507
505
|
return;
|
|
508
506
|
}
|
|
509
|
-
yield pull(bag, appId,
|
|
507
|
+
yield pull(bag, appId, pkgAndAuthInfo);
|
|
510
508
|
});
|
|
511
509
|
}
|
|
512
510
|
function push(bag, appId, opts) {
|
|
@@ -609,6 +607,7 @@ function login(options) {
|
|
|
609
607
|
debugName: 'Login register',
|
|
610
608
|
errorMessage: 'Failed to register login.',
|
|
611
609
|
noAuth: true,
|
|
610
|
+
command: 'login',
|
|
612
611
|
});
|
|
613
612
|
if (!registerRes.ok) {
|
|
614
613
|
return process.exit(1);
|
|
@@ -742,6 +741,7 @@ function promptCreateApp(opts) {
|
|
|
742
741
|
method: 'GET',
|
|
743
742
|
path: '/dash',
|
|
744
743
|
errorMessage: 'Failed to fetch apps.',
|
|
744
|
+
command: 'init',
|
|
745
745
|
});
|
|
746
746
|
if (!res.ok) {
|
|
747
747
|
return { ok: false };
|
|
@@ -768,6 +768,7 @@ function promptCreateApp(opts) {
|
|
|
768
768
|
debugName: 'App create',
|
|
769
769
|
errorMessage: 'Failed to create app.',
|
|
770
770
|
body: app,
|
|
771
|
+
command: 'init',
|
|
771
772
|
});
|
|
772
773
|
if (!appRes.ok)
|
|
773
774
|
return { ok: false };
|
|
@@ -787,6 +788,7 @@ function promptImportAppOrCreateApp() {
|
|
|
787
788
|
method: 'GET',
|
|
788
789
|
path: '/dash',
|
|
789
790
|
errorMessage: 'Failed to fetch apps.',
|
|
791
|
+
command: 'init',
|
|
790
792
|
});
|
|
791
793
|
if (!res.ok) {
|
|
792
794
|
return { ok: false };
|
|
@@ -804,6 +806,7 @@ function promptImportAppOrCreateApp() {
|
|
|
804
806
|
method: 'GET',
|
|
805
807
|
path: `/dash/orgs/${orgId}`,
|
|
806
808
|
errorMessage: 'Failed to fetch apps.',
|
|
809
|
+
command: 'init',
|
|
807
810
|
});
|
|
808
811
|
if (!orgsRes.ok) {
|
|
809
812
|
throw new Error('Failed to fetch org apps');
|
|
@@ -832,6 +835,7 @@ function createApp(title, orgId) {
|
|
|
832
835
|
debugName: 'App create',
|
|
833
836
|
errorMessage: 'Failed to create app.',
|
|
834
837
|
body: app,
|
|
838
|
+
command: 'init',
|
|
835
839
|
});
|
|
836
840
|
if (!appRes.ok)
|
|
837
841
|
throw new Error('Failed to create app');
|
|
@@ -990,12 +994,13 @@ function getOrPromptPackageAndAuthInfoWithErrorLogging(opts) {
|
|
|
990
994
|
});
|
|
991
995
|
}
|
|
992
996
|
function pullSchema(appId_1, _a) {
|
|
993
|
-
return __awaiter(this, arguments, void 0, function* (appId, { pkgDir, instantModuleName
|
|
997
|
+
return __awaiter(this, arguments, void 0, function* (appId, { pkgDir, instantModuleName }) {
|
|
994
998
|
console.log('Pulling schema...');
|
|
995
999
|
const pullRes = yield fetchJson({
|
|
996
1000
|
path: `/dash/apps/${appId}/schema/pull`,
|
|
997
1001
|
debugName: 'Schema pull',
|
|
998
1002
|
errorMessage: 'Failed to pull schema.',
|
|
1003
|
+
command: 'pull',
|
|
999
1004
|
});
|
|
1000
1005
|
if (!pullRes.ok)
|
|
1001
1006
|
return pullRes;
|
|
@@ -1017,17 +1022,7 @@ function pullSchema(appId_1, _a) {
|
|
|
1017
1022
|
}
|
|
1018
1023
|
const shortSchemaPath = getSchemaPathToWrite(prev === null || prev === void 0 ? void 0 : prev.path);
|
|
1019
1024
|
const schemaPath = join(pkgDir, shortSchemaPath);
|
|
1020
|
-
|
|
1021
|
-
if (prev && experimentalTypePreservation) {
|
|
1022
|
-
try {
|
|
1023
|
-
const oldSchemaContent = yield readFile(prev.path, 'utf-8');
|
|
1024
|
-
newSchemaContent = mergeSchema(oldSchemaContent, newSchemaContent);
|
|
1025
|
-
}
|
|
1026
|
-
catch (e) {
|
|
1027
|
-
warn('Failed to merge schema with existing file. Overwriting instead.', e);
|
|
1028
|
-
}
|
|
1029
|
-
}
|
|
1030
|
-
yield writeTypescript(schemaPath, newSchemaContent, 'utf-8');
|
|
1025
|
+
yield writeTypescript(schemaPath, generateSchemaTypescriptFile(prev === null || prev === void 0 ? void 0 : prev.schema, apiSchemaToInstantSchemaDef(pullRes.data.schema), instantModuleName), 'utf-8');
|
|
1031
1026
|
console.log('✅ Wrote schema to ' + shortSchemaPath);
|
|
1032
1027
|
return { ok: true };
|
|
1033
1028
|
});
|
|
@@ -1039,6 +1034,7 @@ function pullPerms(appId_1, _a) {
|
|
|
1039
1034
|
path: `/dash/apps/${appId}/perms/pull`,
|
|
1040
1035
|
debugName: 'Perms pull',
|
|
1041
1036
|
errorMessage: 'Failed to pull perms.',
|
|
1037
|
+
command: 'pull',
|
|
1042
1038
|
});
|
|
1043
1039
|
if (!pullRes.ok)
|
|
1044
1040
|
return pullRes;
|
|
@@ -1254,6 +1250,7 @@ function waitForIndexingJobsToFinish(appId, data) {
|
|
|
1254
1250
|
method: 'GET',
|
|
1255
1251
|
path: `/dash/apps/${appId}/indexing-jobs/group/${groupId}`,
|
|
1256
1252
|
errorMessage: 'Failed to check indexing status.',
|
|
1253
|
+
command: 'push',
|
|
1257
1254
|
});
|
|
1258
1255
|
if (!res.ok) {
|
|
1259
1256
|
break;
|
|
@@ -1308,6 +1305,7 @@ function pushSchema(appId, opts) {
|
|
|
1308
1305
|
path: `/dash/apps/${appId}/schema/pull`,
|
|
1309
1306
|
debugName: 'Schema plan',
|
|
1310
1307
|
errorMessage: 'Failed to get old schema.',
|
|
1308
|
+
command: 'push',
|
|
1311
1309
|
});
|
|
1312
1310
|
if (!pulledSchemaResponse.ok)
|
|
1313
1311
|
return pulledSchemaResponse;
|
|
@@ -1383,6 +1381,7 @@ function pushSchema(appId, opts) {
|
|
|
1383
1381
|
body: {
|
|
1384
1382
|
steps: txSteps,
|
|
1385
1383
|
},
|
|
1384
|
+
command: 'push',
|
|
1386
1385
|
});
|
|
1387
1386
|
console.log(chalk.green('Schema updated!'));
|
|
1388
1387
|
if (!applyRes.ok)
|
|
@@ -1408,6 +1407,7 @@ function claimEphemeralApp(appId, adminToken) {
|
|
|
1408
1407
|
path: `/dash/apps/ephemeral/${appId}/claim`,
|
|
1409
1408
|
debugName: 'Claim ephemeral app',
|
|
1410
1409
|
errorMessage: 'Failed to claim ephemeral app.',
|
|
1410
|
+
command: 'claim',
|
|
1411
1411
|
});
|
|
1412
1412
|
if (!res.ok)
|
|
1413
1413
|
return res;
|
|
@@ -1426,6 +1426,7 @@ function pushPerms(appId) {
|
|
|
1426
1426
|
path: `/dash/apps/${appId}/perms/pull`,
|
|
1427
1427
|
debugName: 'Perms pull',
|
|
1428
1428
|
errorMessage: 'Failed to pull perms.',
|
|
1429
|
+
command: 'push',
|
|
1429
1430
|
});
|
|
1430
1431
|
if (!prodPerms.ok)
|
|
1431
1432
|
return prodPerms;
|
|
@@ -1457,6 +1458,7 @@ function pushPerms(appId) {
|
|
|
1457
1458
|
body: {
|
|
1458
1459
|
code: res.perms,
|
|
1459
1460
|
},
|
|
1461
|
+
command: 'push',
|
|
1460
1462
|
});
|
|
1461
1463
|
if (!permsRes.ok)
|
|
1462
1464
|
return permsRes;
|
|
@@ -1477,6 +1479,7 @@ function waitForAuthToken(_a) {
|
|
|
1477
1479
|
body: { secret },
|
|
1478
1480
|
noAuth: true,
|
|
1479
1481
|
noLogError: true,
|
|
1482
|
+
command: 'login',
|
|
1480
1483
|
});
|
|
1481
1484
|
if (authCheckRes.ok) {
|
|
1482
1485
|
return authCheckRes.data;
|
|
@@ -1504,10 +1507,11 @@ function waitForAuthToken(_a) {
|
|
|
1504
1507
|
* @param {Object} [options.body=undefined]
|
|
1505
1508
|
* @param {boolean} [options.noAuth]
|
|
1506
1509
|
* @param {boolean} [options.noLogError]
|
|
1510
|
+
* @param {string} [options.command] - The CLI command being executed (e.g., 'push', 'pull', 'login')
|
|
1507
1511
|
* @returns {Promise<{ ok: boolean; data: any }>}
|
|
1508
1512
|
*/
|
|
1509
1513
|
function fetchJson(_a) {
|
|
1510
|
-
return __awaiter(this, arguments, void 0, function* ({ debugName, errorMessage, path, body, method, noAuth, noLogError, }) {
|
|
1514
|
+
return __awaiter(this, arguments, void 0, function* ({ debugName, errorMessage, path, body, method, noAuth, noLogError, command, }) {
|
|
1511
1515
|
const withAuth = !noAuth;
|
|
1512
1516
|
const withErrorLogging = !noLogError;
|
|
1513
1517
|
let authToken = null;
|
|
@@ -1521,7 +1525,7 @@ function fetchJson(_a) {
|
|
|
1521
1525
|
try {
|
|
1522
1526
|
const res = yield fetch(`${instantBackendOrigin}${path}`, {
|
|
1523
1527
|
method: method !== null && method !== void 0 ? method : 'GET',
|
|
1524
|
-
headers: Object.assign(Object.assign({}, (withAuth ? { Authorization: `Bearer ${authToken}` } : {})), { 'Content-Type': 'application/json', 'Instant-
|
|
1528
|
+
headers: Object.assign(Object.assign(Object.assign({}, (withAuth ? { Authorization: `Bearer ${authToken}` } : {})), { 'Content-Type': 'application/json', 'X-Instant-Source': 'instant-cli', 'X-Instant-Version': version }), (command ? { 'X-Instant-Command': command } : {})),
|
|
1525
1529
|
body: body ? JSON.stringify(body) : undefined,
|
|
1526
1530
|
signal: AbortSignal.timeout(timeoutMs),
|
|
1527
1531
|
});
|