@tinacms/cli 0.61.7 → 0.61.10
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/buildTina/attachPath.d.ts +1 -0
- package/dist/buildTina/index.d.ts +37 -17
- package/dist/cmds/audit/audit.d.ts +6 -0
- package/dist/cmds/compile/defaultSchema.d.ts +1 -1
- package/dist/cmds/compile/index.d.ts +5 -3
- package/dist/cmds/query-gen/index.d.ts +0 -1
- package/dist/cmds/start-server/index.d.ts +9 -3
- package/dist/index.js +329 -413
- package/package.json +5 -6
- package/dist/cmds/query-gen/attachSchema.d.ts +0 -13
package/dist/index.js
CHANGED
|
@@ -70,11 +70,11 @@ var init_utils = __esm({
|
|
|
70
70
|
});
|
|
71
71
|
|
|
72
72
|
// src/server/models/media.ts
|
|
73
|
-
var
|
|
73
|
+
var import_fs_extra8, import_path10, MediaModel;
|
|
74
74
|
var init_media = __esm({
|
|
75
75
|
"src/server/models/media.ts"() {
|
|
76
|
-
|
|
77
|
-
|
|
76
|
+
import_fs_extra8 = __toModule(require("fs-extra"));
|
|
77
|
+
import_path10 = __toModule(require("path"));
|
|
78
78
|
init_utils();
|
|
79
79
|
MediaModel = class {
|
|
80
80
|
constructor({ publicFolder, mediaRoot }) {
|
|
@@ -83,12 +83,12 @@ var init_media = __esm({
|
|
|
83
83
|
}
|
|
84
84
|
async listMedia(args) {
|
|
85
85
|
try {
|
|
86
|
-
const folderPath = (0,
|
|
86
|
+
const folderPath = (0, import_path10.join)(this.publicFolder, this.mediaRoot, args.searchPath);
|
|
87
87
|
const searchPath = parseMediaFolder(args.searchPath);
|
|
88
|
-
const filesStr = await
|
|
88
|
+
const filesStr = await import_fs_extra8.default.readdir(folderPath);
|
|
89
89
|
const filesProm = filesStr.map(async (file) => {
|
|
90
|
-
const filePath = (0,
|
|
91
|
-
const stat = await
|
|
90
|
+
const filePath = (0, import_path10.join)(folderPath, file);
|
|
91
|
+
const stat = await import_fs_extra8.default.stat(filePath);
|
|
92
92
|
let src = `/${file}`;
|
|
93
93
|
const isFile = stat.isFile();
|
|
94
94
|
if (!isFile) {
|
|
@@ -144,9 +144,9 @@ var init_media = __esm({
|
|
|
144
144
|
}
|
|
145
145
|
async deleteMedia(args) {
|
|
146
146
|
try {
|
|
147
|
-
const file = (0,
|
|
148
|
-
await
|
|
149
|
-
await
|
|
147
|
+
const file = (0, import_path10.join)(this.publicFolder, this.mediaRoot, args.searchPath);
|
|
148
|
+
await import_fs_extra8.default.stat(file);
|
|
149
|
+
await import_fs_extra8.default.remove(file);
|
|
150
150
|
return { ok: true };
|
|
151
151
|
} catch (error) {
|
|
152
152
|
console.error(error);
|
|
@@ -158,15 +158,15 @@ var init_media = __esm({
|
|
|
158
158
|
});
|
|
159
159
|
|
|
160
160
|
// src/server/routes/index.ts
|
|
161
|
-
var import_express,
|
|
161
|
+
var import_express, import_path11, import_multer, createMediaRouter;
|
|
162
162
|
var init_routes = __esm({
|
|
163
163
|
"src/server/routes/index.ts"() {
|
|
164
164
|
import_express = __toModule(require("express"));
|
|
165
|
-
|
|
165
|
+
import_path11 = __toModule(require("path"));
|
|
166
166
|
import_multer = __toModule(require("multer"));
|
|
167
167
|
init_media();
|
|
168
168
|
createMediaRouter = (config) => {
|
|
169
|
-
const mediaFolder = (0,
|
|
169
|
+
const mediaFolder = (0, import_path11.join)(process.cwd(), config.publicFolder, config.mediaRoot);
|
|
170
170
|
const storage = import_multer.default.diskStorage({
|
|
171
171
|
destination: function(req, file, cb) {
|
|
172
172
|
cb(null, mediaFolder);
|
|
@@ -293,7 +293,7 @@ var commander = __toModule(require("commander"));
|
|
|
293
293
|
|
|
294
294
|
// package.json
|
|
295
295
|
var name = "@tinacms/cli";
|
|
296
|
-
var version = "0.61.
|
|
296
|
+
var version = "0.61.10";
|
|
297
297
|
|
|
298
298
|
// src/cmds/audit/audit.ts
|
|
299
299
|
var import_graphql = __toModule(require("@tinacms/graphql"));
|
|
@@ -313,81 +313,14 @@ logger.level = "info";
|
|
|
313
313
|
// src/cmds/audit/audit.ts
|
|
314
314
|
var import_graphql2 = __toModule(require("@tinacms/graphql"));
|
|
315
315
|
var import_chalk = __toModule(require("chalk"));
|
|
316
|
-
var auditCollection = async (args) => {
|
|
317
|
-
let warning = false;
|
|
318
|
-
const { collection, database, rootPath: rootPath2 } = args;
|
|
319
|
-
logger.info(`Checking collection ${collection.name}`);
|
|
320
|
-
const query = `query {
|
|
321
|
-
collection(collection: "${collection.name}") {
|
|
322
|
-
format
|
|
323
|
-
documents {
|
|
324
|
-
edges {
|
|
325
|
-
node {
|
|
326
|
-
...on Document {
|
|
327
|
-
_sys {
|
|
328
|
-
extension
|
|
329
|
-
path
|
|
330
|
-
}
|
|
331
|
-
}
|
|
332
|
-
}
|
|
333
|
-
}
|
|
334
|
-
}
|
|
335
|
-
}
|
|
336
|
-
}
|
|
337
|
-
`;
|
|
338
|
-
const result = await (0, import_graphql.resolve)({
|
|
339
|
-
database,
|
|
340
|
-
query,
|
|
341
|
-
variables: {}
|
|
342
|
-
});
|
|
343
|
-
const format = result.data.collection.format;
|
|
344
|
-
const docs = result.data.collection.documents.edges;
|
|
345
|
-
docs.forEach((x) => {
|
|
346
|
-
const node = x.node;
|
|
347
|
-
if (node._sys.extension.replace(".", "") !== format) {
|
|
348
|
-
warning = true;
|
|
349
|
-
logger.warn(import_chalk.default.yellowBright(`WARNING: there is a file with extension \`${node._sys.extension}\` but in your schema it is defined to be \`.${format}\`
|
|
350
|
-
|
|
351
|
-
location: ${import_path.default.join(rootPath2, node._sys.path)}`));
|
|
352
|
-
}
|
|
353
|
-
});
|
|
354
|
-
return warning;
|
|
355
|
-
};
|
|
356
316
|
var auditDocuments = async (args) => {
|
|
357
|
-
const { collection, database,
|
|
358
|
-
const query = `query {
|
|
359
|
-
collection(collection: "${collection.name}") {
|
|
360
|
-
format
|
|
361
|
-
slug
|
|
362
|
-
documents {
|
|
363
|
-
edges {
|
|
364
|
-
node {
|
|
365
|
-
...on Document {
|
|
366
|
-
_sys {
|
|
367
|
-
extension
|
|
368
|
-
path
|
|
369
|
-
relativePath
|
|
370
|
-
}
|
|
371
|
-
}
|
|
372
|
-
}
|
|
373
|
-
}
|
|
374
|
-
}
|
|
375
|
-
}
|
|
376
|
-
}
|
|
377
|
-
`;
|
|
378
|
-
const result = await (0, import_graphql.resolve)({
|
|
379
|
-
database,
|
|
380
|
-
query,
|
|
381
|
-
variables: {}
|
|
382
|
-
});
|
|
317
|
+
const { collection, database, useDefaultValues, documents } = args;
|
|
383
318
|
let error = false;
|
|
384
|
-
const documents = result.data.collection.documents.edges;
|
|
385
319
|
for (let i = 0; i < documents.length; i++) {
|
|
386
320
|
const node = documents[i].node;
|
|
387
|
-
const
|
|
388
|
-
logger.info(`Checking document: ${fullPath}`);
|
|
321
|
+
const relativePath = node.path.replace(`${collection.path}/`, "");
|
|
389
322
|
const documentQuery = `query {
|
|
390
|
-
document(collection: "${collection.name}", relativePath: "${
|
|
323
|
+
document(collection: "${collection.name}", relativePath: "${relativePath}") {
|
|
391
324
|
__typename
|
|
392
325
|
...on Document {
|
|
393
326
|
_values
|
|
@@ -397,44 +330,58 @@ var auditDocuments = async (args) => {
|
|
|
397
330
|
const docResult = await (0, import_graphql.resolve)({
|
|
398
331
|
database,
|
|
399
332
|
query: documentQuery,
|
|
400
|
-
variables: {}
|
|
333
|
+
variables: {},
|
|
334
|
+
silenceErrors: true,
|
|
335
|
+
verbose: args.verbose || false,
|
|
336
|
+
isAudit: true
|
|
401
337
|
});
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
if (
|
|
407
|
-
|
|
338
|
+
if (docResult.errors) {
|
|
339
|
+
error = true;
|
|
340
|
+
docResult.errors.forEach((err) => {
|
|
341
|
+
logger.error(import_chalk.default.red(err.message));
|
|
342
|
+
if (err.originalError.originalError) {
|
|
343
|
+
logger.error(import_chalk.default.red(` ${err.originalError.originalError.message}`));
|
|
408
344
|
}
|
|
409
345
|
});
|
|
410
|
-
}
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
346
|
+
} else {
|
|
347
|
+
const topLevelDefaults = {};
|
|
348
|
+
if (useDefaultValues && typeof collection.fields !== "string") {
|
|
349
|
+
collection.fields.filter((x) => !x.list).forEach((x) => {
|
|
350
|
+
const value = x.ui;
|
|
351
|
+
if (typeof value !== "undefined") {
|
|
352
|
+
topLevelDefaults[x.name] = value.defaultValue;
|
|
353
|
+
}
|
|
354
|
+
});
|
|
355
|
+
}
|
|
356
|
+
const params = transformDocumentIntoMutationRequestPayload(docResult.data.document._values, {
|
|
357
|
+
includeCollection: true,
|
|
358
|
+
includeTemplate: typeof collection.templates !== "undefined"
|
|
359
|
+
}, topLevelDefaults);
|
|
360
|
+
const mutation = `mutation($collection: String!, $relativePath: String!, $params: DocumentMutation!) {
|
|
416
361
|
updateDocument(
|
|
417
362
|
collection: $collection,
|
|
418
363
|
relativePath: $relativePath,
|
|
419
364
|
params: $params
|
|
420
365
|
){__typename}
|
|
421
366
|
}`;
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
if (mutationRes.errors) {
|
|
434
|
-
mutationRes.errors.forEach((err) => {
|
|
435
|
-
error = true;
|
|
436
|
-
logger.error(import_chalk.default.red(err.message));
|
|
367
|
+
const mutationRes = await (0, import_graphql.resolve)({
|
|
368
|
+
database,
|
|
369
|
+
query: mutation,
|
|
370
|
+
variables: {
|
|
371
|
+
params,
|
|
372
|
+
collection: collection.name,
|
|
373
|
+
relativePath
|
|
374
|
+
},
|
|
375
|
+
isAudit: true,
|
|
376
|
+
silenceErrors: true,
|
|
377
|
+
verbose: args.verbose || false
|
|
437
378
|
});
|
|
379
|
+
if (mutationRes.errors) {
|
|
380
|
+
mutationRes.errors.forEach((err) => {
|
|
381
|
+
error = true;
|
|
382
|
+
logger.error(import_chalk.default.red(err.message));
|
|
383
|
+
});
|
|
384
|
+
}
|
|
438
385
|
}
|
|
439
386
|
}
|
|
440
387
|
return error;
|
|
@@ -484,9 +431,22 @@ function filterObject(obj) {
|
|
|
484
431
|
}
|
|
485
432
|
|
|
486
433
|
// src/cmds/audit/index.ts
|
|
487
|
-
var
|
|
434
|
+
var import_chalk3 = __toModule(require("chalk"));
|
|
488
435
|
var import_prompts = __toModule(require("prompts"));
|
|
489
436
|
var import_metrics = __toModule(require("@tinacms/metrics"));
|
|
437
|
+
|
|
438
|
+
// src/utils/theme.ts
|
|
439
|
+
var import_chalk2 = __toModule(require("chalk"));
|
|
440
|
+
var successText = import_chalk2.default.bold.green;
|
|
441
|
+
var dangerText = import_chalk2.default.bold.red;
|
|
442
|
+
var neutralText = import_chalk2.default.bold.cyan;
|
|
443
|
+
var labelText = import_chalk2.default.bold;
|
|
444
|
+
var cmdText = import_chalk2.default.inverse;
|
|
445
|
+
var logText = import_chalk2.default.italic.gray;
|
|
446
|
+
var warnText = import_chalk2.default.yellowBright.bgBlack;
|
|
447
|
+
var CONFIRMATION_TEXT = import_chalk2.default.dim("enter to confirm");
|
|
448
|
+
|
|
449
|
+
// src/cmds/audit/index.ts
|
|
490
450
|
var rootPath = process.cwd();
|
|
491
451
|
var audit = async (ctx, next, options) => {
|
|
492
452
|
const telemetry = new import_metrics.Telemetry({ disabled: options.noTelemetry });
|
|
@@ -498,7 +458,7 @@ var audit = async (ctx, next, options) => {
|
|
|
498
458
|
}
|
|
499
459
|
});
|
|
500
460
|
if (options.clean) {
|
|
501
|
-
logger.info(`You are using the \`--clean\` option. This will modify your content as if a user is submitting a form. Before running this you should have a ${
|
|
461
|
+
logger.info(`You are using the \`--clean\` option. This will modify your content as if a user is submitting a form. Before running this you should have a ${import_chalk3.default.bold("clean git tree")} so unwanted changes can be undone.
|
|
502
462
|
|
|
503
463
|
`);
|
|
504
464
|
const res = await (0, import_prompts.default)({
|
|
@@ -507,52 +467,47 @@ var audit = async (ctx, next, options) => {
|
|
|
507
467
|
message: `Do you want to continue?`
|
|
508
468
|
});
|
|
509
469
|
if (!res.useClean) {
|
|
510
|
-
logger.warn(
|
|
470
|
+
logger.warn(import_chalk3.default.yellowBright("\u26A0\uFE0F Audit not complete"));
|
|
511
471
|
process.exit(0);
|
|
512
472
|
}
|
|
513
473
|
}
|
|
514
474
|
if (options.useDefaultValues && !options.clean) {
|
|
515
|
-
logger.warn(
|
|
475
|
+
logger.warn(import_chalk3.default.yellowBright("WARNING: using the `--useDefaultValues` without the `--clean` flag has no effect. Please re-run audit and add the `--clean` flag"));
|
|
516
476
|
}
|
|
517
477
|
const database = ctx.database;
|
|
518
478
|
const schema = await database.getSchema();
|
|
519
479
|
const collections = schema.getCollections();
|
|
520
|
-
let warning = false;
|
|
521
480
|
let error = false;
|
|
522
481
|
for (let i = 0; i < collections.length; i++) {
|
|
523
482
|
const collection = collections[i];
|
|
524
|
-
const
|
|
525
|
-
|
|
526
|
-
database,
|
|
527
|
-
rootPath,
|
|
528
|
-
useDefaultValues: options.useDefaultValues
|
|
529
|
-
});
|
|
483
|
+
const docs = await database.query({ collection: collection.name, first: -1, filterChain: [] }, (item) => ({ path: item }));
|
|
484
|
+
logger.info(`Checking ${neutralText(collection.name)} collection`);
|
|
530
485
|
const returnError = await auditDocuments({
|
|
531
486
|
collection,
|
|
532
487
|
database,
|
|
533
488
|
rootPath,
|
|
534
|
-
useDefaultValues: options.useDefaultValues
|
|
489
|
+
useDefaultValues: options.useDefaultValues,
|
|
490
|
+
documents: docs.edges,
|
|
491
|
+
verbose: ctx.verbose
|
|
535
492
|
});
|
|
536
|
-
warning = warning || returnWarning;
|
|
537
493
|
error = error || returnError;
|
|
538
494
|
}
|
|
539
|
-
ctx.warning = warning;
|
|
540
495
|
ctx.error = error;
|
|
541
496
|
next();
|
|
542
497
|
};
|
|
543
498
|
var printFinalMessage = async (ctx, next, _options) => {
|
|
544
499
|
if (ctx.error) {
|
|
545
|
-
logger.error(
|
|
500
|
+
logger.error(import_chalk3.default.redBright(`\u203C\uFE0F Audit ${import_chalk3.default.bold("failed")} with errors`));
|
|
546
501
|
} else if (ctx.warning) {
|
|
547
|
-
logger.warn(
|
|
502
|
+
logger.warn(import_chalk3.default.yellowBright("\u26A0\uFE0F Audit passed with warnings"));
|
|
548
503
|
} else {
|
|
549
|
-
logger.info(
|
|
504
|
+
logger.info(import_chalk3.default.greenBright("\u2705 Audit passed"));
|
|
550
505
|
}
|
|
551
506
|
next();
|
|
552
507
|
};
|
|
553
508
|
|
|
554
509
|
// src/cmds/init/setup-files/index.ts
|
|
555
|
-
var
|
|
510
|
+
var import_chalk4 = __toModule(require("chalk"));
|
|
556
511
|
var adminPage = `import { TinaAdmin } from 'tinacms';
|
|
557
512
|
export default TinaAdmin;
|
|
558
513
|
`;
|
|
@@ -856,15 +811,15 @@ export default App
|
|
|
856
811
|
`;
|
|
857
812
|
};
|
|
858
813
|
var AppJsContentPrintout = (usingSrc, extraImports) => {
|
|
859
|
-
const importLine =
|
|
814
|
+
const importLine = import_chalk4.default.green(`+ import Tina from '${usingSrc ? "../" : ""}../.tina/components/TinaDynamicProvider.js'`);
|
|
860
815
|
return `${importLine}
|
|
861
816
|
${extraImports || ""}
|
|
862
817
|
|
|
863
818
|
const App = ({ Component, pageProps }) => {
|
|
864
819
|
return (
|
|
865
|
-
${
|
|
820
|
+
${import_chalk4.default.green("+ <Tina>")}
|
|
866
821
|
<Component {...pageProps} />
|
|
867
|
-
${
|
|
822
|
+
${import_chalk4.default.green("+ </Tina>")}
|
|
868
823
|
)
|
|
869
824
|
}
|
|
870
825
|
|
|
@@ -905,17 +860,6 @@ const DynamicTina = ({ children }) => {
|
|
|
905
860
|
export default DynamicTina
|
|
906
861
|
`;
|
|
907
862
|
|
|
908
|
-
// src/utils/theme.ts
|
|
909
|
-
var import_chalk4 = __toModule(require("chalk"));
|
|
910
|
-
var successText = import_chalk4.default.bold.green;
|
|
911
|
-
var dangerText = import_chalk4.default.bold.red;
|
|
912
|
-
var neutralText = import_chalk4.default.bold.cyan;
|
|
913
|
-
var labelText = import_chalk4.default.bold;
|
|
914
|
-
var cmdText = import_chalk4.default.inverse;
|
|
915
|
-
var logText = import_chalk4.default.italic.gray;
|
|
916
|
-
var warnText = import_chalk4.default.yellowBright.bgBlack;
|
|
917
|
-
var CONFIRMATION_TEXT = import_chalk4.default.dim("enter to confirm");
|
|
918
|
-
|
|
919
863
|
// src/utils/script-helpers.ts
|
|
920
864
|
function generateGqlScript(scriptValue) {
|
|
921
865
|
return `tinacms dev -c "${scriptValue}"`;
|
|
@@ -1048,7 +992,7 @@ async function tinaSetup(_ctx, next, _options) {
|
|
|
1048
992
|
}
|
|
1049
993
|
if (!import_fs_extra.default.existsSync(TinaProviderPath) && !import_fs_extra.default.existsSync(TinaDynamicProvider)) {
|
|
1050
994
|
import_fs_extra.default.mkdirpSync(componentFolder);
|
|
1051
|
-
import_fs_extra.default.writeFileSync(TinaProviderPath, TinaProvider.replace(/'\.\.\/schema\.ts'/, `'../schema.${_ctx.
|
|
995
|
+
import_fs_extra.default.writeFileSync(TinaProviderPath, TinaProvider.replace(/'\.\.\/schema\.ts'/, `'../schema.${_ctx.usingTs ? "ts" : "js"}'`));
|
|
1052
996
|
import_fs_extra.default.writeFileSync(TinaDynamicProvider, TinaProviderDynamic);
|
|
1053
997
|
}
|
|
1054
998
|
logger.level = "info";
|
|
@@ -1141,6 +1085,9 @@ var chain = async (cmds, options) => {
|
|
|
1141
1085
|
await cmds[middlewareIndex](ctx, () => next(middlewareIndex + 1), options || {});
|
|
1142
1086
|
} catch (err) {
|
|
1143
1087
|
console.error(` ${dangerText(err)}`);
|
|
1088
|
+
if (err.stack) {
|
|
1089
|
+
console.log(err.stack);
|
|
1090
|
+
}
|
|
1144
1091
|
process.exit(1);
|
|
1145
1092
|
}
|
|
1146
1093
|
};
|
|
@@ -1219,6 +1166,12 @@ const schema = defineSchema({
|
|
|
1219
1166
|
name: 'post',
|
|
1220
1167
|
path: 'content/posts',
|
|
1221
1168
|
format: 'mdx',
|
|
1169
|
+
ui: {
|
|
1170
|
+
router: ({ document }) => {
|
|
1171
|
+
// This can be used to add contextual editing to your site. See https://tina.io/docs/tinacms-context/#accessing-contextual-editing-from-the-cms for more information.
|
|
1172
|
+
return \`/demo/blog/\${document._sys.filename}\`
|
|
1173
|
+
},
|
|
1174
|
+
},
|
|
1222
1175
|
fields: [
|
|
1223
1176
|
{
|
|
1224
1177
|
type: 'string',
|
|
@@ -1264,28 +1217,6 @@ export default schema
|
|
|
1264
1217
|
export const tinaConfig = defineConfig({
|
|
1265
1218
|
client,
|
|
1266
1219
|
schema,
|
|
1267
|
-
cmsCallback: (cms) => {
|
|
1268
|
-
// add your CMS callback code here (if you want)
|
|
1269
|
-
|
|
1270
|
-
// The Route Mapper
|
|
1271
|
-
/**
|
|
1272
|
-
* 1. Import \`tinacms\` and \`RouteMappingPlugin\`
|
|
1273
|
-
**/
|
|
1274
|
-
import('tinacms').then(({ RouteMappingPlugin }) => {
|
|
1275
|
-
/**
|
|
1276
|
-
* 2. Define the \`RouteMappingPlugin\` see https://tina.io/docs/tinacms-context/#the-routemappingplugin for more details
|
|
1277
|
-
**/
|
|
1278
|
-
const RouteMapping = new RouteMappingPlugin((collection, document) => {
|
|
1279
|
-
return undefined
|
|
1280
|
-
})
|
|
1281
|
-
/**
|
|
1282
|
-
* 3. Add the \`RouteMappingPlugin\` to the \`cms\`.
|
|
1283
|
-
**/
|
|
1284
|
-
cms.plugins.add(RouteMapping)
|
|
1285
|
-
})
|
|
1286
|
-
|
|
1287
|
-
return cms
|
|
1288
|
-
},
|
|
1289
1220
|
})
|
|
1290
1221
|
|
|
1291
1222
|
`;
|
|
@@ -1304,9 +1235,9 @@ var getPath = ({
|
|
|
1304
1235
|
}
|
|
1305
1236
|
const filePaths = allowedTypes.map((ext) => import_path3.default.join(projectDir, `${filename}.${ext}`));
|
|
1306
1237
|
let inputFile = void 0;
|
|
1307
|
-
filePaths.every((
|
|
1308
|
-
if (import_fs_extra2.default.existsSync(
|
|
1309
|
-
inputFile =
|
|
1238
|
+
filePaths.every((path8) => {
|
|
1239
|
+
if (import_fs_extra2.default.existsSync(path8)) {
|
|
1240
|
+
inputFile = path8;
|
|
1310
1241
|
return false;
|
|
1311
1242
|
}
|
|
1312
1243
|
return true;
|
|
@@ -1425,8 +1356,8 @@ var compileClient = async (ctx, next, options) => {
|
|
|
1425
1356
|
}
|
|
1426
1357
|
return next();
|
|
1427
1358
|
};
|
|
1428
|
-
var compileFile = async (
|
|
1429
|
-
const root2 =
|
|
1359
|
+
var compileFile = async (options, fileName) => {
|
|
1360
|
+
const root2 = options.rootPath;
|
|
1430
1361
|
if (!root2) {
|
|
1431
1362
|
throw new Error("ctx.rootPath has not been attached");
|
|
1432
1363
|
}
|
|
@@ -1447,9 +1378,6 @@ var compileFile = async (ctx, _next, options, fileName) => {
|
|
|
1447
1378
|
if (!schemaFileType2) {
|
|
1448
1379
|
throw new Error(`Requested schema file type '${requestedSchemaFileType}' is not valid. Supported schema file types: 'ts, js, tsx, jsx'`);
|
|
1449
1380
|
}
|
|
1450
|
-
if (ctx) {
|
|
1451
|
-
ctx.schemaFileType = schemaFileType2;
|
|
1452
|
-
}
|
|
1453
1381
|
let schemaExists = true;
|
|
1454
1382
|
try {
|
|
1455
1383
|
getPath({
|
|
@@ -1507,14 +1435,14 @@ var compileFile = async (ctx, _next, options, fileName) => {
|
|
|
1507
1435
|
}
|
|
1508
1436
|
return returnObject;
|
|
1509
1437
|
};
|
|
1510
|
-
var compileSchema = async (
|
|
1511
|
-
const root2 =
|
|
1438
|
+
var compileSchema = async (options) => {
|
|
1439
|
+
const root2 = options.rootPath;
|
|
1512
1440
|
const tinaPath = import_path4.default.join(root2, ".tina");
|
|
1513
1441
|
const tinaGeneratedPath = import_path4.default.join(tinaPath, "__generated__");
|
|
1514
1442
|
const tinaConfigPath = import_path4.default.join(tinaGeneratedPath, "config");
|
|
1515
|
-
let schema = await compileFile(
|
|
1443
|
+
let schema = await compileFile(options, "schema");
|
|
1516
1444
|
try {
|
|
1517
|
-
const config = await compileFile(
|
|
1445
|
+
const config = await compileFile(options, "config");
|
|
1518
1446
|
const configCopy = _.cloneDeep(config);
|
|
1519
1447
|
delete configCopy.schema;
|
|
1520
1448
|
if (config == null ? void 0 : config.schema) {
|
|
@@ -1522,8 +1450,8 @@ var compileSchema = async (ctx, _next, options) => {
|
|
|
1522
1450
|
}
|
|
1523
1451
|
} catch (e) {
|
|
1524
1452
|
}
|
|
1525
|
-
ctx.schema = schema;
|
|
1526
1453
|
await import_fs_extra3.default.outputFile(import_path4.default.join(tinaConfigPath, `schema.json`), JSON.stringify(schema, null, 2));
|
|
1454
|
+
return schema;
|
|
1527
1455
|
};
|
|
1528
1456
|
var transpile = async (inputFile, outputFile, tempDir, verbose, define, packageJSONFilePath) => {
|
|
1529
1457
|
if (verbose)
|
|
@@ -1533,14 +1461,29 @@ var transpile = async (inputFile, outputFile, tempDir, verbose, define, packageJ
|
|
|
1533
1461
|
const peerDeps = (packageJSON == null ? void 0 : packageJSON.peerDependencies) || [];
|
|
1534
1462
|
const devDeps = (packageJSON == null ? void 0 : packageJSON.devDependencies) || [];
|
|
1535
1463
|
const external = Object.keys(__spreadValues(__spreadValues(__spreadValues({}, deps), peerDeps), devDeps));
|
|
1464
|
+
const prebuiltInputPath = import_path4.default.join(tempDir, "temp-output.jsx");
|
|
1465
|
+
await (0, import_esbuild.build)({
|
|
1466
|
+
bundle: true,
|
|
1467
|
+
platform: "neutral",
|
|
1468
|
+
target: ["es2020"],
|
|
1469
|
+
entryPoints: [inputFile],
|
|
1470
|
+
treeShaking: true,
|
|
1471
|
+
external: [...external, "./node_modules/*"],
|
|
1472
|
+
loader: loaders,
|
|
1473
|
+
outfile: prebuiltInputPath,
|
|
1474
|
+
define
|
|
1475
|
+
});
|
|
1476
|
+
const tempTsConfigPath = import_path4.default.join(tempDir, "temp-tsconfig.json");
|
|
1477
|
+
await import_fs_extra3.default.outputFileSync(tempTsConfigPath, "{}");
|
|
1536
1478
|
const outputPath = import_path4.default.join(tempDir, outputFile);
|
|
1537
1479
|
await (0, import_esbuild.build)({
|
|
1538
1480
|
bundle: true,
|
|
1539
1481
|
platform: "neutral",
|
|
1540
1482
|
target: ["node10.4"],
|
|
1541
|
-
entryPoints: [
|
|
1483
|
+
entryPoints: [prebuiltInputPath],
|
|
1542
1484
|
treeShaking: true,
|
|
1543
1485
|
external: [...external, "./node_modules/*"],
|
|
1486
|
+
tsconfig: tempTsConfigPath,
|
|
1544
1487
|
loader: loaders,
|
|
1545
1488
|
outfile: outputPath,
|
|
1546
1489
|
define
|
|
@@ -1578,29 +1521,36 @@ var loaders = {
|
|
|
1578
1521
|
};
|
|
1579
1522
|
|
|
1580
1523
|
// src/cmds/start-server/index.ts
|
|
1581
|
-
var
|
|
1524
|
+
var import_path12 = __toModule(require("path"));
|
|
1582
1525
|
var import_chalk6 = __toModule(require("chalk"));
|
|
1583
1526
|
var import_chokidar = __toModule(require("chokidar"));
|
|
1584
1527
|
var import_metrics3 = __toModule(require("@tinacms/metrics"));
|
|
1585
1528
|
|
|
1586
|
-
// src/
|
|
1587
|
-
var
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1529
|
+
// src/cmds/start-server/lock.ts
|
|
1530
|
+
var AsyncLock = class {
|
|
1531
|
+
constructor() {
|
|
1532
|
+
this.disable = () => {
|
|
1533
|
+
};
|
|
1534
|
+
this.promise = Promise.resolve();
|
|
1535
|
+
}
|
|
1536
|
+
enable() {
|
|
1537
|
+
this.promise = new Promise((resolve2) => this.disable = resolve2);
|
|
1538
|
+
}
|
|
1539
|
+
};
|
|
1592
1540
|
|
|
1593
|
-
// src/
|
|
1594
|
-
var
|
|
1541
|
+
// src/buildTina/index.ts
|
|
1542
|
+
var import_fs_extra7 = __toModule(require("fs-extra"));
|
|
1543
|
+
var import_graphql9 = __toModule(require("@tinacms/graphql"));
|
|
1595
1544
|
var import_datalayer = __toModule(require("@tinacms/datalayer"));
|
|
1545
|
+
var import_path9 = __toModule(require("path"));
|
|
1596
1546
|
|
|
1597
1547
|
// src/cmds/query-gen/genTypes.ts
|
|
1598
|
-
var
|
|
1548
|
+
var import_graphql8 = __toModule(require("graphql"));
|
|
1599
1549
|
var import_fs_extra4 = __toModule(require("fs-extra"));
|
|
1600
1550
|
var import_path6 = __toModule(require("path"));
|
|
1601
1551
|
|
|
1602
1552
|
// src/codegen/index.ts
|
|
1603
|
-
var
|
|
1553
|
+
var import_graphql7 = __toModule(require("graphql"));
|
|
1604
1554
|
|
|
1605
1555
|
// src/codegen/plugin.ts
|
|
1606
1556
|
var AddGeneratedClientFunc = (_schema, _documents, _config, _info) => {
|
|
@@ -1652,14 +1602,14 @@ var import_typescript_operations = __toModule(require("@graphql-codegen/typescri
|
|
|
1652
1602
|
var import_typescript = __toModule(require("@graphql-codegen/typescript"));
|
|
1653
1603
|
|
|
1654
1604
|
// src/codegen/sdkPlugin/index.ts
|
|
1605
|
+
var import_graphql5 = __toModule(require("graphql"));
|
|
1655
1606
|
var import_graphql6 = __toModule(require("graphql"));
|
|
1656
|
-
var import_graphql7 = __toModule(require("graphql"));
|
|
1657
1607
|
var import_path5 = __toModule(require("path"));
|
|
1658
1608
|
|
|
1659
1609
|
// src/codegen/sdkPlugin/visitor.ts
|
|
1660
1610
|
var import_visitor_plugin_common = __toModule(require("@graphql-codegen/visitor-plugin-common"));
|
|
1661
1611
|
var import_auto_bind = __toModule(require("auto-bind"));
|
|
1662
|
-
var
|
|
1612
|
+
var import_graphql4 = __toModule(require("graphql"));
|
|
1663
1613
|
var GenericSdkVisitor = class extends import_visitor_plugin_common.ClientSideBaseVisitor {
|
|
1664
1614
|
constructor(schema, fragments, rawConfig) {
|
|
1665
1615
|
super(schema, fragments, rawConfig, {
|
|
@@ -1675,7 +1625,7 @@ var GenericSdkVisitor = class extends import_visitor_plugin_common.ClientSideBas
|
|
|
1675
1625
|
}
|
|
1676
1626
|
buildOperation(node, documentVariableName, operationType, operationResultType, operationVariablesTypes) {
|
|
1677
1627
|
if (node.name == null) {
|
|
1678
|
-
throw new Error("Plugin 'generic-sdk' cannot generate SDK for unnamed operation.\n\n" + (0,
|
|
1628
|
+
throw new Error("Plugin 'generic-sdk' cannot generate SDK for unnamed operation.\n\n" + (0, import_graphql4.print)(node));
|
|
1679
1629
|
} else {
|
|
1680
1630
|
this._operationsToInclude.push({
|
|
1681
1631
|
node,
|
|
@@ -1690,7 +1640,7 @@ var GenericSdkVisitor = class extends import_visitor_plugin_common.ClientSideBas
|
|
|
1690
1640
|
get sdkContent() {
|
|
1691
1641
|
const usingObservable = !!this.config.usingObservableFrom;
|
|
1692
1642
|
const allPossibleActions = this._operationsToInclude.map((o) => {
|
|
1693
|
-
const optionalVariables = !o.node.variableDefinitions || o.node.variableDefinitions.length === 0 || o.node.variableDefinitions.every((v) => v.type.kind !==
|
|
1643
|
+
const optionalVariables = !o.node.variableDefinitions || o.node.variableDefinitions.length === 0 || o.node.variableDefinitions.every((v) => v.type.kind !== import_graphql4.Kind.NON_NULL_TYPE || v.defaultValue);
|
|
1694
1644
|
const returnType = usingObservable && o.operationType === "Subscription" ? "Observable" : "Promise";
|
|
1695
1645
|
return `${o.node.name.value}(variables${optionalVariables ? "?" : ""}: ${o.operationVariablesTypes}, options?: C): ${returnType}<${o.operationResultType}> {
|
|
1696
1646
|
return requester<${o.operationResultType}, ${o.operationVariablesTypes}>(${o.documentVariableName}, variables, options);
|
|
@@ -1708,11 +1658,11 @@ var GenericSdkVisitor = class extends import_visitor_plugin_common.ClientSideBas
|
|
|
1708
1658
|
|
|
1709
1659
|
// src/codegen/sdkPlugin/index.ts
|
|
1710
1660
|
var plugin = (schema, documents, config) => {
|
|
1711
|
-
const allAst = (0,
|
|
1661
|
+
const allAst = (0, import_graphql6.concatAST)(documents.reduce((prev, v) => {
|
|
1712
1662
|
return [...prev, v.document];
|
|
1713
1663
|
}, []));
|
|
1714
1664
|
const allFragments = [
|
|
1715
|
-
...allAst.definitions.filter((d) => d.kind ===
|
|
1665
|
+
...allAst.definitions.filter((d) => d.kind === import_graphql6.Kind.FRAGMENT_DEFINITION).map((fragmentDef) => ({
|
|
1716
1666
|
node: fragmentDef,
|
|
1717
1667
|
name: fragmentDef.name.value,
|
|
1718
1668
|
onType: fragmentDef.typeCondition.name.value,
|
|
@@ -1721,7 +1671,7 @@ var plugin = (schema, documents, config) => {
|
|
|
1721
1671
|
...config.externalFragments || []
|
|
1722
1672
|
];
|
|
1723
1673
|
const visitor = new GenericSdkVisitor(schema, allFragments, config);
|
|
1724
|
-
const visitorResult = (0,
|
|
1674
|
+
const visitorResult = (0, import_graphql5.visit)(allAst, { leave: visitor });
|
|
1725
1675
|
return {
|
|
1726
1676
|
content: [
|
|
1727
1677
|
visitor.fragments,
|
|
@@ -1738,64 +1688,53 @@ var generateTypes = async (schema, queryPathGlob = process.cwd(), fragDocPath =
|
|
|
1738
1688
|
}) => {
|
|
1739
1689
|
if (options.verbose)
|
|
1740
1690
|
logger.info("Generating types...");
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
}
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1691
|
+
let docs = [];
|
|
1692
|
+
let fragDocs = [];
|
|
1693
|
+
if (!options.noSDK) {
|
|
1694
|
+
docs = await loadGraphQLDocuments(queryPathGlob);
|
|
1695
|
+
fragDocs = await loadGraphQLDocuments(fragDocPath);
|
|
1696
|
+
}
|
|
1697
|
+
const res = await (0, import_core.codegen)({
|
|
1698
|
+
filename: process.cwd(),
|
|
1699
|
+
schema: (0, import_graphql7.parse)((0, import_graphql7.printSchema)(schema)),
|
|
1700
|
+
documents: [...docs, ...fragDocs],
|
|
1701
|
+
config: {},
|
|
1702
|
+
plugins: [
|
|
1703
|
+
{ typescript: {} },
|
|
1704
|
+
{ typescriptOperations: {} },
|
|
1705
|
+
{
|
|
1706
|
+
typescriptSdk: {}
|
|
1707
|
+
},
|
|
1708
|
+
{ AddGeneratedClient: {} }
|
|
1709
|
+
],
|
|
1710
|
+
pluginMap: {
|
|
1711
|
+
typescript: {
|
|
1712
|
+
plugin: import_typescript.plugin
|
|
1713
|
+
},
|
|
1714
|
+
typescriptOperations: {
|
|
1715
|
+
plugin: import_typescript_operations.plugin
|
|
1716
|
+
},
|
|
1717
|
+
typescriptSdk: {
|
|
1718
|
+
plugin
|
|
1719
|
+
},
|
|
1720
|
+
AddGeneratedClient
|
|
1768
1721
|
}
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
{
|
|
1778
|
-
typescriptSdk: {}
|
|
1779
|
-
},
|
|
1780
|
-
{ AddGeneratedClient: {} }
|
|
1781
|
-
],
|
|
1782
|
-
pluginMap: {
|
|
1783
|
-
typescript: {
|
|
1784
|
-
plugin: import_typescript.plugin
|
|
1785
|
-
},
|
|
1786
|
-
typescriptOperations: {
|
|
1787
|
-
plugin: import_typescript_operations.plugin
|
|
1788
|
-
},
|
|
1789
|
-
typescriptSdk: {
|
|
1790
|
-
plugin
|
|
1791
|
-
},
|
|
1792
|
-
AddGeneratedClient
|
|
1793
|
-
}
|
|
1722
|
+
});
|
|
1723
|
+
return res;
|
|
1724
|
+
};
|
|
1725
|
+
var loadGraphQLDocuments = async (globPath) => {
|
|
1726
|
+
let result = [];
|
|
1727
|
+
try {
|
|
1728
|
+
result = await (0, import_load.loadDocuments)(globPath, {
|
|
1729
|
+
loaders: [new import_graphql_file_loader.GraphQLFileLoader()]
|
|
1794
1730
|
});
|
|
1795
|
-
return res;
|
|
1796
1731
|
} catch (e) {
|
|
1797
|
-
|
|
1732
|
+
if ((e.message || "").includes("Unable to find any GraphQL type definitions for the following pointers:")) {
|
|
1733
|
+
} else {
|
|
1734
|
+
throw e;
|
|
1735
|
+
}
|
|
1798
1736
|
}
|
|
1737
|
+
return result;
|
|
1799
1738
|
};
|
|
1800
1739
|
|
|
1801
1740
|
// src/cmds/query-gen/genTypes.ts
|
|
@@ -1856,7 +1795,7 @@ async function genTypes({ schema, usingTs }, next, options) {
|
|
|
1856
1795
|
const jsCode = await (0, import_esbuild2.transform)(code, { loader: "ts" });
|
|
1857
1796
|
await import_fs_extra4.default.outputFile(typesJSPath, jsCode.code);
|
|
1858
1797
|
}
|
|
1859
|
-
const schemaString = await (0,
|
|
1798
|
+
const schemaString = await (0, import_graphql8.printSchema)(schema);
|
|
1860
1799
|
const schemaPath = process.cwd() + "/.tina/__generated__/schema.gql";
|
|
1861
1800
|
await import_fs_extra4.default.outputFile(schemaPath, `# DO NOT MODIFY THIS FILE. This file is automatically generated by Tina
|
|
1862
1801
|
${schemaString}
|
|
@@ -1960,159 +1899,156 @@ async function spin({
|
|
|
1960
1899
|
return res;
|
|
1961
1900
|
}
|
|
1962
1901
|
|
|
1902
|
+
// src/buildTina/attachPath.ts
|
|
1903
|
+
var import_fs_extra6 = __toModule(require("fs-extra"));
|
|
1904
|
+
var import_path8 = __toModule(require("path"));
|
|
1905
|
+
var attachPath = async (ctx, next, _options) => {
|
|
1906
|
+
ctx.rootPath = process.cwd();
|
|
1907
|
+
ctx.usingTs = await isProjectTs(ctx.rootPath);
|
|
1908
|
+
next();
|
|
1909
|
+
};
|
|
1910
|
+
var isProjectTs = async (rootPath2) => {
|
|
1911
|
+
const tinaPath = import_path8.default.join(rootPath2, ".tina");
|
|
1912
|
+
return await (0, import_fs_extra6.pathExists)(import_path8.default.join(tinaPath, "schema.ts")) || await (0, import_fs_extra6.pathExists)(import_path8.default.join(tinaPath, "schema.tsx"));
|
|
1913
|
+
};
|
|
1914
|
+
|
|
1963
1915
|
// src/buildTina/index.ts
|
|
1964
1916
|
var buildSetupCmdBuild = async (ctx, next, opts) => {
|
|
1965
1917
|
const rootPath2 = ctx.rootPath;
|
|
1966
|
-
const { bridge, database
|
|
1918
|
+
const { bridge, database } = await buildSetup(__spreadProps(__spreadValues({}, opts), {
|
|
1967
1919
|
rootPath: rootPath2,
|
|
1968
1920
|
useMemoryStore: true
|
|
1969
1921
|
}));
|
|
1970
1922
|
ctx.bridge = bridge;
|
|
1971
1923
|
ctx.database = database;
|
|
1972
|
-
ctx.
|
|
1924
|
+
ctx.builder = new ConfigBuilder(database);
|
|
1973
1925
|
next();
|
|
1974
1926
|
};
|
|
1975
1927
|
var buildSetupCmdServerStart = async (ctx, next, opts) => {
|
|
1976
1928
|
const rootPath2 = ctx.rootPath;
|
|
1977
|
-
const { bridge, database
|
|
1929
|
+
const { bridge, database } = await buildSetup(__spreadProps(__spreadValues({}, opts), {
|
|
1978
1930
|
rootPath: rootPath2,
|
|
1979
1931
|
useMemoryStore: false
|
|
1980
1932
|
}));
|
|
1981
1933
|
ctx.bridge = bridge;
|
|
1982
1934
|
ctx.database = database;
|
|
1983
|
-
ctx.
|
|
1935
|
+
ctx.builder = new ConfigBuilder(database);
|
|
1984
1936
|
next();
|
|
1985
1937
|
};
|
|
1986
1938
|
var buildSetupCmdAudit = async (ctx, next, options) => {
|
|
1987
1939
|
const rootPath2 = ctx.rootPath;
|
|
1988
|
-
const bridge = options.clean ? new
|
|
1989
|
-
const store = new
|
|
1990
|
-
const database = await (0,
|
|
1940
|
+
const bridge = options.clean ? new import_datalayer.FilesystemBridge(rootPath2) : new import_datalayer.AuditFileSystemBridge(rootPath2);
|
|
1941
|
+
const store = new import_datalayer.LevelStore(rootPath2, false);
|
|
1942
|
+
const database = await (0, import_graphql9.createDatabase)({ store, bridge });
|
|
1991
1943
|
ctx.bridge = bridge;
|
|
1992
1944
|
ctx.database = database;
|
|
1993
|
-
ctx.
|
|
1945
|
+
ctx.builder = new ConfigBuilder(database);
|
|
1994
1946
|
next();
|
|
1995
1947
|
};
|
|
1996
1948
|
var buildSetup = async ({
|
|
1997
1949
|
isomorphicGitBridge: isomorphicGitBridge2,
|
|
1998
|
-
experimentalData,
|
|
1999
1950
|
rootPath: rootPath2,
|
|
2000
1951
|
useMemoryStore
|
|
2001
1952
|
}) => {
|
|
2002
|
-
const fsBridge = new
|
|
1953
|
+
const fsBridge = new import_datalayer.FilesystemBridge(rootPath2);
|
|
2003
1954
|
const isomorphicOptions = isomorphicGitBridge2 && await makeIsomorphicOptions(fsBridge);
|
|
2004
|
-
const bridge = isomorphicGitBridge2 ? new
|
|
2005
|
-
const store = new
|
|
2006
|
-
const database = await (0,
|
|
1955
|
+
const bridge = isomorphicGitBridge2 ? new import_datalayer.IsomorphicBridge(rootPath2, isomorphicOptions) : fsBridge;
|
|
1956
|
+
const store = new import_datalayer.LevelStore(rootPath2, useMemoryStore);
|
|
1957
|
+
const database = await (0, import_graphql9.createDatabase)({ store, bridge });
|
|
2007
1958
|
return { database, bridge, store };
|
|
2008
1959
|
};
|
|
2009
1960
|
var buildCmdBuild = async (ctx, next, options) => {
|
|
2010
|
-
const
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
await
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
})
|
|
1961
|
+
const { schema } = await ctx.builder.build(__spreadValues({
|
|
1962
|
+
rootPath: ctx.rootPath
|
|
1963
|
+
}, options));
|
|
1964
|
+
await ctx.builder.genTypedClient({
|
|
1965
|
+
compiledSchema: schema,
|
|
1966
|
+
local: options.local,
|
|
1967
|
+
noSDK: options.noSDK,
|
|
1968
|
+
verbose: options.verbose,
|
|
1969
|
+
usingTs: ctx.usingTs
|
|
1970
|
+
});
|
|
1971
|
+
await buildAdmin({
|
|
1972
|
+
local: options.local,
|
|
1973
|
+
rootPath: ctx.rootPath,
|
|
1974
|
+
schema
|
|
1975
|
+
});
|
|
2020
1976
|
next();
|
|
2021
1977
|
};
|
|
2022
1978
|
var auditCmdBuild = async (ctx, next, options) => {
|
|
2023
|
-
const
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
local: true,
|
|
2028
|
-
verbose: true,
|
|
2029
|
-
bridge,
|
|
2030
|
-
database,
|
|
2031
|
-
store,
|
|
2032
|
-
ctx
|
|
1979
|
+
const { graphQLSchema, tinaSchema } = await ctx.builder.build(__spreadProps(__spreadValues({
|
|
1980
|
+
rootPath: ctx.rootPath
|
|
1981
|
+
}, options), {
|
|
1982
|
+
verbose: true
|
|
2033
1983
|
}));
|
|
1984
|
+
await ctx.database.indexContent({ graphQLSchema, tinaSchema });
|
|
2034
1985
|
next();
|
|
2035
1986
|
};
|
|
2036
|
-
var
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
bridge,
|
|
2040
|
-
database,
|
|
2041
|
-
store,
|
|
2042
|
-
beforeBuild,
|
|
2043
|
-
afterBuild,
|
|
2044
|
-
dev,
|
|
2045
|
-
local,
|
|
2046
|
-
verbose,
|
|
2047
|
-
noSDK,
|
|
2048
|
-
skipIndex
|
|
2049
|
-
}) => {
|
|
2050
|
-
var _a, _b;
|
|
2051
|
-
const rootPath2 = ctx.rootPath;
|
|
2052
|
-
if (!rootPath2) {
|
|
2053
|
-
throw new Error("Root path has not been attached");
|
|
1987
|
+
var ConfigBuilder = class {
|
|
1988
|
+
constructor(database) {
|
|
1989
|
+
this.database = database;
|
|
2054
1990
|
}
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
await
|
|
1991
|
+
async build({ dev, verbose, rootPath: rootPath2 }) {
|
|
1992
|
+
const usingTs = await isProjectTs(rootPath2);
|
|
1993
|
+
if (!rootPath2) {
|
|
1994
|
+
throw new Error("Root path has not been attached");
|
|
1995
|
+
}
|
|
1996
|
+
const tinaGeneratedPath = import_path9.default.join(rootPath2, ".tina", "__generated__");
|
|
1997
|
+
this.database.clearCache();
|
|
1998
|
+
await import_fs_extra7.default.mkdirp(tinaGeneratedPath);
|
|
1999
|
+
await this.database.store.close();
|
|
2063
2000
|
await resetGeneratedFolder({
|
|
2064
2001
|
tinaGeneratedPath,
|
|
2065
|
-
usingTs
|
|
2002
|
+
usingTs
|
|
2066
2003
|
});
|
|
2067
|
-
await store.open();
|
|
2068
|
-
const
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
const
|
|
2074
|
-
|
|
2004
|
+
await this.database.store.open();
|
|
2005
|
+
const compiledSchema = await compileSchema({
|
|
2006
|
+
verbose,
|
|
2007
|
+
dev,
|
|
2008
|
+
rootPath: rootPath2
|
|
2009
|
+
});
|
|
2010
|
+
const { graphQLSchema, tinaSchema } = await (0, import_graphql9.buildSchema)(rootPath2, this.database, ["experimentalData", "isomorphicGitBridge"]);
|
|
2011
|
+
return { schema: compiledSchema, graphQLSchema, tinaSchema };
|
|
2012
|
+
}
|
|
2013
|
+
async genTypedClient({
|
|
2014
|
+
usingTs,
|
|
2015
|
+
compiledSchema,
|
|
2016
|
+
noSDK,
|
|
2017
|
+
verbose,
|
|
2018
|
+
local
|
|
2019
|
+
}) {
|
|
2020
|
+
const astSchema = await (0, import_graphql9.getASTSchema)(this.database);
|
|
2021
|
+
await genTypes({ schema: astSchema, usingTs }, () => {
|
|
2075
2022
|
}, {
|
|
2076
2023
|
noSDK,
|
|
2077
2024
|
verbose
|
|
2078
2025
|
});
|
|
2079
|
-
await genClient({ tinaSchema:
|
|
2026
|
+
await genClient({ tinaSchema: compiledSchema, usingTs }, () => {
|
|
2080
2027
|
}, {
|
|
2081
2028
|
local
|
|
2082
2029
|
});
|
|
2083
|
-
if ((_b = (_a = ctx.schema) == null ? void 0 : _a.config) == null ? void 0 : _b.build) {
|
|
2084
|
-
await spin({
|
|
2085
|
-
text: "Building static site",
|
|
2086
|
-
waitFor: async () => {
|
|
2087
|
-
var _a2, _b2, _c, _d, _e, _f;
|
|
2088
|
-
await (0, import_app.viteBuild)({
|
|
2089
|
-
local,
|
|
2090
|
-
rootPath: rootPath2,
|
|
2091
|
-
outputFolder: (_c = (_b2 = (_a2 = ctx.schema) == null ? void 0 : _a2.config) == null ? void 0 : _b2.build) == null ? void 0 : _c.outputFolder,
|
|
2092
|
-
publicFolder: (_f = (_e = (_d = ctx.schema) == null ? void 0 : _d.config) == null ? void 0 : _e.build) == null ? void 0 : _f.publicFolder
|
|
2093
|
-
});
|
|
2094
|
-
}
|
|
2095
|
-
});
|
|
2096
|
-
console.log("\nDone building static site");
|
|
2097
|
-
}
|
|
2098
|
-
} catch (error) {
|
|
2099
|
-
throw error;
|
|
2100
|
-
} finally {
|
|
2101
|
-
if (afterBuild) {
|
|
2102
|
-
await afterBuild();
|
|
2103
|
-
}
|
|
2104
2030
|
}
|
|
2105
2031
|
};
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2032
|
+
var buildAdmin = async ({
|
|
2033
|
+
schema,
|
|
2034
|
+
local,
|
|
2035
|
+
rootPath: rootPath2
|
|
2036
|
+
}) => {
|
|
2037
|
+
var _a;
|
|
2038
|
+
if ((_a = schema == null ? void 0 : schema.config) == null ? void 0 : _a.build) {
|
|
2039
|
+
await spin({
|
|
2040
|
+
text: "Building static site",
|
|
2041
|
+
waitFor: async () => {
|
|
2042
|
+
var _a2, _b, _c, _d;
|
|
2043
|
+
await (0, import_app.viteBuild)({
|
|
2044
|
+
local,
|
|
2045
|
+
rootPath: rootPath2,
|
|
2046
|
+
outputFolder: (_b = (_a2 = schema == null ? void 0 : schema.config) == null ? void 0 : _a2.build) == null ? void 0 : _b.outputFolder,
|
|
2047
|
+
publicFolder: (_d = (_c = schema == null ? void 0 : schema.config) == null ? void 0 : _c.build) == null ? void 0 : _d.publicFolder
|
|
2048
|
+
});
|
|
2049
|
+
}
|
|
2050
|
+
});
|
|
2051
|
+
console.log("\nDone building static site");
|
|
2116
2052
|
}
|
|
2117
2053
|
};
|
|
2118
2054
|
|
|
@@ -2123,13 +2059,11 @@ var gqlPackageFile = require.resolve("@tinacms/graphql");
|
|
|
2123
2059
|
async function startServer(ctx, next, {
|
|
2124
2060
|
port = 4001,
|
|
2125
2061
|
noWatch,
|
|
2126
|
-
isomorphicGitBridge: isomorphicGitBridge2,
|
|
2127
2062
|
noSDK,
|
|
2128
2063
|
noTelemetry,
|
|
2129
2064
|
watchFolders,
|
|
2130
2065
|
verbose,
|
|
2131
|
-
dev
|
|
2132
|
-
local
|
|
2066
|
+
dev
|
|
2133
2067
|
}) {
|
|
2134
2068
|
buildLock.disable();
|
|
2135
2069
|
reBuildLock.disable();
|
|
@@ -2142,7 +2076,6 @@ async function startServer(ctx, next, {
|
|
|
2142
2076
|
});
|
|
2143
2077
|
const bridge = ctx.bridge;
|
|
2144
2078
|
const database = ctx.database;
|
|
2145
|
-
const store = ctx.store;
|
|
2146
2079
|
const shouldBuild = bridge.supportsBuilding();
|
|
2147
2080
|
let ready = false;
|
|
2148
2081
|
const state = {
|
|
@@ -2205,7 +2138,34 @@ or`);
|
|
|
2205
2138
|
});
|
|
2206
2139
|
});
|
|
2207
2140
|
};
|
|
2208
|
-
const
|
|
2141
|
+
const build2 = async () => {
|
|
2142
|
+
try {
|
|
2143
|
+
await beforeBuild();
|
|
2144
|
+
const { schema, graphQLSchema, tinaSchema } = await ctx.builder.build({
|
|
2145
|
+
rootPath: ctx.rootPath,
|
|
2146
|
+
dev,
|
|
2147
|
+
verbose
|
|
2148
|
+
});
|
|
2149
|
+
await ctx.builder.genTypedClient({
|
|
2150
|
+
compiledSchema: schema,
|
|
2151
|
+
local: true,
|
|
2152
|
+
noSDK,
|
|
2153
|
+
verbose,
|
|
2154
|
+
usingTs: ctx.usingTs
|
|
2155
|
+
});
|
|
2156
|
+
await ctx.database.indexContent({ graphQLSchema, tinaSchema });
|
|
2157
|
+
await buildAdmin({
|
|
2158
|
+
local: true,
|
|
2159
|
+
rootPath: ctx.rootPath,
|
|
2160
|
+
schema
|
|
2161
|
+
});
|
|
2162
|
+
} catch (error) {
|
|
2163
|
+
throw error;
|
|
2164
|
+
} finally {
|
|
2165
|
+
await afterBuild();
|
|
2166
|
+
}
|
|
2167
|
+
};
|
|
2168
|
+
const foldersToWatch = (watchFolders || []).map((x) => import_path12.default.join(rootPath2, x));
|
|
2209
2169
|
if (!noWatch && !process.env.CI) {
|
|
2210
2170
|
import_chokidar.default.watch([
|
|
2211
2171
|
...foldersToWatch,
|
|
@@ -2215,27 +2175,14 @@ or`);
|
|
|
2215
2175
|
ignored: [
|
|
2216
2176
|
"**/node_modules/**/*",
|
|
2217
2177
|
"**/.next/**/*",
|
|
2218
|
-
`${
|
|
2178
|
+
`${import_path12.default.resolve(rootPath2)}/.tina/__generated__/**/*`
|
|
2219
2179
|
]
|
|
2220
2180
|
}).on("ready", async () => {
|
|
2221
2181
|
if (verbose)
|
|
2222
2182
|
console.log("Generating Tina config");
|
|
2223
2183
|
try {
|
|
2224
2184
|
if (shouldBuild) {
|
|
2225
|
-
await build2(
|
|
2226
|
-
bridge,
|
|
2227
|
-
ctx,
|
|
2228
|
-
database,
|
|
2229
|
-
store,
|
|
2230
|
-
dev,
|
|
2231
|
-
isomorphicGitBridge: isomorphicGitBridge2,
|
|
2232
|
-
local: true,
|
|
2233
|
-
noSDK,
|
|
2234
|
-
noWatch,
|
|
2235
|
-
verbose,
|
|
2236
|
-
beforeBuild,
|
|
2237
|
-
afterBuild
|
|
2238
|
-
});
|
|
2185
|
+
await build2();
|
|
2239
2186
|
}
|
|
2240
2187
|
ready = true;
|
|
2241
2188
|
isReady = true;
|
|
@@ -2253,20 +2200,7 @@ or`);
|
|
|
2253
2200
|
logger.info("Tina change detected, regenerating config");
|
|
2254
2201
|
try {
|
|
2255
2202
|
if (shouldBuild) {
|
|
2256
|
-
await build2(
|
|
2257
|
-
bridge,
|
|
2258
|
-
ctx,
|
|
2259
|
-
database,
|
|
2260
|
-
store,
|
|
2261
|
-
dev,
|
|
2262
|
-
isomorphicGitBridge: isomorphicGitBridge2,
|
|
2263
|
-
local: true,
|
|
2264
|
-
noSDK,
|
|
2265
|
-
noWatch,
|
|
2266
|
-
verbose,
|
|
2267
|
-
beforeBuild,
|
|
2268
|
-
afterBuild
|
|
2269
|
-
});
|
|
2203
|
+
await build2();
|
|
2270
2204
|
}
|
|
2271
2205
|
if (isReady) {
|
|
2272
2206
|
await restart();
|
|
@@ -2289,20 +2223,7 @@ or`);
|
|
|
2289
2223
|
logger.info("Detected CI environment, omitting watch commands...");
|
|
2290
2224
|
}
|
|
2291
2225
|
if (shouldBuild) {
|
|
2292
|
-
await build2(
|
|
2293
|
-
bridge,
|
|
2294
|
-
ctx,
|
|
2295
|
-
database,
|
|
2296
|
-
store,
|
|
2297
|
-
dev,
|
|
2298
|
-
isomorphicGitBridge: isomorphicGitBridge2,
|
|
2299
|
-
local: true,
|
|
2300
|
-
noSDK,
|
|
2301
|
-
noWatch,
|
|
2302
|
-
verbose,
|
|
2303
|
-
beforeBuild,
|
|
2304
|
-
afterBuild
|
|
2305
|
-
});
|
|
2226
|
+
await build2();
|
|
2306
2227
|
}
|
|
2307
2228
|
await start();
|
|
2308
2229
|
next();
|
|
@@ -2408,16 +2329,6 @@ stack: ${code.stack || "No stack was provided"}`);
|
|
|
2408
2329
|
}
|
|
2409
2330
|
};
|
|
2410
2331
|
|
|
2411
|
-
// src/buildTina/attachPath.ts
|
|
2412
|
-
var import_fs_extra8 = __toModule(require("fs-extra"));
|
|
2413
|
-
var import_path12 = __toModule(require("path"));
|
|
2414
|
-
var attachPath = async (ctx, next, _options) => {
|
|
2415
|
-
ctx.rootPath = process.cwd();
|
|
2416
|
-
const tinaPath = import_path12.default.join(ctx.rootPath, ".tina");
|
|
2417
|
-
ctx.usingTs = await (0, import_fs_extra8.pathExists)(import_path12.default.join(tinaPath, "schema.ts")) || await (0, import_fs_extra8.pathExists)(import_path12.default.join(tinaPath, "schema.tsx"));
|
|
2418
|
-
next();
|
|
2419
|
-
};
|
|
2420
|
-
|
|
2421
2332
|
// src/cmds/baseCmds.ts
|
|
2422
2333
|
var CMD_START_SERVER = "server:start";
|
|
2423
2334
|
var CMD_DEV = "dev";
|
|
@@ -2581,7 +2492,12 @@ var baseCmds = [
|
|
|
2581
2492
|
], options)
|
|
2582
2493
|
},
|
|
2583
2494
|
{
|
|
2584
|
-
options: [
|
|
2495
|
+
options: [
|
|
2496
|
+
cleanOption,
|
|
2497
|
+
useDefaultValuesOption,
|
|
2498
|
+
noTelemetryOption,
|
|
2499
|
+
verboseOption
|
|
2500
|
+
],
|
|
2585
2501
|
command: AUDIT,
|
|
2586
2502
|
description: "Audit your schema and the files to check for errors",
|
|
2587
2503
|
action: (options) => chain([
|