@tinacms/cli 0.60.28 → 0.61.0
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 +13 -0
- package/dist/buildTina/git.d.ts +22 -0
- package/dist/buildTina/index.d.ts +42 -0
- package/dist/cmds/baseCmds.d.ts +2 -3
- package/dist/cmds/compile/defaultSchema.d.ts +1 -1
- package/dist/cmds/compile/index.d.ts +5 -2
- package/dist/cmds/init/setup-files/index.d.ts +3 -1
- package/dist/cmds/query-gen/genTypes.d.ts +8 -1
- package/dist/cmds/start-server/index.d.ts +2 -1
- package/dist/index.js +945 -713
- package/dist/utils/spinner.d.ts +15 -0
- package/package.json +7 -4
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_extra7, import_path9, MediaModel;
|
|
74
74
|
var init_media = __esm({
|
|
75
75
|
"src/server/models/media.ts"() {
|
|
76
|
-
|
|
77
|
-
|
|
76
|
+
import_fs_extra7 = __toModule(require("fs-extra"));
|
|
77
|
+
import_path9 = __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_path9.join)(this.publicFolder, this.mediaRoot, args.searchPath);
|
|
87
87
|
const searchPath = parseMediaFolder(args.searchPath);
|
|
88
|
-
const filesStr = await
|
|
88
|
+
const filesStr = await import_fs_extra7.default.readdir(folderPath);
|
|
89
89
|
const filesProm = filesStr.map(async (file) => {
|
|
90
|
-
const filePath = (0,
|
|
91
|
-
const stat = await
|
|
90
|
+
const filePath = (0, import_path9.join)(folderPath, file);
|
|
91
|
+
const stat = await import_fs_extra7.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_path9.join)(this.publicFolder, this.mediaRoot, args.searchPath);
|
|
148
|
+
await import_fs_extra7.default.stat(file);
|
|
149
|
+
await import_fs_extra7.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_path10, 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_path10 = __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_path10.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,22 +293,11 @@ var commander = __toModule(require("commander"));
|
|
|
293
293
|
|
|
294
294
|
// package.json
|
|
295
295
|
var name = "@tinacms/cli";
|
|
296
|
-
var version = "0.
|
|
296
|
+
var version = "0.61.0";
|
|
297
297
|
|
|
298
|
-
// src/cmds/
|
|
298
|
+
// src/cmds/audit/audit.ts
|
|
299
299
|
var import_graphql = __toModule(require("@tinacms/graphql"));
|
|
300
|
-
var
|
|
301
|
-
|
|
302
|
-
// src/utils/theme.ts
|
|
303
|
-
var import_chalk = __toModule(require("chalk"));
|
|
304
|
-
var successText = import_chalk.default.bold.green;
|
|
305
|
-
var dangerText = import_chalk.default.bold.red;
|
|
306
|
-
var neutralText = import_chalk.default.bold.cyan;
|
|
307
|
-
var labelText = import_chalk.default.bold;
|
|
308
|
-
var cmdText = import_chalk.default.inverse;
|
|
309
|
-
var logText = import_chalk.default.italic.gray;
|
|
310
|
-
var warnText = import_chalk.default.yellowBright.bgBlack;
|
|
311
|
-
var CONFIRMATION_TEXT = import_chalk.default.dim("enter to confirm");
|
|
300
|
+
var import_path = __toModule(require("path"));
|
|
312
301
|
|
|
313
302
|
// src/logger/index.ts
|
|
314
303
|
var import_log4js = __toModule(require("log4js"));
|
|
@@ -321,269 +310,9 @@ import_log4js.default.configure({
|
|
|
321
310
|
});
|
|
322
311
|
logger.level = "info";
|
|
323
312
|
|
|
324
|
-
// src/cmds/query-gen/attachSchema.ts
|
|
325
|
-
async function attachSchema(ctx, next, options) {
|
|
326
|
-
logger.info(logText("Building schema..."));
|
|
327
|
-
const rootPath2 = process.cwd();
|
|
328
|
-
const bridge = new import_datalayer.FilesystemBridge(rootPath2);
|
|
329
|
-
const store = new import_datalayer.FilesystemStore({ rootPath: rootPath2 });
|
|
330
|
-
const database = await (0, import_graphql.createDatabase)({ store, bridge });
|
|
331
|
-
const schema = await (0, import_graphql.buildSchema)(rootPath2, database);
|
|
332
|
-
ctx.schema = schema;
|
|
333
|
-
next();
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
// src/cmds/query-gen/genTypes.ts
|
|
337
|
-
var import_graphql6 = __toModule(require("graphql"));
|
|
338
|
-
var import_fs_extra = __toModule(require("fs-extra"));
|
|
339
|
-
|
|
340
|
-
// src/codegen/index.ts
|
|
341
|
-
var import_graphql5 = __toModule(require("graphql"));
|
|
342
|
-
|
|
343
|
-
// src/codegen/plugin.ts
|
|
344
|
-
var AddGeneratedClientFunc = (_schema, _documents, _config, _info) => {
|
|
345
|
-
return `
|
|
346
|
-
// TinaSDK generated code
|
|
347
|
-
import { createClient, TinaClient } from "tinacms/dist/client";
|
|
348
|
-
|
|
349
|
-
const generateRequester = (client: TinaClient) => {
|
|
350
|
-
const requester: (
|
|
351
|
-
doc: any,
|
|
352
|
-
vars?: any,
|
|
353
|
-
options?: any,
|
|
354
|
-
client
|
|
355
|
-
) => Promise<any> = async (doc, vars, _options) => {
|
|
356
|
-
let data = {};
|
|
357
|
-
try {
|
|
358
|
-
data = await client.request({
|
|
359
|
-
query: doc,
|
|
360
|
-
variables: vars,
|
|
361
|
-
});
|
|
362
|
-
} catch (e) {
|
|
363
|
-
// swallow errors related to document creation
|
|
364
|
-
console.warn("Warning: There was an error when fetching data");
|
|
365
|
-
console.warn(e);
|
|
366
|
-
}
|
|
367
|
-
|
|
368
|
-
return { data: data?.data, query: doc, variables: vars || {} };
|
|
369
|
-
};
|
|
370
|
-
|
|
371
|
-
return requester;
|
|
372
|
-
};
|
|
373
|
-
|
|
374
|
-
/**
|
|
375
|
-
* @experimental this class can be used but may change in the future
|
|
376
|
-
**/
|
|
377
|
-
export const ExperimentalGetTinaClient = () =>
|
|
378
|
-
getSdk(
|
|
379
|
-
generateRequester(createClient({ url: "http://localhost:4001/graphql" }))
|
|
380
|
-
);
|
|
381
|
-
|
|
382
|
-
export const queries = (client: TinaClient) => {
|
|
383
|
-
const requester = generateRequester(client);
|
|
384
|
-
return getSdk(requester);
|
|
385
|
-
};
|
|
386
|
-
`;
|
|
387
|
-
};
|
|
388
|
-
var AddGeneratedClient = {
|
|
389
|
-
plugin: AddGeneratedClientFunc
|
|
390
|
-
};
|
|
391
|
-
|
|
392
|
-
// src/codegen/index.ts
|
|
393
|
-
var import_graphql_file_loader = __toModule(require("@graphql-tools/graphql-file-loader"));
|
|
394
|
-
var import_core = __toModule(require("@graphql-codegen/core"));
|
|
395
|
-
var import_load = __toModule(require("@graphql-tools/load"));
|
|
396
|
-
var import_typescript_operations = __toModule(require("@graphql-codegen/typescript-operations"));
|
|
397
|
-
var import_typescript = __toModule(require("@graphql-codegen/typescript"));
|
|
398
|
-
|
|
399
|
-
// src/codegen/sdkPlugin/index.ts
|
|
400
|
-
var import_graphql3 = __toModule(require("graphql"));
|
|
401
|
-
var import_graphql4 = __toModule(require("graphql"));
|
|
402
|
-
var import_path = __toModule(require("path"));
|
|
403
|
-
|
|
404
|
-
// src/codegen/sdkPlugin/visitor.ts
|
|
405
|
-
var import_visitor_plugin_common = __toModule(require("@graphql-codegen/visitor-plugin-common"));
|
|
406
|
-
var import_auto_bind = __toModule(require("auto-bind"));
|
|
407
|
-
var import_graphql2 = __toModule(require("graphql"));
|
|
408
|
-
var GenericSdkVisitor = class extends import_visitor_plugin_common.ClientSideBaseVisitor {
|
|
409
|
-
constructor(schema, fragments, rawConfig) {
|
|
410
|
-
super(schema, fragments, rawConfig, {
|
|
411
|
-
usingObservableFrom: rawConfig.usingObservableFrom
|
|
412
|
-
});
|
|
413
|
-
this._operationsToInclude = [];
|
|
414
|
-
(0, import_auto_bind.default)(this);
|
|
415
|
-
if (this.config.usingObservableFrom) {
|
|
416
|
-
this._additionalImports.push(this.config.usingObservableFrom);
|
|
417
|
-
}
|
|
418
|
-
if (this.config.documentMode !== import_visitor_plugin_common.DocumentMode.string) {
|
|
419
|
-
}
|
|
420
|
-
}
|
|
421
|
-
buildOperation(node, documentVariableName, operationType, operationResultType, operationVariablesTypes) {
|
|
422
|
-
if (node.name == null) {
|
|
423
|
-
throw new Error("Plugin 'generic-sdk' cannot generate SDK for unnamed operation.\n\n" + (0, import_graphql2.print)(node));
|
|
424
|
-
} else {
|
|
425
|
-
this._operationsToInclude.push({
|
|
426
|
-
node,
|
|
427
|
-
documentVariableName,
|
|
428
|
-
operationType,
|
|
429
|
-
operationResultType: `{data: ${operationResultType}, variables: ${operationVariablesTypes}, query: string}`,
|
|
430
|
-
operationVariablesTypes
|
|
431
|
-
});
|
|
432
|
-
}
|
|
433
|
-
return null;
|
|
434
|
-
}
|
|
435
|
-
get sdkContent() {
|
|
436
|
-
const usingObservable = !!this.config.usingObservableFrom;
|
|
437
|
-
const allPossibleActions = this._operationsToInclude.map((o) => {
|
|
438
|
-
const optionalVariables = !o.node.variableDefinitions || o.node.variableDefinitions.length === 0 || o.node.variableDefinitions.every((v) => v.type.kind !== import_graphql2.Kind.NON_NULL_TYPE || v.defaultValue);
|
|
439
|
-
const returnType = usingObservable && o.operationType === "Subscription" ? "Observable" : "Promise";
|
|
440
|
-
return `${o.node.name.value}(variables${optionalVariables ? "?" : ""}: ${o.operationVariablesTypes}, options?: C): ${returnType}<${o.operationResultType}> {
|
|
441
|
-
return requester<${o.operationResultType}, ${o.operationVariablesTypes}>(${o.documentVariableName}, variables, options);
|
|
442
|
-
}`;
|
|
443
|
-
}).map((s) => (0, import_visitor_plugin_common.indentMultiline)(s, 2));
|
|
444
|
-
return `export type Requester<C= {}> = <R, V>(doc: ${this.config.documentMode === import_visitor_plugin_common.DocumentMode.string ? "string" : "DocumentNode"}, vars?: V, options?: C) => ${usingObservable ? "Promise<R> & Observable<R>" : "Promise<R>"}
|
|
445
|
-
export function getSdk<C>(requester: Requester<C>) {
|
|
446
|
-
return {
|
|
447
|
-
${allPossibleActions.join(",\n")}
|
|
448
|
-
};
|
|
449
|
-
}
|
|
450
|
-
export type Sdk = ReturnType<typeof getSdk>;`;
|
|
451
|
-
}
|
|
452
|
-
};
|
|
453
|
-
|
|
454
|
-
// src/codegen/sdkPlugin/index.ts
|
|
455
|
-
var plugin = (schema, documents, config) => {
|
|
456
|
-
const allAst = (0, import_graphql4.concatAST)(documents.reduce((prev, v) => {
|
|
457
|
-
return [...prev, v.document];
|
|
458
|
-
}, []));
|
|
459
|
-
const allFragments = [
|
|
460
|
-
...allAst.definitions.filter((d) => d.kind === import_graphql4.Kind.FRAGMENT_DEFINITION).map((fragmentDef) => ({
|
|
461
|
-
node: fragmentDef,
|
|
462
|
-
name: fragmentDef.name.value,
|
|
463
|
-
onType: fragmentDef.typeCondition.name.value,
|
|
464
|
-
isExternal: false
|
|
465
|
-
})),
|
|
466
|
-
...config.externalFragments || []
|
|
467
|
-
];
|
|
468
|
-
const visitor = new GenericSdkVisitor(schema, allFragments, config);
|
|
469
|
-
const visitorResult = (0, import_graphql3.visit)(allAst, { leave: visitor });
|
|
470
|
-
return {
|
|
471
|
-
content: [
|
|
472
|
-
visitor.fragments,
|
|
473
|
-
...visitorResult.definitions.filter((t) => typeof t === "string"),
|
|
474
|
-
visitor.sdkContent
|
|
475
|
-
].join("\n")
|
|
476
|
-
};
|
|
477
|
-
};
|
|
478
|
-
|
|
479
|
-
// src/codegen/index.ts
|
|
480
|
-
var generateTypes = async (schema, queryPathGlob = process.cwd(), fragDocPath = process.cwd(), options = {
|
|
481
|
-
noSDK: false,
|
|
482
|
-
verbose: false
|
|
483
|
-
}) => {
|
|
484
|
-
if (options.verbose)
|
|
485
|
-
logger.info("Generating types...");
|
|
486
|
-
try {
|
|
487
|
-
let docs = [];
|
|
488
|
-
let fragDocs = [];
|
|
489
|
-
try {
|
|
490
|
-
if (!options.noSDK) {
|
|
491
|
-
docs = await (0, import_load.loadDocuments)(queryPathGlob, {
|
|
492
|
-
loaders: [new import_graphql_file_loader.GraphQLFileLoader()]
|
|
493
|
-
});
|
|
494
|
-
}
|
|
495
|
-
} catch (e) {
|
|
496
|
-
let showErrorMessage = true;
|
|
497
|
-
const message = e.message || "";
|
|
498
|
-
if (message.includes("Unable to find any GraphQL type definitions for the following pointers:")) {
|
|
499
|
-
showErrorMessage = false;
|
|
500
|
-
}
|
|
501
|
-
if (showErrorMessage) {
|
|
502
|
-
console.error(e);
|
|
503
|
-
}
|
|
504
|
-
}
|
|
505
|
-
try {
|
|
506
|
-
if (!options.noSDK) {
|
|
507
|
-
fragDocs = await (0, import_load.loadDocuments)(fragDocPath, {
|
|
508
|
-
loaders: [new import_graphql_file_loader.GraphQLFileLoader()]
|
|
509
|
-
});
|
|
510
|
-
}
|
|
511
|
-
} catch (error) {
|
|
512
|
-
console.error(error);
|
|
513
|
-
}
|
|
514
|
-
const res = await (0, import_core.codegen)({
|
|
515
|
-
filename: process.cwd(),
|
|
516
|
-
schema: (0, import_graphql5.parse)((0, import_graphql5.printSchema)(schema)),
|
|
517
|
-
documents: [...docs, ...fragDocs],
|
|
518
|
-
config: {},
|
|
519
|
-
plugins: [
|
|
520
|
-
{ typescript: {} },
|
|
521
|
-
{ typescriptOperations: {} },
|
|
522
|
-
{
|
|
523
|
-
typescriptSdk: {}
|
|
524
|
-
},
|
|
525
|
-
{ AddGeneratedClient: {} }
|
|
526
|
-
],
|
|
527
|
-
pluginMap: {
|
|
528
|
-
typescript: {
|
|
529
|
-
plugin: import_typescript.plugin
|
|
530
|
-
},
|
|
531
|
-
typescriptOperations: {
|
|
532
|
-
plugin: import_typescript_operations.plugin
|
|
533
|
-
},
|
|
534
|
-
typescriptSdk: {
|
|
535
|
-
plugin
|
|
536
|
-
},
|
|
537
|
-
AddGeneratedClient
|
|
538
|
-
}
|
|
539
|
-
});
|
|
540
|
-
return res;
|
|
541
|
-
} catch (e) {
|
|
542
|
-
console.error(e);
|
|
543
|
-
}
|
|
544
|
-
};
|
|
545
|
-
|
|
546
|
-
// src/cmds/query-gen/genTypes.ts
|
|
547
|
-
async function genTypes({ schema }, next, options) {
|
|
548
|
-
const typesPath = process.cwd() + "/.tina/__generated__/types.ts";
|
|
549
|
-
const fragPath = process.cwd() + "/.tina/__generated__/*.{graphql,gql}";
|
|
550
|
-
const queryPathGlob = process.cwd() + "/.tina/queries/**/*.{graphql,gql}";
|
|
551
|
-
const typescriptTypes = await generateTypes(schema, queryPathGlob, fragPath, options);
|
|
552
|
-
await import_fs_extra.default.outputFile(typesPath, `//@ts-nocheck
|
|
553
|
-
// DO NOT MODIFY THIS FILE. This file is automatically generated by Tina
|
|
554
|
-
export function gql(strings: TemplateStringsArray, ...args: string[]): string {
|
|
555
|
-
let str = ''
|
|
556
|
-
strings.forEach((string, i) => {
|
|
557
|
-
str += string + (args[i] || '')
|
|
558
|
-
})
|
|
559
|
-
return str
|
|
560
|
-
}
|
|
561
|
-
${typescriptTypes}
|
|
562
|
-
`);
|
|
563
|
-
logger.info(` Typescript types => ${logText(typesPath)}`);
|
|
564
|
-
const schemaString = await (0, import_graphql6.printSchema)(schema);
|
|
565
|
-
const schemaPath = process.cwd() + "/.tina/__generated__/schema.gql";
|
|
566
|
-
await import_fs_extra.default.outputFile(schemaPath, `# DO NOT MODIFY THIS FILE. This file is automatically generated by Tina
|
|
567
|
-
${schemaString}
|
|
568
|
-
schema {
|
|
569
|
-
query: Query
|
|
570
|
-
mutation: Mutation
|
|
571
|
-
}
|
|
572
|
-
`);
|
|
573
|
-
logger.info(` GraphQL types ====> ${logText(schemaPath)}
|
|
574
|
-
`);
|
|
575
|
-
next();
|
|
576
|
-
}
|
|
577
|
-
|
|
578
|
-
// src/cmds/audit/index.ts
|
|
579
|
-
var import_graphql9 = __toModule(require("@tinacms/graphql"));
|
|
580
|
-
var import_datalayer2 = __toModule(require("@tinacms/datalayer"));
|
|
581
|
-
|
|
582
313
|
// src/cmds/audit/audit.ts
|
|
583
|
-
var
|
|
584
|
-
var
|
|
585
|
-
var import_graphql8 = __toModule(require("@tinacms/graphql"));
|
|
586
|
-
var import_chalk2 = __toModule(require("chalk"));
|
|
314
|
+
var import_graphql2 = __toModule(require("@tinacms/graphql"));
|
|
315
|
+
var import_chalk = __toModule(require("chalk"));
|
|
587
316
|
var auditCollection = async (args) => {
|
|
588
317
|
let warning = false;
|
|
589
318
|
const { collection, database, rootPath: rootPath2 } = args;
|
|
@@ -606,7 +335,7 @@ var auditCollection = async (args) => {
|
|
|
606
335
|
}
|
|
607
336
|
}
|
|
608
337
|
`;
|
|
609
|
-
const result = await (0,
|
|
338
|
+
const result = await (0, import_graphql.resolve)({
|
|
610
339
|
database,
|
|
611
340
|
query,
|
|
612
341
|
variables: {}
|
|
@@ -617,9 +346,9 @@ var auditCollection = async (args) => {
|
|
|
617
346
|
const node = x.node;
|
|
618
347
|
if (node._sys.extension.replace(".", "") !== format) {
|
|
619
348
|
warning = true;
|
|
620
|
-
logger.warn(
|
|
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}\`
|
|
621
350
|
|
|
622
|
-
location: ${
|
|
351
|
+
location: ${import_path.default.join(rootPath2, node._sys.path)}`));
|
|
623
352
|
}
|
|
624
353
|
});
|
|
625
354
|
return warning;
|
|
@@ -646,7 +375,7 @@ var auditDocuments = async (args) => {
|
|
|
646
375
|
}
|
|
647
376
|
}
|
|
648
377
|
`;
|
|
649
|
-
const result = await (0,
|
|
378
|
+
const result = await (0, import_graphql.resolve)({
|
|
650
379
|
database,
|
|
651
380
|
query,
|
|
652
381
|
variables: {}
|
|
@@ -655,7 +384,7 @@ var auditDocuments = async (args) => {
|
|
|
655
384
|
const documents = result.data.collection.documents.edges;
|
|
656
385
|
for (let i = 0; i < documents.length; i++) {
|
|
657
386
|
const node = documents[i].node;
|
|
658
|
-
const fullPath =
|
|
387
|
+
const fullPath = import_path.default.join(rootPath2, node._sys.path);
|
|
659
388
|
logger.info(`Checking document: ${fullPath}`);
|
|
660
389
|
const documentQuery = `query {
|
|
661
390
|
document(collection: "${collection.name}", relativePath: "${node._sys.relativePath}") {
|
|
@@ -665,7 +394,7 @@ var auditDocuments = async (args) => {
|
|
|
665
394
|
}
|
|
666
395
|
}
|
|
667
396
|
}`;
|
|
668
|
-
const docResult = await (0,
|
|
397
|
+
const docResult = await (0, import_graphql.resolve)({
|
|
669
398
|
database,
|
|
670
399
|
query: documentQuery,
|
|
671
400
|
variables: {}
|
|
@@ -690,7 +419,7 @@ var auditDocuments = async (args) => {
|
|
|
690
419
|
params: $params
|
|
691
420
|
){__typename}
|
|
692
421
|
}`;
|
|
693
|
-
const mutationRes = await (0,
|
|
422
|
+
const mutationRes = await (0, import_graphql.resolve)({
|
|
694
423
|
database,
|
|
695
424
|
query: mutation,
|
|
696
425
|
variables: {
|
|
@@ -704,7 +433,7 @@ var auditDocuments = async (args) => {
|
|
|
704
433
|
if (mutationRes.errors) {
|
|
705
434
|
mutationRes.errors.forEach((err) => {
|
|
706
435
|
error = true;
|
|
707
|
-
logger.error(
|
|
436
|
+
logger.error(import_chalk.default.red(err.message));
|
|
708
437
|
});
|
|
709
438
|
}
|
|
710
439
|
}
|
|
@@ -724,7 +453,7 @@ var transformParams = (data) => {
|
|
|
724
453
|
return data.map((item) => transformParams(item));
|
|
725
454
|
}
|
|
726
455
|
try {
|
|
727
|
-
(0,
|
|
456
|
+
(0, import_graphql2.assertShape)(data, (yup) => yup.object({ _template: yup.string().required() }));
|
|
728
457
|
const _a = data, { _template, __typename } = _a, rest = __objRest(_a, ["_template", "__typename"]);
|
|
729
458
|
const nested = transformParams(rest);
|
|
730
459
|
return { [_template]: nested };
|
|
@@ -755,7 +484,7 @@ function filterObject(obj) {
|
|
|
755
484
|
}
|
|
756
485
|
|
|
757
486
|
// src/cmds/audit/index.ts
|
|
758
|
-
var
|
|
487
|
+
var import_chalk2 = __toModule(require("chalk"));
|
|
759
488
|
var import_prompts = __toModule(require("prompts"));
|
|
760
489
|
var import_metrics = __toModule(require("@tinacms/metrics"));
|
|
761
490
|
var rootPath = process.cwd();
|
|
@@ -769,7 +498,7 @@ var audit = async (ctx, next, options) => {
|
|
|
769
498
|
}
|
|
770
499
|
});
|
|
771
500
|
if (options.clean) {
|
|
772
|
-
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 ${
|
|
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 ${import_chalk2.default.bold("clean git tree")} so unwanted changes can be undone.
|
|
773
502
|
|
|
774
503
|
`);
|
|
775
504
|
const res = await (0, import_prompts.default)({
|
|
@@ -778,16 +507,14 @@ var audit = async (ctx, next, options) => {
|
|
|
778
507
|
message: `Do you want to continue?`
|
|
779
508
|
});
|
|
780
509
|
if (!res.useClean) {
|
|
781
|
-
logger.warn(
|
|
510
|
+
logger.warn(import_chalk2.default.yellowBright("\u26A0\uFE0F Audit not complete"));
|
|
782
511
|
process.exit(0);
|
|
783
512
|
}
|
|
784
513
|
}
|
|
785
514
|
if (options.useDefaultValues && !options.clean) {
|
|
786
|
-
logger.warn(
|
|
515
|
+
logger.warn(import_chalk2.default.yellowBright("WARNING: using the `--useDefaultValues` without the `--clean` flag has no effect. Please re-run audit and add the `--clean` flag"));
|
|
787
516
|
}
|
|
788
|
-
const
|
|
789
|
-
const store = options.clean ? new import_datalayer2.FilesystemStore({ rootPath }) : new import_datalayer2.AuditFilesystemStore({ rootPath });
|
|
790
|
-
const database = await (0, import_graphql9.createDatabase)({ store, bridge });
|
|
517
|
+
const database = ctx.database;
|
|
791
518
|
const schema = await database.getSchema();
|
|
792
519
|
const collections = schema.getCollections();
|
|
793
520
|
let warning = false;
|
|
@@ -815,17 +542,17 @@ var audit = async (ctx, next, options) => {
|
|
|
815
542
|
};
|
|
816
543
|
var printFinalMessage = async (ctx, next, _options) => {
|
|
817
544
|
if (ctx.error) {
|
|
818
|
-
logger.error(
|
|
545
|
+
logger.error(import_chalk2.default.redBright(`\u203C\uFE0F Audit ${import_chalk2.default.bold("failed")} with errors`));
|
|
819
546
|
} else if (ctx.warning) {
|
|
820
|
-
logger.warn(
|
|
547
|
+
logger.warn(import_chalk2.default.yellowBright("\u26A0\uFE0F Audit passed with warnings"));
|
|
821
548
|
} else {
|
|
822
|
-
logger.info(
|
|
549
|
+
logger.info(import_chalk2.default.greenBright("\u2705 Audit passed"));
|
|
823
550
|
}
|
|
824
551
|
next();
|
|
825
552
|
};
|
|
826
553
|
|
|
827
554
|
// src/cmds/init/setup-files/index.ts
|
|
828
|
-
var
|
|
555
|
+
var import_chalk3 = __toModule(require("chalk"));
|
|
829
556
|
var adminPage = `import { TinaAdmin } from 'tinacms';
|
|
830
557
|
export default TinaAdmin;
|
|
831
558
|
`;
|
|
@@ -857,65 +584,58 @@ mille rigidi sub taurum.
|
|
|
857
584
|
|
|
858
585
|
|
|
859
586
|
`;
|
|
860
|
-
var nextPostPage = (
|
|
587
|
+
var nextPostPage = ({
|
|
588
|
+
usingSrc
|
|
589
|
+
}) => `// THIS FILE HAS BEEN GENERATED WITH THE TINA CLI.
|
|
861
590
|
// This is a demo file once you have tina setup feel free to delete this file
|
|
862
|
-
|
|
863
|
-
import
|
|
864
|
-
import
|
|
865
|
-
import {
|
|
866
|
-
import { useTina } from "tinacms/dist/edit-state";
|
|
591
|
+
|
|
592
|
+
import Head from 'next/head'
|
|
593
|
+
import { createGlobalStyle } from 'styled-components'
|
|
594
|
+
import { useTina } from 'tinacms/dist/edit-state'
|
|
867
595
|
import { TinaMarkdown } from 'tinacms/dist/rich-text'
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
query BlogPostQuery($relativePath: String!) {
|
|
871
|
-
posts(relativePath: $relativePath) {
|
|
872
|
-
title
|
|
873
|
-
body
|
|
874
|
-
}
|
|
875
|
-
}
|
|
876
|
-
\`
|
|
877
|
-
|
|
596
|
+
import client from '${usingSrc ? "../" : ""}../../../.tina/__generated__/client'
|
|
597
|
+
|
|
878
598
|
// Styles for markdown
|
|
879
599
|
const GlobalStyle = createGlobalStyle\`
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
600
|
+
h1,h2,h3,h4,h5 {
|
|
601
|
+
margin-bottom: 1.5rem;
|
|
602
|
+
margin-top: 1.5rem;
|
|
603
|
+
}
|
|
604
|
+
blockquote {
|
|
605
|
+
background-color: rgb(209,250,229);
|
|
606
|
+
}
|
|
607
|
+
h1 {
|
|
608
|
+
font-size: 45px;
|
|
609
|
+
}
|
|
610
|
+
h2 {
|
|
611
|
+
font-size: 35px;
|
|
612
|
+
}
|
|
613
|
+
h3 {
|
|
614
|
+
font-size: 25px;
|
|
615
|
+
}
|
|
616
|
+
h4 {
|
|
617
|
+
font-size: 22px;
|
|
618
|
+
}
|
|
619
|
+
ul {
|
|
620
|
+
padding-left: 0;
|
|
621
|
+
}
|
|
622
|
+
li {
|
|
623
|
+
list-style-type: none;
|
|
624
|
+
}
|
|
625
|
+
a {
|
|
626
|
+
font-weight: bold;
|
|
627
|
+
color: rgb(59,130,246);
|
|
628
|
+
text-decoration: underline;
|
|
629
|
+
}
|
|
630
|
+
\`
|
|
631
|
+
|
|
912
632
|
const BlogPage = (props) => {
|
|
913
633
|
const { data } = useTina({
|
|
914
|
-
query,
|
|
634
|
+
query: props.query,
|
|
915
635
|
variables: props.variables,
|
|
916
636
|
data: props.data,
|
|
917
|
-
})
|
|
918
|
-
|
|
637
|
+
})
|
|
638
|
+
|
|
919
639
|
return (
|
|
920
640
|
<>
|
|
921
641
|
<Head>
|
|
@@ -931,15 +651,13 @@ var nextPostPage = () => `// THIS FILE HAS BEEN GENERATED WITH THE TINA CLI.
|
|
|
931
651
|
<div>
|
|
932
652
|
<div
|
|
933
653
|
style={{
|
|
934
|
-
textAlign:
|
|
654
|
+
textAlign: 'center',
|
|
935
655
|
}}
|
|
936
656
|
>
|
|
937
657
|
<h1 className="text-3xl m-8 text-center leading-8 font-extrabold tracking-tight text-gray-900 sm:text-4xl">
|
|
938
|
-
{data.
|
|
658
|
+
{data.post.title}
|
|
939
659
|
</h1>
|
|
940
|
-
<ContentSection
|
|
941
|
-
content={data.posts.body}
|
|
942
|
-
></ContentSection>
|
|
660
|
+
<ContentSection content={data.post.body}></ContentSection>
|
|
943
661
|
</div>
|
|
944
662
|
<div className="bg-green-100 text-center">
|
|
945
663
|
Lost and looking for a place to start?
|
|
@@ -947,79 +665,65 @@ var nextPostPage = () => `// THIS FILE HAS BEEN GENERATED WITH THE TINA CLI.
|
|
|
947
665
|
href="https://tina.io/guides/tina-cloud/getting-started/overview/"
|
|
948
666
|
className="text-blue-500 underline"
|
|
949
667
|
>
|
|
950
|
-
{
|
|
668
|
+
{' '}
|
|
951
669
|
Check out this guide
|
|
952
|
-
</a>{
|
|
670
|
+
</a>{' '}
|
|
953
671
|
to see how add TinaCMS to an existing Next.js site.
|
|
954
672
|
</div>
|
|
955
673
|
</div>
|
|
956
674
|
</>
|
|
957
|
-
)
|
|
958
|
-
}
|
|
959
|
-
|
|
675
|
+
)
|
|
676
|
+
}
|
|
677
|
+
|
|
960
678
|
export const getStaticProps = async ({ params }) => {
|
|
961
|
-
const variables = { relativePath: \`\${params.filename}.md\` }
|
|
962
679
|
let data = {}
|
|
680
|
+
let query = {}
|
|
681
|
+
let variables = { relativePath: \`\${params.filename}.mdx\` }
|
|
963
682
|
try {
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
683
|
+
const res = await client.queries.post(variables)
|
|
684
|
+
query = res.query
|
|
685
|
+
data = res.data
|
|
686
|
+
variables = res.variables
|
|
968
687
|
} catch {
|
|
969
688
|
// swallow errors related to document creation
|
|
970
689
|
}
|
|
971
|
-
|
|
690
|
+
|
|
972
691
|
return {
|
|
973
|
-
props: {
|
|
974
|
-
variables,
|
|
975
|
-
data,
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
postsConnection {
|
|
986
|
-
edges {
|
|
987
|
-
node {
|
|
988
|
-
...on Document {
|
|
989
|
-
_sys {
|
|
990
|
-
filename
|
|
991
|
-
}
|
|
992
|
-
}
|
|
993
|
-
}
|
|
994
|
-
}
|
|
995
|
-
}
|
|
996
|
-
}
|
|
997
|
-
\`,
|
|
998
|
-
}));
|
|
999
|
-
|
|
692
|
+
props: {
|
|
693
|
+
variables: variables,
|
|
694
|
+
data: data,
|
|
695
|
+
query: query,
|
|
696
|
+
//myOtherProp: 'some-other-data',
|
|
697
|
+
},
|
|
698
|
+
}
|
|
699
|
+
}
|
|
700
|
+
|
|
701
|
+
export const getStaticPaths = async () => {
|
|
702
|
+
const postsListData = await client.queries.postConnection()
|
|
703
|
+
|
|
1000
704
|
return {
|
|
1001
|
-
paths: postsListData.
|
|
705
|
+
paths: postsListData.data.postConnection.edges.map((post) => ({
|
|
1002
706
|
params: { filename: post.node._sys.filename },
|
|
1003
707
|
})),
|
|
1004
708
|
fallback: false,
|
|
1005
|
-
}
|
|
1006
|
-
}
|
|
1007
|
-
|
|
1008
|
-
export default BlogPage
|
|
1009
|
-
|
|
1010
|
-
const PageSection = props => {
|
|
709
|
+
}
|
|
710
|
+
}
|
|
711
|
+
|
|
712
|
+
export default BlogPage
|
|
713
|
+
|
|
714
|
+
const PageSection = (props) => {
|
|
1011
715
|
return (
|
|
1012
716
|
<>
|
|
1013
|
-
<h2>{
|
|
1014
|
-
<p>{
|
|
717
|
+
<h2>{props.heading}</h2>
|
|
718
|
+
<p>{props.content}</p>
|
|
1015
719
|
</>
|
|
1016
720
|
)
|
|
1017
721
|
}
|
|
1018
|
-
|
|
722
|
+
|
|
1019
723
|
const components = {
|
|
1020
724
|
PageSection: PageSection,
|
|
1021
725
|
}
|
|
1022
|
-
|
|
726
|
+
|
|
1023
727
|
const ContentSection = ({ content }) => {
|
|
1024
728
|
return (
|
|
1025
729
|
<div className="relative py-16 bg-white overflow-hidden">
|
|
@@ -1128,15 +832,13 @@ var nextPostPage = () => `// THIS FILE HAS BEEN GENERATED WITH THE TINA CLI.
|
|
|
1128
832
|
</div>
|
|
1129
833
|
<div className="relative px-4 sm:px-6 lg:px-8">
|
|
1130
834
|
<div className="text-lg max-w-prose mx-auto">
|
|
1131
|
-
<TinaMarkdown components={components} content={content}/>
|
|
835
|
+
<TinaMarkdown components={components} content={content} />
|
|
1132
836
|
<GlobalStyle />
|
|
1133
837
|
</div>
|
|
1134
838
|
</div>
|
|
1135
839
|
</div>
|
|
1136
|
-
)
|
|
1137
|
-
}
|
|
1138
|
-
|
|
1139
|
-
`;
|
|
840
|
+
)
|
|
841
|
+
}`;
|
|
1140
842
|
var AppJsContent = (usingSrc, extraImports) => {
|
|
1141
843
|
const importLine = `import Tina from '${usingSrc ? "../" : ""}../.tina/components/TinaDynamicProvider.js'`;
|
|
1142
844
|
return `${importLine}
|
|
@@ -1154,15 +856,15 @@ export default App
|
|
|
1154
856
|
`;
|
|
1155
857
|
};
|
|
1156
858
|
var AppJsContentPrintout = (usingSrc, extraImports) => {
|
|
1157
|
-
const importLine =
|
|
859
|
+
const importLine = import_chalk3.default.green(`+ import Tina from '${usingSrc ? "../" : ""}../.tina/components/TinaDynamicProvider.js'`);
|
|
1158
860
|
return `${importLine}
|
|
1159
861
|
${extraImports || ""}
|
|
1160
862
|
|
|
1161
863
|
const App = ({ Component, pageProps }) => {
|
|
1162
864
|
return (
|
|
1163
|
-
${
|
|
865
|
+
${import_chalk3.default.green("+ <Tina>")}
|
|
1164
866
|
<Component {...pageProps} />
|
|
1165
|
-
${
|
|
867
|
+
${import_chalk3.default.green("+ </Tina>")}
|
|
1166
868
|
)
|
|
1167
869
|
}
|
|
1168
870
|
|
|
@@ -1203,24 +905,35 @@ const DynamicTina = ({ children }) => {
|
|
|
1203
905
|
export default DynamicTina
|
|
1204
906
|
`;
|
|
1205
907
|
|
|
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
|
+
|
|
1206
919
|
// src/utils/script-helpers.ts
|
|
1207
920
|
function generateGqlScript(scriptValue) {
|
|
1208
|
-
return `tinacms
|
|
921
|
+
return `tinacms dev -c "${scriptValue}"`;
|
|
1209
922
|
}
|
|
1210
923
|
function extendNextScripts(scripts) {
|
|
1211
924
|
return __spreadProps(__spreadValues({}, scripts), {
|
|
1212
|
-
dev: generateGqlScript(scripts.dev || "next dev"),
|
|
1213
|
-
build:
|
|
1214
|
-
start:
|
|
925
|
+
dev: generateGqlScript((scripts == null ? void 0 : scripts.dev) || "next dev"),
|
|
926
|
+
build: `tinacms build && ${(scripts == null ? void 0 : scripts.build) || "next build"}`,
|
|
927
|
+
start: `tinacms build && ${(scripts == null ? void 0 : scripts.start) || "next start"}`
|
|
1215
928
|
});
|
|
1216
929
|
}
|
|
1217
930
|
|
|
1218
931
|
// src/cmds/init/index.ts
|
|
1219
|
-
var
|
|
932
|
+
var import_fs_extra = __toModule(require("fs-extra"));
|
|
1220
933
|
var import_progress = __toModule(require("progress"));
|
|
1221
934
|
var import_metrics2 = __toModule(require("@tinacms/metrics"));
|
|
1222
935
|
var import_chalk5 = __toModule(require("chalk"));
|
|
1223
|
-
var
|
|
936
|
+
var import_path2 = __toModule(require("path"));
|
|
1224
937
|
var import_prompts2 = __toModule(require("prompts"));
|
|
1225
938
|
function execShellCommand(cmd) {
|
|
1226
939
|
const exec = require("child_process").exec;
|
|
@@ -1247,7 +960,10 @@ async function initTina(ctx, next, options) {
|
|
|
1247
960
|
var MIN_REACT_VERSION = ">=16.14.0";
|
|
1248
961
|
async function checkDeps(ctx, next, options) {
|
|
1249
962
|
const bar = new import_progress.default("Checking dependencies. :prog", 1);
|
|
1250
|
-
|
|
963
|
+
if (!import_fs_extra.default.existsSync(packageJSONPath)) {
|
|
964
|
+
throw new Error("No package.json Found. Please run tinacms init at the root of your app");
|
|
965
|
+
}
|
|
966
|
+
const packageJSON = JSON.parse((await import_fs_extra.default.readFileSync(packageJSONPath)).toString());
|
|
1251
967
|
if (!checkPackage(packageJSON, "react") || !checkPackage(packageJSON, "react-dom")) {
|
|
1252
968
|
const message = `Unable to initialize Tina due to outdated dependencies, try upgrading the following packages:
|
|
1253
969
|
"react@${MIN_REACT_VERSION}"
|
|
@@ -1269,6 +985,9 @@ var checkPackage = (packageJSON, packageName) => {
|
|
|
1269
985
|
strippedVersion = version2.replace(/^[^a-zA-Z0-9]*|[^a-zA-Z0-9]*$/g, "");
|
|
1270
986
|
}
|
|
1271
987
|
});
|
|
988
|
+
if (!strippedVersion) {
|
|
989
|
+
throw new Error(`Please add ${packageName} to your project`);
|
|
990
|
+
}
|
|
1272
991
|
return checkVersion(strippedVersion);
|
|
1273
992
|
};
|
|
1274
993
|
var checkVersion = (version2) => {
|
|
@@ -1313,33 +1032,33 @@ async function installDeps(ctx, next, options) {
|
|
|
1313
1032
|
next();
|
|
1314
1033
|
}
|
|
1315
1034
|
var baseDir = process.cwd();
|
|
1316
|
-
var packageJSONPath =
|
|
1317
|
-
var blogContentPath =
|
|
1318
|
-
var blogPostPath =
|
|
1319
|
-
var TinaFolder =
|
|
1320
|
-
var componentFolder =
|
|
1321
|
-
var TinaProviderPath =
|
|
1322
|
-
var TinaDynamicProvider =
|
|
1035
|
+
var packageJSONPath = import_path2.default.join(baseDir, "package.json");
|
|
1036
|
+
var blogContentPath = import_path2.default.join(baseDir, "content", "posts");
|
|
1037
|
+
var blogPostPath = import_path2.default.join(blogContentPath, "HelloWorld.mdx");
|
|
1038
|
+
var TinaFolder = import_path2.default.join(baseDir, ".tina");
|
|
1039
|
+
var componentFolder = import_path2.default.join(TinaFolder, "components");
|
|
1040
|
+
var TinaProviderPath = import_path2.default.join(componentFolder, "TinaProvider.js");
|
|
1041
|
+
var TinaDynamicProvider = import_path2.default.join(componentFolder, "TinaDynamicProvider.js");
|
|
1323
1042
|
async function tinaSetup(_ctx, next, _options) {
|
|
1324
|
-
const usingSrc = !
|
|
1325
|
-
if (!
|
|
1043
|
+
const usingSrc = !import_fs_extra.default.pathExistsSync(import_path2.default.join(baseDir, "pages"));
|
|
1044
|
+
if (!import_fs_extra.default.pathExistsSync(blogPostPath)) {
|
|
1326
1045
|
logger.info(logText("Adding a content folder..."));
|
|
1327
|
-
|
|
1328
|
-
|
|
1046
|
+
import_fs_extra.default.mkdirpSync(blogContentPath);
|
|
1047
|
+
import_fs_extra.default.writeFileSync(blogPostPath, blogPost);
|
|
1329
1048
|
}
|
|
1330
|
-
if (!
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1049
|
+
if (!import_fs_extra.default.existsSync(TinaProviderPath) && !import_fs_extra.default.existsSync(TinaDynamicProvider)) {
|
|
1050
|
+
import_fs_extra.default.mkdirpSync(componentFolder);
|
|
1051
|
+
import_fs_extra.default.writeFileSync(TinaProviderPath, TinaProvider.replace(/'\.\.\/schema\.ts'/, `'../schema.${_ctx.schemaFileType || "ts"}'`));
|
|
1052
|
+
import_fs_extra.default.writeFileSync(TinaDynamicProvider, TinaProviderDynamic);
|
|
1334
1053
|
}
|
|
1335
1054
|
logger.level = "info";
|
|
1336
|
-
const pagesPath =
|
|
1337
|
-
const appPath =
|
|
1338
|
-
const appPathTS =
|
|
1339
|
-
const appExtension =
|
|
1340
|
-
if (!
|
|
1055
|
+
const pagesPath = import_path2.default.join(baseDir, usingSrc ? "src" : "", "pages");
|
|
1056
|
+
const appPath = import_path2.default.join(pagesPath, "_app.js");
|
|
1057
|
+
const appPathTS = import_path2.default.join(pagesPath, "_app.tsx");
|
|
1058
|
+
const appExtension = import_fs_extra.default.existsSync(appPath) ? ".js" : ".tsx";
|
|
1059
|
+
if (!import_fs_extra.default.pathExistsSync(appPath) && !import_fs_extra.default.pathExistsSync(appPathTS)) {
|
|
1341
1060
|
logger.info(logText("Adding _app.js ... \u2705"));
|
|
1342
|
-
|
|
1061
|
+
import_fs_extra.default.writeFileSync(appPath, AppJsContent(usingSrc));
|
|
1343
1062
|
} else {
|
|
1344
1063
|
const override = await (0, import_prompts2.default)({
|
|
1345
1064
|
name: "res",
|
|
@@ -1349,40 +1068,43 @@ async function tinaSetup(_ctx, next, _options) {
|
|
|
1349
1068
|
_ctx.overrideApp = override.res;
|
|
1350
1069
|
if (override.res) {
|
|
1351
1070
|
logger.info(logText(`Adding _app${appExtension} ... \u2705`));
|
|
1352
|
-
const appPathWithExtension =
|
|
1353
|
-
const fileContent =
|
|
1071
|
+
const appPathWithExtension = import_path2.default.join(pagesPath, `_app${appExtension}`);
|
|
1072
|
+
const fileContent = import_fs_extra.default.pathExistsSync(appPath) ? (0, import_fs_extra.readFileSync)(appPath) : (0, import_fs_extra.readFileSync)(appPathTS);
|
|
1354
1073
|
const matches = [
|
|
1355
1074
|
...fileContent.toString().matchAll(/^.*import.*\.css("|').*$/gm)
|
|
1356
1075
|
];
|
|
1357
1076
|
const primaryMatches = matches.map((x) => x[0]);
|
|
1358
|
-
|
|
1077
|
+
import_fs_extra.default.writeFileSync(appPathWithExtension, AppJsContent(usingSrc, primaryMatches.join("\n")));
|
|
1359
1078
|
}
|
|
1360
1079
|
}
|
|
1361
|
-
const tinaBlogPagePath =
|
|
1362
|
-
const tinaBlogPagePathFile =
|
|
1363
|
-
if (!
|
|
1364
|
-
|
|
1365
|
-
|
|
1080
|
+
const tinaBlogPagePath = import_path2.default.join(pagesPath, "demo", "blog");
|
|
1081
|
+
const tinaBlogPagePathFile = import_path2.default.join(tinaBlogPagePath, "[filename].js");
|
|
1082
|
+
if (!import_fs_extra.default.pathExistsSync(tinaBlogPagePathFile)) {
|
|
1083
|
+
import_fs_extra.default.mkdirpSync(tinaBlogPagePath);
|
|
1084
|
+
import_fs_extra.default.writeFileSync(tinaBlogPagePathFile, nextPostPage({ usingSrc }));
|
|
1366
1085
|
}
|
|
1367
1086
|
logger.info("Adding a content folder... \u2705");
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
scripts
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1087
|
+
if (!import_fs_extra.default.existsSync(packageJSONPath)) {
|
|
1088
|
+
throw new Error("No package.json Found. Please run tinacms init at the root of your app");
|
|
1089
|
+
} else {
|
|
1090
|
+
const pack = JSON.parse((0, import_fs_extra.readFileSync)(packageJSONPath).toString());
|
|
1091
|
+
const oldScripts = pack.scripts || {};
|
|
1092
|
+
const newPack = JSON.stringify(__spreadProps(__spreadValues({}, pack), {
|
|
1093
|
+
scripts: extendNextScripts(oldScripts)
|
|
1094
|
+
}), null, 2);
|
|
1095
|
+
(0, import_fs_extra.writeFileSync)(packageJSONPath, newPack);
|
|
1096
|
+
}
|
|
1097
|
+
const adminPath = import_path2.default.join(pagesPath, "admin.js");
|
|
1098
|
+
if (import_fs_extra.default.pathExistsSync(import_path2.default.join(pagesPath, "admin"))) {
|
|
1377
1099
|
logger.warn(`Unable to add /pages/admin.js, this path already exists.
|
|
1378
1100
|
Learn more about toggling edit-mode at https://tina.io/docs/tinacms-context/#manually-toggling-edit-mode`);
|
|
1379
1101
|
return next();
|
|
1380
1102
|
}
|
|
1381
|
-
(0,
|
|
1103
|
+
(0, import_fs_extra.outputFileSync)(adminPath, adminPage);
|
|
1382
1104
|
next();
|
|
1383
1105
|
}
|
|
1384
1106
|
async function successMessage(ctx, next, options) {
|
|
1385
|
-
const usingSrc =
|
|
1107
|
+
const usingSrc = import_fs_extra.default.pathExistsSync(import_path2.default.join(baseDir, "src"));
|
|
1386
1108
|
logger.info(`Tina setup ${import_chalk5.default.underline.green("done")} \u2705
|
|
1387
1109
|
`);
|
|
1388
1110
|
logger.info("Next Steps: \n");
|
|
@@ -1431,7 +1153,7 @@ var chain = async (cmds, options) => {
|
|
|
1431
1153
|
var import_chalk7 = __toModule(require("chalk"));
|
|
1432
1154
|
|
|
1433
1155
|
// src/cmds/start-server/errors/index.ts
|
|
1434
|
-
var
|
|
1156
|
+
var import_graphql3 = __toModule(require("@tinacms/graphql"));
|
|
1435
1157
|
var BuildSchemaError = class extends Error {
|
|
1436
1158
|
constructor(message) {
|
|
1437
1159
|
super(message);
|
|
@@ -1457,8 +1179,8 @@ var handleServerErrors = (e) => {
|
|
|
1457
1179
|
logger.error(`${dangerText("ERROR: your schema was not successfully validated: see https://tina.io/docs/schema/ for instructions on how to setup a schema")}
|
|
1458
1180
|
Error Message Below
|
|
1459
1181
|
${e}`);
|
|
1460
|
-
} else if (e instanceof
|
|
1461
|
-
(0,
|
|
1182
|
+
} else if (e instanceof import_graphql3.TinaFetchError) {
|
|
1183
|
+
(0, import_graphql3.handleFetchErrorError)(e, true);
|
|
1462
1184
|
} else {
|
|
1463
1185
|
logger.info(dangerText("Compilation failed with errors. Server has not been restarted.") + ` see error below
|
|
1464
1186
|
${e.message}`);
|
|
@@ -1466,72 +1188,78 @@ var handleServerErrors = (e) => {
|
|
|
1466
1188
|
};
|
|
1467
1189
|
|
|
1468
1190
|
// src/cmds/compile/index.ts
|
|
1469
|
-
var
|
|
1470
|
-
var
|
|
1191
|
+
var import_fs_extra3 = __toModule(require("fs-extra"));
|
|
1192
|
+
var import_path4 = __toModule(require("path"));
|
|
1471
1193
|
var import_esbuild = __toModule(require("esbuild"));
|
|
1472
1194
|
|
|
1473
1195
|
// src/cmds/compile/defaultSchema.ts
|
|
1474
1196
|
var defaultSchema = `
|
|
1475
|
-
import { defineSchema, defineConfig } from
|
|
1197
|
+
import { defineSchema, defineConfig } from 'tinacms'
|
|
1198
|
+
import { client } from './__generated__/client'
|
|
1476
1199
|
|
|
1200
|
+
|
|
1201
|
+
const branch =
|
|
1202
|
+
process.env.NEXT_PUBLIC_TINA_BRANCH ||
|
|
1203
|
+
process.env.NEXT_PUBLIC_VERCEL_GIT_COMMIT_REF ||
|
|
1204
|
+
process.env.HEAD ||
|
|
1205
|
+
'main'
|
|
1477
1206
|
const schema = defineSchema({
|
|
1207
|
+
// See https://tina.io/docs/tina-cloud/connecting-site/ for more information about this config
|
|
1208
|
+
config: {
|
|
1209
|
+
token: '<Your Read Only Token>', // generated on app.tina.io,
|
|
1210
|
+
clientId: '<Your Client ID>', // generated on app.tina.io
|
|
1211
|
+
branch,
|
|
1212
|
+
},
|
|
1478
1213
|
collections: [
|
|
1479
1214
|
{
|
|
1480
|
-
label:
|
|
1481
|
-
name:
|
|
1482
|
-
path:
|
|
1215
|
+
label: 'Blog Posts',
|
|
1216
|
+
name: 'post',
|
|
1217
|
+
path: 'content/posts',
|
|
1218
|
+
format: 'mdx',
|
|
1483
1219
|
fields: [
|
|
1484
1220
|
{
|
|
1485
|
-
type:
|
|
1486
|
-
label:
|
|
1487
|
-
name:
|
|
1221
|
+
type: 'string',
|
|
1222
|
+
label: 'Title',
|
|
1223
|
+
name: 'title',
|
|
1488
1224
|
},
|
|
1489
1225
|
{
|
|
1490
|
-
type:
|
|
1491
|
-
label:
|
|
1492
|
-
name:
|
|
1226
|
+
type: 'rich-text',
|
|
1227
|
+
label: 'Blog Post Body',
|
|
1228
|
+
name: 'body',
|
|
1493
1229
|
isBody: true,
|
|
1494
1230
|
templates: [
|
|
1495
1231
|
{
|
|
1496
|
-
name:
|
|
1497
|
-
label:
|
|
1232
|
+
name: 'PageSection',
|
|
1233
|
+
label: 'Page Section',
|
|
1498
1234
|
fields: [
|
|
1499
1235
|
{
|
|
1500
|
-
type:
|
|
1501
|
-
name:
|
|
1502
|
-
label:
|
|
1236
|
+
type: 'string',
|
|
1237
|
+
name: 'heading',
|
|
1238
|
+
label: 'Heading',
|
|
1503
1239
|
},
|
|
1504
1240
|
{
|
|
1505
|
-
type:
|
|
1506
|
-
name:
|
|
1507
|
-
label:
|
|
1241
|
+
type: 'string',
|
|
1242
|
+
name: 'content',
|
|
1243
|
+
label: 'Content',
|
|
1508
1244
|
ui: {
|
|
1509
|
-
component:
|
|
1510
|
-
}
|
|
1511
|
-
}
|
|
1245
|
+
component: 'textarea',
|
|
1246
|
+
},
|
|
1247
|
+
},
|
|
1512
1248
|
],
|
|
1513
1249
|
},
|
|
1514
|
-
]
|
|
1250
|
+
],
|
|
1515
1251
|
},
|
|
1516
1252
|
],
|
|
1517
1253
|
},
|
|
1518
1254
|
],
|
|
1519
|
-
})
|
|
1255
|
+
})
|
|
1520
1256
|
|
|
1521
1257
|
export default schema
|
|
1522
1258
|
|
|
1523
1259
|
// Your tina config
|
|
1524
|
-
// ==============
|
|
1525
|
-
const branch = 'main'
|
|
1526
|
-
// When working locally, hit our local filesystem.
|
|
1527
|
-
// On a Vercel deployment, hit the Tina Cloud API
|
|
1528
|
-
const apiURL =
|
|
1529
|
-
process.env.NODE_ENV == 'development'
|
|
1530
|
-
? 'http://localhost:4001/graphql'
|
|
1531
|
-
: \`https://content.tinajs.io/content/\${process.env.NEXT_PUBLIC_TINA_CLIENT_ID}/github/\${branch}\`
|
|
1532
1260
|
|
|
1533
1261
|
export const tinaConfig = defineConfig({
|
|
1534
|
-
|
|
1262
|
+
client,
|
|
1535
1263
|
schema,
|
|
1536
1264
|
cmsCallback: (cms) => {
|
|
1537
1265
|
// add your CMS callback code here (if you want)
|
|
@@ -1540,41 +1268,42 @@ export const tinaConfig = defineConfig({
|
|
|
1540
1268
|
/**
|
|
1541
1269
|
* 1. Import \`tinacms\` and \`RouteMappingPlugin\`
|
|
1542
1270
|
**/
|
|
1543
|
-
import(
|
|
1271
|
+
import('tinacms').then(({ RouteMappingPlugin }) => {
|
|
1544
1272
|
/**
|
|
1545
1273
|
* 2. Define the \`RouteMappingPlugin\` see https://tina.io/docs/tinacms-context/#the-routemappingplugin for more details
|
|
1546
1274
|
**/
|
|
1547
1275
|
const RouteMapping = new RouteMappingPlugin((collection, document) => {
|
|
1548
|
-
return undefined
|
|
1549
|
-
})
|
|
1276
|
+
return undefined
|
|
1277
|
+
})
|
|
1550
1278
|
/**
|
|
1551
1279
|
* 3. Add the \`RouteMappingPlugin\` to the \`cms\`.
|
|
1552
1280
|
**/
|
|
1553
|
-
cms.plugins.add(RouteMapping)
|
|
1554
|
-
})
|
|
1281
|
+
cms.plugins.add(RouteMapping)
|
|
1282
|
+
})
|
|
1555
1283
|
|
|
1556
|
-
return cms
|
|
1284
|
+
return cms
|
|
1557
1285
|
},
|
|
1558
|
-
})
|
|
1286
|
+
})
|
|
1287
|
+
|
|
1559
1288
|
`;
|
|
1560
1289
|
|
|
1561
1290
|
// src/lib/getPath.ts
|
|
1562
|
-
var
|
|
1563
|
-
var
|
|
1291
|
+
var import_path3 = __toModule(require("path"));
|
|
1292
|
+
var import_fs_extra2 = __toModule(require("fs-extra"));
|
|
1564
1293
|
var getPath = ({
|
|
1565
1294
|
projectDir,
|
|
1566
1295
|
filename,
|
|
1567
1296
|
allowedTypes,
|
|
1568
1297
|
errorMessage
|
|
1569
1298
|
}) => {
|
|
1570
|
-
if (!
|
|
1299
|
+
if (!import_fs_extra2.default.existsSync(projectDir)) {
|
|
1571
1300
|
throw new Error(errorMessage);
|
|
1572
1301
|
}
|
|
1573
|
-
const filePaths = allowedTypes.map((ext) =>
|
|
1302
|
+
const filePaths = allowedTypes.map((ext) => import_path3.default.join(projectDir, `${filename}.${ext}`));
|
|
1574
1303
|
let inputFile = void 0;
|
|
1575
|
-
filePaths.every((
|
|
1576
|
-
if (
|
|
1577
|
-
inputFile =
|
|
1304
|
+
filePaths.every((path7) => {
|
|
1305
|
+
if (import_fs_extra2.default.existsSync(path7)) {
|
|
1306
|
+
inputFile = path7;
|
|
1578
1307
|
return false;
|
|
1579
1308
|
}
|
|
1580
1309
|
return true;
|
|
@@ -1598,29 +1327,48 @@ var getClientPath = ({ projectDir }) => {
|
|
|
1598
1327
|
};
|
|
1599
1328
|
|
|
1600
1329
|
// src/cmds/compile/index.ts
|
|
1601
|
-
var
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
var resetGeneratedFolder = async () => {
|
|
1330
|
+
var resetGeneratedFolder = async ({
|
|
1331
|
+
tinaGeneratedPath,
|
|
1332
|
+
usingTs
|
|
1333
|
+
}) => {
|
|
1606
1334
|
try {
|
|
1607
|
-
await
|
|
1335
|
+
await import_fs_extra3.default.rm(tinaGeneratedPath, {
|
|
1608
1336
|
recursive: true
|
|
1609
1337
|
});
|
|
1610
1338
|
} catch (e) {
|
|
1611
1339
|
console.log(e);
|
|
1612
1340
|
}
|
|
1613
|
-
await
|
|
1614
|
-
|
|
1341
|
+
await import_fs_extra3.default.mkdir(tinaGeneratedPath);
|
|
1342
|
+
const ext = usingTs ? "ts" : "js";
|
|
1343
|
+
await import_fs_extra3.default.writeFile(import_path4.default.join(tinaGeneratedPath, `types.${ext}`), `
|
|
1615
1344
|
export const queries = (client)=>({})
|
|
1616
1345
|
`);
|
|
1617
|
-
await
|
|
1346
|
+
await import_fs_extra3.default.writeFile(import_path4.default.join(tinaGeneratedPath, `client.${ext}`), `
|
|
1347
|
+
export const client = {}
|
|
1348
|
+
`);
|
|
1349
|
+
await import_fs_extra3.default.outputFile(import_path4.default.join(tinaGeneratedPath, ".gitignore"), `db
|
|
1350
|
+
client.ts
|
|
1351
|
+
client.js
|
|
1352
|
+
types.ts
|
|
1353
|
+
types.js
|
|
1354
|
+
types.d.ts
|
|
1355
|
+
frags.gql
|
|
1356
|
+
queries.gql
|
|
1357
|
+
schema.gql
|
|
1358
|
+
`);
|
|
1618
1359
|
};
|
|
1619
1360
|
var cleanup = async ({ tinaTempPath }) => {
|
|
1620
|
-
await
|
|
1361
|
+
await import_fs_extra3.default.remove(tinaTempPath);
|
|
1621
1362
|
};
|
|
1622
1363
|
var compileClient = async (ctx, next, options) => {
|
|
1623
|
-
const
|
|
1364
|
+
const root2 = ctx.rootPath;
|
|
1365
|
+
if (!root2) {
|
|
1366
|
+
throw new Error("ctx.rootPath has not been attached");
|
|
1367
|
+
}
|
|
1368
|
+
const tinaPath = import_path4.default.join(root2, ".tina");
|
|
1369
|
+
const tinaGeneratedPath = import_path4.default.join(tinaPath, "__generated__");
|
|
1370
|
+
const packageJSONFilePath = import_path4.default.join(root2, "package.json");
|
|
1371
|
+
const tinaTempPath = import_path4.default.join(tinaGeneratedPath, "temp_client");
|
|
1624
1372
|
if (!options.clientFileType)
|
|
1625
1373
|
options = __spreadProps(__spreadValues({}, options), { clientFileType: "ts" });
|
|
1626
1374
|
if (options.verbose) {
|
|
@@ -1635,8 +1383,9 @@ var compileClient = async (ctx, next, options) => {
|
|
|
1635
1383
|
ctx.clientFileType = requestedClientFileType;
|
|
1636
1384
|
}
|
|
1637
1385
|
let clientExists = true;
|
|
1386
|
+
const projectDir = import_path4.default.join(tinaPath, "__generated__");
|
|
1638
1387
|
try {
|
|
1639
|
-
getClientPath({ projectDir
|
|
1388
|
+
getClientPath({ projectDir });
|
|
1640
1389
|
} catch {
|
|
1641
1390
|
clientExists = false;
|
|
1642
1391
|
}
|
|
@@ -1651,8 +1400,10 @@ var compileClient = async (ctx, next, options) => {
|
|
|
1651
1400
|
if (!process.env.NODE_ENV) {
|
|
1652
1401
|
define["process.env.NODE_ENV"] = options.dev ? '"development"' : '"production"';
|
|
1653
1402
|
}
|
|
1654
|
-
const inputFile = getClientPath({
|
|
1655
|
-
|
|
1403
|
+
const inputFile = getClientPath({
|
|
1404
|
+
projectDir
|
|
1405
|
+
});
|
|
1406
|
+
await transpile(inputFile, "client.js", tinaTempPath, options.verbose, define, packageJSONFilePath);
|
|
1656
1407
|
} catch (e) {
|
|
1657
1408
|
await cleanup({ tinaTempPath });
|
|
1658
1409
|
throw new BuildSchemaError(e);
|
|
@@ -1663,7 +1414,7 @@ var compileClient = async (ctx, next, options) => {
|
|
|
1663
1414
|
}
|
|
1664
1415
|
});
|
|
1665
1416
|
try {
|
|
1666
|
-
const clientFunc = require(
|
|
1417
|
+
const clientFunc = require(import_path4.default.join(tinaTempPath, "client.js"));
|
|
1667
1418
|
const client = clientFunc.default;
|
|
1668
1419
|
ctx.client = client;
|
|
1669
1420
|
await cleanup({ tinaTempPath });
|
|
@@ -1678,10 +1429,21 @@ var compileClient = async (ctx, next, options) => {
|
|
|
1678
1429
|
}
|
|
1679
1430
|
return next();
|
|
1680
1431
|
};
|
|
1681
|
-
var compileSchema = async (
|
|
1682
|
-
const
|
|
1683
|
-
if (!
|
|
1684
|
-
|
|
1432
|
+
var compileSchema = async (ctx, _next, options) => {
|
|
1433
|
+
const root2 = ctx.rootPath;
|
|
1434
|
+
if (!root2) {
|
|
1435
|
+
throw new Error("ctx.rootPath has not been attached");
|
|
1436
|
+
}
|
|
1437
|
+
const tinaPath = import_path4.default.join(root2, ".tina");
|
|
1438
|
+
const tsConfigPath = import_path4.default.join(root2, "tsconfig.json");
|
|
1439
|
+
const tinaGeneratedPath = import_path4.default.join(tinaPath, "__generated__");
|
|
1440
|
+
const tinaTempPath = import_path4.default.join(tinaGeneratedPath, "temp_schema");
|
|
1441
|
+
const tinaConfigPath = import_path4.default.join(tinaGeneratedPath, "config");
|
|
1442
|
+
const packageJSONFilePath = import_path4.default.join(root2, "package.json");
|
|
1443
|
+
if (!options.schemaFileType) {
|
|
1444
|
+
const usingTs = await import_fs_extra3.default.pathExists(tsConfigPath);
|
|
1445
|
+
options = __spreadProps(__spreadValues({}, options), { schemaFileType: usingTs ? "ts" : "js" });
|
|
1446
|
+
}
|
|
1685
1447
|
if (options.verbose) {
|
|
1686
1448
|
logger.info(logText("Compiling Schema..."));
|
|
1687
1449
|
}
|
|
@@ -1690,8 +1452,8 @@ var compileSchema = async (_ctx, _next, options) => {
|
|
|
1690
1452
|
if (!schemaFileType2) {
|
|
1691
1453
|
throw new Error(`Requested schema file type '${requestedSchemaFileType}' is not valid. Supported schema file types: 'ts, js, tsx, jsx'`);
|
|
1692
1454
|
}
|
|
1693
|
-
if (
|
|
1694
|
-
|
|
1455
|
+
if (ctx) {
|
|
1456
|
+
ctx.schemaFileType = schemaFileType2;
|
|
1695
1457
|
}
|
|
1696
1458
|
let schemaExists = true;
|
|
1697
1459
|
try {
|
|
@@ -1704,9 +1466,9 @@ var compileSchema = async (_ctx, _next, options) => {
|
|
|
1704
1466
|
.tina/schema.${schemaFileType2} not found, Creating one for you...
|
|
1705
1467
|
See Documentation: https://tina.io/docs/tina-cloud/cli/#getting-started"
|
|
1706
1468
|
`));
|
|
1707
|
-
const file =
|
|
1708
|
-
await
|
|
1709
|
-
await
|
|
1469
|
+
const file = import_path4.default.join(tinaPath, `schema.${schemaFileType2}`);
|
|
1470
|
+
await import_fs_extra3.default.ensureFile(file);
|
|
1471
|
+
await import_fs_extra3.default.writeFile(file, defaultSchema);
|
|
1710
1472
|
}
|
|
1711
1473
|
try {
|
|
1712
1474
|
const define = {};
|
|
@@ -1714,7 +1476,7 @@ var compileSchema = async (_ctx, _next, options) => {
|
|
|
1714
1476
|
define["process.env.NODE_ENV"] = options.dev ? '"development"' : '"production"';
|
|
1715
1477
|
}
|
|
1716
1478
|
const inputFile = getSchemaPath({ projectDir: tinaPath });
|
|
1717
|
-
await transpile(inputFile, "schema.js", tinaTempPath, options.verbose, define);
|
|
1479
|
+
await transpile(inputFile, "schema.js", tinaTempPath, options.verbose, define, packageJSONFilePath);
|
|
1718
1480
|
} catch (e) {
|
|
1719
1481
|
await cleanup({ tinaTempPath });
|
|
1720
1482
|
throw new BuildSchemaError(e);
|
|
@@ -1725,104 +1487,376 @@ var compileSchema = async (_ctx, _next, options) => {
|
|
|
1725
1487
|
}
|
|
1726
1488
|
});
|
|
1727
1489
|
try {
|
|
1728
|
-
const schemaFunc = require(
|
|
1729
|
-
const schemaObject = schemaFunc.default;
|
|
1730
|
-
|
|
1731
|
-
await
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1490
|
+
const schemaFunc = require(import_path4.default.join(tinaTempPath, "schema.js"));
|
|
1491
|
+
const schemaObject = schemaFunc.default;
|
|
1492
|
+
ctx.schema = schemaObject;
|
|
1493
|
+
await import_fs_extra3.default.outputFile(import_path4.default.join(tinaConfigPath, "schema.json"), JSON.stringify(schemaObject, null, 2));
|
|
1494
|
+
await cleanup({ tinaTempPath });
|
|
1495
|
+
} catch (e) {
|
|
1496
|
+
await cleanup({ tinaTempPath });
|
|
1497
|
+
if (e instanceof Error) {
|
|
1498
|
+
if (e.name === "TinaSchemaValidationError") {
|
|
1499
|
+
throw e;
|
|
1500
|
+
}
|
|
1501
|
+
}
|
|
1502
|
+
throw new ExecuteSchemaError(e);
|
|
1503
|
+
}
|
|
1504
|
+
};
|
|
1505
|
+
var transpile = async (inputFile, outputFile, tempDir, verbose, define, packageJSONFilePath) => {
|
|
1506
|
+
if (verbose)
|
|
1507
|
+
logger.info(logText("Building javascript..."));
|
|
1508
|
+
const packageJSON = JSON.parse(import_fs_extra3.default.readFileSync(packageJSONFilePath).toString() || "{}");
|
|
1509
|
+
const deps = (packageJSON == null ? void 0 : packageJSON.dependencies) || [];
|
|
1510
|
+
const peerDeps = (packageJSON == null ? void 0 : packageJSON.peerDependencies) || [];
|
|
1511
|
+
const devDeps = (packageJSON == null ? void 0 : packageJSON.devDependencies) || [];
|
|
1512
|
+
const external = Object.keys(__spreadValues(__spreadValues(__spreadValues({}, deps), peerDeps), devDeps));
|
|
1513
|
+
const outputPath = import_path4.default.join(tempDir, outputFile);
|
|
1514
|
+
await (0, import_esbuild.build)({
|
|
1515
|
+
bundle: true,
|
|
1516
|
+
platform: "neutral",
|
|
1517
|
+
target: ["node10.4"],
|
|
1518
|
+
entryPoints: [inputFile],
|
|
1519
|
+
treeShaking: true,
|
|
1520
|
+
external: [...external, "./node_modules/*"],
|
|
1521
|
+
loader: loaders,
|
|
1522
|
+
outfile: outputPath,
|
|
1523
|
+
define
|
|
1524
|
+
});
|
|
1525
|
+
if (verbose)
|
|
1526
|
+
logger.info(logText(`Javascript built`));
|
|
1527
|
+
};
|
|
1528
|
+
var defineSchema = (config) => {
|
|
1529
|
+
return config;
|
|
1530
|
+
};
|
|
1531
|
+
var loaders = {
|
|
1532
|
+
".aac": "file",
|
|
1533
|
+
".css": "file",
|
|
1534
|
+
".eot": "file",
|
|
1535
|
+
".flac": "file",
|
|
1536
|
+
".gif": "file",
|
|
1537
|
+
".jpeg": "file",
|
|
1538
|
+
".jpg": "file",
|
|
1539
|
+
".json": "json",
|
|
1540
|
+
".mp3": "file",
|
|
1541
|
+
".mp4": "file",
|
|
1542
|
+
".ogg": "file",
|
|
1543
|
+
".otf": "file",
|
|
1544
|
+
".png": "file",
|
|
1545
|
+
".svg": "file",
|
|
1546
|
+
".ttf": "file",
|
|
1547
|
+
".wav": "file",
|
|
1548
|
+
".webm": "file",
|
|
1549
|
+
".webp": "file",
|
|
1550
|
+
".woff": "file",
|
|
1551
|
+
".woff2": "file",
|
|
1552
|
+
".js": "jsx",
|
|
1553
|
+
".jsx": "jsx",
|
|
1554
|
+
".tsx": "tsx"
|
|
1555
|
+
};
|
|
1556
|
+
|
|
1557
|
+
// src/cmds/start-server/index.ts
|
|
1558
|
+
var import_path11 = __toModule(require("path"));
|
|
1559
|
+
var import_chalk6 = __toModule(require("chalk"));
|
|
1560
|
+
var import_chokidar = __toModule(require("chokidar"));
|
|
1561
|
+
var import_metrics3 = __toModule(require("@tinacms/metrics"));
|
|
1562
|
+
|
|
1563
|
+
// src/buildTina/index.ts
|
|
1564
|
+
var import_async_retry = __toModule(require("async-retry"));
|
|
1565
|
+
var import_fs_extra6 = __toModule(require("fs-extra"));
|
|
1566
|
+
var import_graphql10 = __toModule(require("@tinacms/graphql"));
|
|
1567
|
+
var import_datalayer2 = __toModule(require("@tinacms/datalayer"));
|
|
1568
|
+
var import_path8 = __toModule(require("path"));
|
|
1569
|
+
|
|
1570
|
+
// src/cmds/query-gen/attachSchema.ts
|
|
1571
|
+
var import_graphql4 = __toModule(require("@tinacms/graphql"));
|
|
1572
|
+
var import_datalayer = __toModule(require("@tinacms/datalayer"));
|
|
1573
|
+
|
|
1574
|
+
// src/cmds/query-gen/genTypes.ts
|
|
1575
|
+
var import_graphql9 = __toModule(require("graphql"));
|
|
1576
|
+
var import_fs_extra4 = __toModule(require("fs-extra"));
|
|
1577
|
+
var import_path6 = __toModule(require("path"));
|
|
1578
|
+
|
|
1579
|
+
// src/codegen/index.ts
|
|
1580
|
+
var import_graphql8 = __toModule(require("graphql"));
|
|
1581
|
+
|
|
1582
|
+
// src/codegen/plugin.ts
|
|
1583
|
+
var AddGeneratedClientFunc = (_schema, _documents, _config, _info) => {
|
|
1584
|
+
return `
|
|
1585
|
+
// TinaSDK generated code
|
|
1586
|
+
import { createClient, TinaClient } from "tinacms/dist/client";
|
|
1587
|
+
|
|
1588
|
+
const generateRequester = (client: TinaClient) => {
|
|
1589
|
+
const requester: (
|
|
1590
|
+
doc: any,
|
|
1591
|
+
vars?: any,
|
|
1592
|
+
options?: any,
|
|
1593
|
+
client
|
|
1594
|
+
) => Promise<any> = async (doc, vars, _options) => {
|
|
1595
|
+
const data = await client.request({
|
|
1596
|
+
query: doc,
|
|
1597
|
+
variables: vars,
|
|
1598
|
+
});
|
|
1599
|
+
|
|
1600
|
+
return { data: data?.data, query: doc, variables: vars || {} };
|
|
1601
|
+
};
|
|
1602
|
+
|
|
1603
|
+
return requester;
|
|
1604
|
+
};
|
|
1605
|
+
|
|
1606
|
+
/**
|
|
1607
|
+
* @experimental this class can be used but may change in the future
|
|
1608
|
+
**/
|
|
1609
|
+
export const ExperimentalGetTinaClient = () =>
|
|
1610
|
+
getSdk(
|
|
1611
|
+
generateRequester(createClient({ url: "http://localhost:4001/graphql", queries }))
|
|
1612
|
+
);
|
|
1613
|
+
|
|
1614
|
+
export const queries = (client: TinaClient) => {
|
|
1615
|
+
const requester = generateRequester(client);
|
|
1616
|
+
return getSdk(requester);
|
|
1617
|
+
};
|
|
1618
|
+
`;
|
|
1619
|
+
};
|
|
1620
|
+
var AddGeneratedClient = {
|
|
1621
|
+
plugin: AddGeneratedClientFunc
|
|
1622
|
+
};
|
|
1623
|
+
|
|
1624
|
+
// src/codegen/index.ts
|
|
1625
|
+
var import_graphql_file_loader = __toModule(require("@graphql-tools/graphql-file-loader"));
|
|
1626
|
+
var import_core = __toModule(require("@graphql-codegen/core"));
|
|
1627
|
+
var import_load = __toModule(require("@graphql-tools/load"));
|
|
1628
|
+
var import_typescript_operations = __toModule(require("@graphql-codegen/typescript-operations"));
|
|
1629
|
+
var import_typescript = __toModule(require("@graphql-codegen/typescript"));
|
|
1630
|
+
|
|
1631
|
+
// src/codegen/sdkPlugin/index.ts
|
|
1632
|
+
var import_graphql6 = __toModule(require("graphql"));
|
|
1633
|
+
var import_graphql7 = __toModule(require("graphql"));
|
|
1634
|
+
var import_path5 = __toModule(require("path"));
|
|
1635
|
+
|
|
1636
|
+
// src/codegen/sdkPlugin/visitor.ts
|
|
1637
|
+
var import_visitor_plugin_common = __toModule(require("@graphql-codegen/visitor-plugin-common"));
|
|
1638
|
+
var import_auto_bind = __toModule(require("auto-bind"));
|
|
1639
|
+
var import_graphql5 = __toModule(require("graphql"));
|
|
1640
|
+
var GenericSdkVisitor = class extends import_visitor_plugin_common.ClientSideBaseVisitor {
|
|
1641
|
+
constructor(schema, fragments, rawConfig) {
|
|
1642
|
+
super(schema, fragments, rawConfig, {
|
|
1643
|
+
usingObservableFrom: rawConfig.usingObservableFrom
|
|
1644
|
+
});
|
|
1645
|
+
this._operationsToInclude = [];
|
|
1646
|
+
(0, import_auto_bind.default)(this);
|
|
1647
|
+
if (this.config.usingObservableFrom) {
|
|
1648
|
+
this._additionalImports.push(this.config.usingObservableFrom);
|
|
1649
|
+
}
|
|
1650
|
+
if (this.config.documentMode !== import_visitor_plugin_common.DocumentMode.string) {
|
|
1651
|
+
}
|
|
1652
|
+
}
|
|
1653
|
+
buildOperation(node, documentVariableName, operationType, operationResultType, operationVariablesTypes) {
|
|
1654
|
+
if (node.name == null) {
|
|
1655
|
+
throw new Error("Plugin 'generic-sdk' cannot generate SDK for unnamed operation.\n\n" + (0, import_graphql5.print)(node));
|
|
1656
|
+
} else {
|
|
1657
|
+
this._operationsToInclude.push({
|
|
1658
|
+
node,
|
|
1659
|
+
documentVariableName,
|
|
1660
|
+
operationType,
|
|
1661
|
+
operationResultType: `{data: ${operationResultType}, variables: ${operationVariablesTypes}, query: string}`,
|
|
1662
|
+
operationVariablesTypes
|
|
1663
|
+
});
|
|
1664
|
+
}
|
|
1665
|
+
return null;
|
|
1666
|
+
}
|
|
1667
|
+
get sdkContent() {
|
|
1668
|
+
const usingObservable = !!this.config.usingObservableFrom;
|
|
1669
|
+
const allPossibleActions = this._operationsToInclude.map((o) => {
|
|
1670
|
+
const optionalVariables = !o.node.variableDefinitions || o.node.variableDefinitions.length === 0 || o.node.variableDefinitions.every((v) => v.type.kind !== import_graphql5.Kind.NON_NULL_TYPE || v.defaultValue);
|
|
1671
|
+
const returnType = usingObservable && o.operationType === "Subscription" ? "Observable" : "Promise";
|
|
1672
|
+
return `${o.node.name.value}(variables${optionalVariables ? "?" : ""}: ${o.operationVariablesTypes}, options?: C): ${returnType}<${o.operationResultType}> {
|
|
1673
|
+
return requester<${o.operationResultType}, ${o.operationVariablesTypes}>(${o.documentVariableName}, variables, options);
|
|
1674
|
+
}`;
|
|
1675
|
+
}).map((s) => (0, import_visitor_plugin_common.indentMultiline)(s, 2));
|
|
1676
|
+
return `export type Requester<C= {}> = <R, V>(doc: ${this.config.documentMode === import_visitor_plugin_common.DocumentMode.string ? "string" : "DocumentNode"}, vars?: V, options?: C) => ${usingObservable ? "Promise<R> & Observable<R>" : "Promise<R>"}
|
|
1677
|
+
export function getSdk<C>(requester: Requester<C>) {
|
|
1678
|
+
return {
|
|
1679
|
+
${allPossibleActions.join(",\n")}
|
|
1680
|
+
};
|
|
1681
|
+
}
|
|
1682
|
+
export type Sdk = ReturnType<typeof getSdk>;`;
|
|
1683
|
+
}
|
|
1684
|
+
};
|
|
1685
|
+
|
|
1686
|
+
// src/codegen/sdkPlugin/index.ts
|
|
1687
|
+
var plugin = (schema, documents, config) => {
|
|
1688
|
+
const allAst = (0, import_graphql7.concatAST)(documents.reduce((prev, v) => {
|
|
1689
|
+
return [...prev, v.document];
|
|
1690
|
+
}, []));
|
|
1691
|
+
const allFragments = [
|
|
1692
|
+
...allAst.definitions.filter((d) => d.kind === import_graphql7.Kind.FRAGMENT_DEFINITION).map((fragmentDef) => ({
|
|
1693
|
+
node: fragmentDef,
|
|
1694
|
+
name: fragmentDef.name.value,
|
|
1695
|
+
onType: fragmentDef.typeCondition.name.value,
|
|
1696
|
+
isExternal: false
|
|
1697
|
+
})),
|
|
1698
|
+
...config.externalFragments || []
|
|
1699
|
+
];
|
|
1700
|
+
const visitor = new GenericSdkVisitor(schema, allFragments, config);
|
|
1701
|
+
const visitorResult = (0, import_graphql6.visit)(allAst, { leave: visitor });
|
|
1702
|
+
return {
|
|
1703
|
+
content: [
|
|
1704
|
+
visitor.fragments,
|
|
1705
|
+
...visitorResult.definitions.filter((t) => typeof t === "string"),
|
|
1706
|
+
visitor.sdkContent
|
|
1707
|
+
].join("\n")
|
|
1708
|
+
};
|
|
1709
|
+
};
|
|
1710
|
+
|
|
1711
|
+
// src/codegen/index.ts
|
|
1712
|
+
var generateTypes = async (schema, queryPathGlob = process.cwd(), fragDocPath = process.cwd(), options = {
|
|
1713
|
+
noSDK: false,
|
|
1714
|
+
verbose: false
|
|
1715
|
+
}) => {
|
|
1716
|
+
if (options.verbose)
|
|
1717
|
+
logger.info("Generating types...");
|
|
1718
|
+
try {
|
|
1719
|
+
let docs = [];
|
|
1720
|
+
let fragDocs = [];
|
|
1721
|
+
try {
|
|
1722
|
+
if (!options.noSDK) {
|
|
1723
|
+
docs = await (0, import_load.loadDocuments)(queryPathGlob, {
|
|
1724
|
+
loaders: [new import_graphql_file_loader.GraphQLFileLoader()]
|
|
1725
|
+
});
|
|
1726
|
+
}
|
|
1727
|
+
} catch (e) {
|
|
1728
|
+
let showErrorMessage = true;
|
|
1729
|
+
const message = e.message || "";
|
|
1730
|
+
if (message.includes("Unable to find any GraphQL type definitions for the following pointers:")) {
|
|
1731
|
+
showErrorMessage = false;
|
|
1732
|
+
}
|
|
1733
|
+
if (showErrorMessage) {
|
|
1734
|
+
console.error(e);
|
|
1737
1735
|
}
|
|
1738
1736
|
}
|
|
1739
|
-
|
|
1737
|
+
try {
|
|
1738
|
+
if (!options.noSDK) {
|
|
1739
|
+
fragDocs = await (0, import_load.loadDocuments)(fragDocPath, {
|
|
1740
|
+
loaders: [new import_graphql_file_loader.GraphQLFileLoader()]
|
|
1741
|
+
});
|
|
1742
|
+
}
|
|
1743
|
+
} catch (error) {
|
|
1744
|
+
console.error(error);
|
|
1745
|
+
}
|
|
1746
|
+
const res = await (0, import_core.codegen)({
|
|
1747
|
+
filename: process.cwd(),
|
|
1748
|
+
schema: (0, import_graphql8.parse)((0, import_graphql8.printSchema)(schema)),
|
|
1749
|
+
documents: [...docs, ...fragDocs],
|
|
1750
|
+
config: {},
|
|
1751
|
+
plugins: [
|
|
1752
|
+
{ typescript: {} },
|
|
1753
|
+
{ typescriptOperations: {} },
|
|
1754
|
+
{
|
|
1755
|
+
typescriptSdk: {}
|
|
1756
|
+
},
|
|
1757
|
+
{ AddGeneratedClient: {} }
|
|
1758
|
+
],
|
|
1759
|
+
pluginMap: {
|
|
1760
|
+
typescript: {
|
|
1761
|
+
plugin: import_typescript.plugin
|
|
1762
|
+
},
|
|
1763
|
+
typescriptOperations: {
|
|
1764
|
+
plugin: import_typescript_operations.plugin
|
|
1765
|
+
},
|
|
1766
|
+
typescriptSdk: {
|
|
1767
|
+
plugin
|
|
1768
|
+
},
|
|
1769
|
+
AddGeneratedClient
|
|
1770
|
+
}
|
|
1771
|
+
});
|
|
1772
|
+
return res;
|
|
1773
|
+
} catch (e) {
|
|
1774
|
+
console.error(e);
|
|
1740
1775
|
}
|
|
1741
1776
|
};
|
|
1742
|
-
var transpile = async (inputFile, outputFile, tempDir, verbose, define) => {
|
|
1743
|
-
if (verbose)
|
|
1744
|
-
logger.info(logText("Building javascript..."));
|
|
1745
|
-
const packageJSON = JSON.parse(import_fs_extra4.default.readFileSync(packageJSONFilePath).toString() || "{}");
|
|
1746
|
-
const deps = (packageJSON == null ? void 0 : packageJSON.dependencies) || [];
|
|
1747
|
-
const peerDeps = (packageJSON == null ? void 0 : packageJSON.peerDependencies) || [];
|
|
1748
|
-
const devDeps = (packageJSON == null ? void 0 : packageJSON.devDependencies) || [];
|
|
1749
|
-
const external = Object.keys(__spreadValues(__spreadValues(__spreadValues({}, deps), peerDeps), devDeps));
|
|
1750
|
-
const outputPath = import_path5.default.join(tempDir, outputFile);
|
|
1751
|
-
await (0, import_esbuild.build)({
|
|
1752
|
-
bundle: true,
|
|
1753
|
-
platform: "neutral",
|
|
1754
|
-
target: ["node10.4"],
|
|
1755
|
-
entryPoints: [inputFile],
|
|
1756
|
-
treeShaking: true,
|
|
1757
|
-
external: [...external, "./node_modules/*"],
|
|
1758
|
-
loader: loaders,
|
|
1759
|
-
outfile: outputPath,
|
|
1760
|
-
define
|
|
1761
|
-
});
|
|
1762
|
-
if (verbose)
|
|
1763
|
-
logger.info(logText(`Javascript built`));
|
|
1764
|
-
};
|
|
1765
|
-
var defineSchema = (config) => {
|
|
1766
|
-
return config;
|
|
1767
|
-
};
|
|
1768
|
-
var loaders = {
|
|
1769
|
-
".aac": "file",
|
|
1770
|
-
".css": "file",
|
|
1771
|
-
".eot": "file",
|
|
1772
|
-
".flac": "file",
|
|
1773
|
-
".gif": "file",
|
|
1774
|
-
".jpeg": "file",
|
|
1775
|
-
".jpg": "file",
|
|
1776
|
-
".json": "json",
|
|
1777
|
-
".mp3": "file",
|
|
1778
|
-
".mp4": "file",
|
|
1779
|
-
".ogg": "file",
|
|
1780
|
-
".otf": "file",
|
|
1781
|
-
".png": "file",
|
|
1782
|
-
".svg": "file",
|
|
1783
|
-
".ttf": "file",
|
|
1784
|
-
".wav": "file",
|
|
1785
|
-
".webm": "file",
|
|
1786
|
-
".webp": "file",
|
|
1787
|
-
".woff": "file",
|
|
1788
|
-
".woff2": "file",
|
|
1789
|
-
".js": "jsx",
|
|
1790
|
-
".jsx": "jsx",
|
|
1791
|
-
".tsx": "tsx"
|
|
1792
|
-
};
|
|
1793
|
-
|
|
1794
|
-
// src/cmds/start-server/index.ts
|
|
1795
|
-
var import_datalayer3 = __toModule(require("@tinacms/datalayer"));
|
|
1796
|
-
var import_graphql11 = __toModule(require("@tinacms/graphql"));
|
|
1797
1777
|
|
|
1798
|
-
// src/cmds/
|
|
1799
|
-
var
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1778
|
+
// src/cmds/query-gen/genTypes.ts
|
|
1779
|
+
var import_esbuild2 = __toModule(require("esbuild"));
|
|
1780
|
+
var TINA_HOST = "content.tinajs.io";
|
|
1781
|
+
var root = process.cwd();
|
|
1782
|
+
var generatedPath = import_path6.default.join(root, ".tina", "__generated__");
|
|
1783
|
+
async function genClient({
|
|
1784
|
+
tinaSchema,
|
|
1785
|
+
usingTs
|
|
1786
|
+
}, next, options) {
|
|
1787
|
+
var _a, _b, _c;
|
|
1788
|
+
const branch = (_a = tinaSchema == null ? void 0 : tinaSchema.config) == null ? void 0 : _a.branch;
|
|
1789
|
+
const clientId = (_b = tinaSchema == null ? void 0 : tinaSchema.config) == null ? void 0 : _b.clientId;
|
|
1790
|
+
const token = (_c = tinaSchema.config) == null ? void 0 : _c.token;
|
|
1791
|
+
if ((!branch || !clientId || !token) && !(options == null ? void 0 : options.local)) {
|
|
1792
|
+
const missing = [];
|
|
1793
|
+
if (!branch)
|
|
1794
|
+
missing.push("branch");
|
|
1795
|
+
if (!clientId)
|
|
1796
|
+
missing.push("clientId");
|
|
1797
|
+
if (!token)
|
|
1798
|
+
missing.push("token");
|
|
1799
|
+
throw new Error(`Client not configured properly. Missing ${missing.join(", ")}. Please visit https://tina.io/docs/tina-cloud/connecting-site/ for more information`);
|
|
1800
|
+
}
|
|
1801
|
+
const apiURL = options.local ? "http://localhost:4001/graphql" : `https://${TINA_HOST}/content/${clientId}/github/${branch}`;
|
|
1802
|
+
const clientPath = import_path6.default.join(generatedPath, `client.${usingTs ? "ts" : "js"}`);
|
|
1803
|
+
import_fs_extra4.default.writeFileSync(clientPath, `import { createClient } from "tinacms/dist/client";
|
|
1804
|
+
import { queries } from "./types";
|
|
1805
|
+
export const client = createClient({ url: '${apiURL}', token: '${token}', queries });
|
|
1806
|
+
export default client;
|
|
1807
|
+
`);
|
|
1808
|
+
return next();
|
|
1809
|
+
}
|
|
1810
|
+
async function genTypes({ schema, usingTs }, next, options) {
|
|
1811
|
+
const typesPath = process.cwd() + "/.tina/__generated__/types.ts";
|
|
1812
|
+
const typesJSPath = process.cwd() + "/.tina/__generated__/types.js";
|
|
1813
|
+
const typesDPath = process.cwd() + "/.tina/__generated__/types.d.ts";
|
|
1814
|
+
const fragPath = process.cwd() + "/.tina/__generated__/*.{graphql,gql}";
|
|
1815
|
+
const queryPathGlob = process.cwd() + "/.tina/queries/**/*.{graphql,gql}";
|
|
1816
|
+
const typescriptTypes = await generateTypes(schema, queryPathGlob, fragPath, options);
|
|
1817
|
+
const code = `//@ts-nocheck
|
|
1818
|
+
// DO NOT MODIFY THIS FILE. This file is automatically generated by Tina
|
|
1819
|
+
export function gql(strings: TemplateStringsArray, ...args: string[]): string {
|
|
1820
|
+
let str = ''
|
|
1821
|
+
strings.forEach((string, i) => {
|
|
1822
|
+
str += string + (args[i] || '')
|
|
1823
|
+
})
|
|
1824
|
+
return str
|
|
1825
|
+
}
|
|
1826
|
+
${typescriptTypes}
|
|
1827
|
+
`;
|
|
1828
|
+
if (usingTs) {
|
|
1829
|
+
await import_fs_extra4.default.outputFile(typesPath, code);
|
|
1830
|
+
logger.info(` Typescript types => ${logText(typesPath)}`);
|
|
1831
|
+
} else {
|
|
1832
|
+
await import_fs_extra4.default.outputFile(typesDPath, code);
|
|
1833
|
+
const jsCode = await (0, import_esbuild2.transform)(code, { loader: "ts" });
|
|
1834
|
+
await import_fs_extra4.default.outputFile(typesJSPath, jsCode.code);
|
|
1807
1835
|
}
|
|
1808
|
-
|
|
1836
|
+
const schemaString = await (0, import_graphql9.printSchema)(schema);
|
|
1837
|
+
const schemaPath = process.cwd() + "/.tina/__generated__/schema.gql";
|
|
1838
|
+
await import_fs_extra4.default.outputFile(schemaPath, `# DO NOT MODIFY THIS FILE. This file is automatically generated by Tina
|
|
1839
|
+
${schemaString}
|
|
1840
|
+
schema {
|
|
1841
|
+
query: Query
|
|
1842
|
+
mutation: Mutation
|
|
1843
|
+
}
|
|
1844
|
+
`);
|
|
1845
|
+
logger.info(` GraphQL types ====> ${logText(schemaPath)}
|
|
1846
|
+
`);
|
|
1847
|
+
next();
|
|
1848
|
+
}
|
|
1809
1849
|
|
|
1810
|
-
// src/
|
|
1811
|
-
var
|
|
1812
|
-
var import_chalk6 = __toModule(require("chalk"));
|
|
1813
|
-
var import_chokidar = __toModule(require("chokidar"));
|
|
1814
|
-
var import_fs_extra6 = __toModule(require("fs-extra"));
|
|
1850
|
+
// src/buildTina/git.ts
|
|
1851
|
+
var import_fs_extra5 = __toModule(require("fs-extra"));
|
|
1815
1852
|
var import_ini = __toModule(require("ini"));
|
|
1816
1853
|
var import_os = __toModule(require("os"));
|
|
1817
|
-
var
|
|
1818
|
-
var buildLock = new AsyncLock();
|
|
1819
|
-
var reBuildLock = new AsyncLock();
|
|
1820
|
-
var gqlPackageFile = require.resolve("@tinacms/graphql");
|
|
1854
|
+
var import_path7 = __toModule(require("path"));
|
|
1821
1855
|
var resolveGitRoot = async () => {
|
|
1822
|
-
const pathParts = process.cwd().split(
|
|
1856
|
+
const pathParts = process.cwd().split(import_path7.default.sep);
|
|
1823
1857
|
while (true) {
|
|
1824
|
-
const pathToGit = pathParts.join(
|
|
1825
|
-
if (await
|
|
1858
|
+
const pathToGit = pathParts.join(import_path7.default.sep);
|
|
1859
|
+
if (await import_fs_extra5.default.pathExists(import_path7.default.join(pathToGit, ".git"))) {
|
|
1826
1860
|
return pathToGit;
|
|
1827
1861
|
}
|
|
1828
1862
|
if (!pathParts.length) {
|
|
@@ -1847,9 +1881,9 @@ async function makeIsomorphicOptions(fsBridge) {
|
|
|
1847
1881
|
await fsBridge.delete(filepath);
|
|
1848
1882
|
}
|
|
1849
1883
|
};
|
|
1850
|
-
const userGitConfig = `${import_os.default.homedir()}${
|
|
1851
|
-
if (await
|
|
1852
|
-
const config = import_ini.default.parse(await
|
|
1884
|
+
const userGitConfig = `${import_os.default.homedir()}${import_path7.default.sep}.gitconfig`;
|
|
1885
|
+
if (await import_fs_extra5.default.pathExists(userGitConfig)) {
|
|
1886
|
+
const config = import_ini.default.parse(await import_fs_extra5.default.readFile(userGitConfig, "utf-8"));
|
|
1853
1887
|
if ((_a = config["user"]) == null ? void 0 : _a["name"]) {
|
|
1854
1888
|
options.author.name = config["user"]["name"];
|
|
1855
1889
|
}
|
|
@@ -1859,7 +1893,7 @@ async function makeIsomorphicOptions(fsBridge) {
|
|
|
1859
1893
|
}
|
|
1860
1894
|
let repoGitConfig = void 0;
|
|
1861
1895
|
if (!options.author.name) {
|
|
1862
|
-
repoGitConfig = import_ini.default.parse(await
|
|
1896
|
+
repoGitConfig = import_ini.default.parse(await import_fs_extra5.default.readFile(`${gitRoot}/.git/config`, "utf-8"));
|
|
1863
1897
|
if ((_c = repoGitConfig["user"]) == null ? void 0 : _c["name"]) {
|
|
1864
1898
|
options.author.name = repoGitConfig["user"]["name"];
|
|
1865
1899
|
}
|
|
@@ -1868,7 +1902,7 @@ async function makeIsomorphicOptions(fsBridge) {
|
|
|
1868
1902
|
}
|
|
1869
1903
|
}
|
|
1870
1904
|
if (!options.author.email) {
|
|
1871
|
-
repoGitConfig = repoGitConfig || import_ini.default.parse(await
|
|
1905
|
+
repoGitConfig = repoGitConfig || import_ini.default.parse(await import_fs_extra5.default.readFile(`${gitRoot}/.git/config`, "utf-8"));
|
|
1872
1906
|
if ((_d = repoGitConfig["user"]) == null ? void 0 : _d["email"]) {
|
|
1873
1907
|
options.author.email = repoGitConfig["user"]["email"];
|
|
1874
1908
|
}
|
|
@@ -1878,63 +1912,188 @@ async function makeIsomorphicOptions(fsBridge) {
|
|
|
1878
1912
|
}
|
|
1879
1913
|
return options;
|
|
1880
1914
|
}
|
|
1881
|
-
|
|
1915
|
+
|
|
1916
|
+
// src/buildTina/index.ts
|
|
1917
|
+
var buildSetupCmdBuild = async (ctx, next, opts) => {
|
|
1918
|
+
const rootPath2 = ctx.rootPath;
|
|
1919
|
+
const { bridge, database, store } = await buildSetup(__spreadProps(__spreadValues({}, opts), {
|
|
1920
|
+
rootPath: rootPath2,
|
|
1921
|
+
useMemoryStore: true
|
|
1922
|
+
}));
|
|
1923
|
+
ctx.bridge = bridge;
|
|
1924
|
+
ctx.database = database;
|
|
1925
|
+
ctx.store = store;
|
|
1926
|
+
next();
|
|
1927
|
+
};
|
|
1928
|
+
var buildSetupCmdServerStart = async (ctx, next, opts) => {
|
|
1929
|
+
const rootPath2 = ctx.rootPath;
|
|
1930
|
+
const { bridge, database, store } = await buildSetup(__spreadProps(__spreadValues({}, opts), {
|
|
1931
|
+
rootPath: rootPath2,
|
|
1932
|
+
useMemoryStore: false
|
|
1933
|
+
}));
|
|
1934
|
+
ctx.bridge = bridge;
|
|
1935
|
+
ctx.database = database;
|
|
1936
|
+
ctx.store = store;
|
|
1937
|
+
next();
|
|
1938
|
+
};
|
|
1939
|
+
var buildSetupCmdAudit = async (ctx, next, options) => {
|
|
1940
|
+
const rootPath2 = ctx.rootPath;
|
|
1941
|
+
const bridge = options.clean ? new import_datalayer2.FilesystemBridge(rootPath2) : new import_datalayer2.AuditFileSystemBridge(rootPath2);
|
|
1942
|
+
const store = new import_datalayer2.LevelStore(rootPath2, false);
|
|
1943
|
+
const database = await (0, import_graphql10.createDatabase)({ store, bridge });
|
|
1944
|
+
ctx.bridge = bridge;
|
|
1945
|
+
ctx.database = database;
|
|
1946
|
+
ctx.store = store;
|
|
1947
|
+
next();
|
|
1948
|
+
};
|
|
1949
|
+
var buildSetup = async ({
|
|
1950
|
+
isomorphicGitBridge: isomorphicGitBridge2,
|
|
1951
|
+
experimentalData,
|
|
1952
|
+
rootPath: rootPath2,
|
|
1953
|
+
useMemoryStore
|
|
1954
|
+
}) => {
|
|
1955
|
+
const fsBridge = new import_datalayer2.FilesystemBridge(rootPath2);
|
|
1956
|
+
const isomorphicOptions = isomorphicGitBridge2 && await makeIsomorphicOptions(fsBridge);
|
|
1957
|
+
const bridge = isomorphicGitBridge2 ? new import_datalayer2.IsomorphicBridge(rootPath2, isomorphicOptions) : fsBridge;
|
|
1958
|
+
const store = new import_datalayer2.LevelStore(rootPath2, useMemoryStore);
|
|
1959
|
+
const database = await (0, import_graphql10.createDatabase)({ store, bridge });
|
|
1960
|
+
return { database, bridge, store };
|
|
1961
|
+
};
|
|
1962
|
+
var buildCmdBuild = async (ctx, next, options) => {
|
|
1963
|
+
const bridge = ctx.bridge;
|
|
1964
|
+
const database = ctx.database;
|
|
1965
|
+
const store = ctx.store;
|
|
1966
|
+
await build2(__spreadProps(__spreadValues({}, options), {
|
|
1967
|
+
bridge,
|
|
1968
|
+
database,
|
|
1969
|
+
store,
|
|
1970
|
+
ctx,
|
|
1971
|
+
skipIndex: true
|
|
1972
|
+
}));
|
|
1973
|
+
next();
|
|
1974
|
+
};
|
|
1975
|
+
var auditCmdBuild = async (ctx, next, options) => {
|
|
1976
|
+
const bridge = ctx.bridge;
|
|
1977
|
+
const database = ctx.database;
|
|
1978
|
+
const store = ctx.store;
|
|
1979
|
+
await build2(__spreadProps(__spreadValues({}, options), {
|
|
1980
|
+
local: true,
|
|
1981
|
+
verbose: true,
|
|
1982
|
+
bridge,
|
|
1983
|
+
database,
|
|
1984
|
+
store,
|
|
1985
|
+
ctx
|
|
1986
|
+
}));
|
|
1987
|
+
next();
|
|
1988
|
+
};
|
|
1989
|
+
var build2 = async ({
|
|
1990
|
+
noWatch,
|
|
1991
|
+
ctx,
|
|
1992
|
+
bridge,
|
|
1993
|
+
database,
|
|
1994
|
+
store,
|
|
1995
|
+
beforeBuild,
|
|
1996
|
+
afterBuild,
|
|
1997
|
+
dev,
|
|
1998
|
+
local,
|
|
1999
|
+
verbose,
|
|
2000
|
+
noSDK,
|
|
2001
|
+
skipIndex
|
|
2002
|
+
}) => {
|
|
2003
|
+
const rootPath2 = ctx.rootPath;
|
|
2004
|
+
if (!rootPath2) {
|
|
2005
|
+
throw new Error("Root path has not been attached");
|
|
2006
|
+
}
|
|
2007
|
+
const tinaGeneratedPath = import_path8.default.join(rootPath2, ".tina", "__generated__");
|
|
2008
|
+
database.clearCache();
|
|
2009
|
+
if (beforeBuild) {
|
|
2010
|
+
await beforeBuild();
|
|
2011
|
+
}
|
|
2012
|
+
try {
|
|
2013
|
+
await import_fs_extra6.default.mkdirp(tinaGeneratedPath);
|
|
2014
|
+
await store.close();
|
|
2015
|
+
await resetGeneratedFolder({
|
|
2016
|
+
tinaGeneratedPath,
|
|
2017
|
+
usingTs: ctx.usingTs
|
|
2018
|
+
});
|
|
2019
|
+
await store.open();
|
|
2020
|
+
const cliFlags = [];
|
|
2021
|
+
cliFlags.push("experimentalData");
|
|
2022
|
+
cliFlags.push("isomorphicGitBridge");
|
|
2023
|
+
const database2 = await (0, import_graphql10.createDatabase)({ store, bridge });
|
|
2024
|
+
await compileSchema(ctx, null, { verbose, dev });
|
|
2025
|
+
const schema = await (0, import_async_retry.default)(async () => await (0, import_graphql10.buildSchema)(rootPath2, database2, cliFlags, skipIndex));
|
|
2026
|
+
await genTypes({ schema, usingTs: ctx.usingTs }, () => {
|
|
2027
|
+
}, {
|
|
2028
|
+
noSDK,
|
|
2029
|
+
verbose
|
|
2030
|
+
});
|
|
2031
|
+
await genClient({ tinaSchema: ctx.schema, usingTs: ctx.usingTs }, () => {
|
|
2032
|
+
}, {
|
|
2033
|
+
local
|
|
2034
|
+
});
|
|
2035
|
+
} catch (error) {
|
|
2036
|
+
throw error;
|
|
2037
|
+
} finally {
|
|
2038
|
+
if (afterBuild) {
|
|
2039
|
+
await afterBuild();
|
|
2040
|
+
}
|
|
2041
|
+
}
|
|
2042
|
+
};
|
|
2043
|
+
|
|
2044
|
+
// src/cmds/start-server/lock.ts
|
|
2045
|
+
var AsyncLock = class {
|
|
2046
|
+
constructor() {
|
|
2047
|
+
this.disable = () => {
|
|
2048
|
+
};
|
|
2049
|
+
this.promise = Promise.resolve();
|
|
2050
|
+
}
|
|
2051
|
+
enable() {
|
|
2052
|
+
this.promise = new Promise((resolve2) => this.disable = resolve2);
|
|
2053
|
+
}
|
|
2054
|
+
};
|
|
2055
|
+
|
|
2056
|
+
// src/cmds/start-server/index.ts
|
|
2057
|
+
var buildLock = new AsyncLock();
|
|
2058
|
+
var reBuildLock = new AsyncLock();
|
|
2059
|
+
var gqlPackageFile = require.resolve("@tinacms/graphql");
|
|
2060
|
+
async function startServer(ctx, next, {
|
|
1882
2061
|
port = 4001,
|
|
1883
2062
|
noWatch,
|
|
1884
|
-
experimentalData,
|
|
1885
2063
|
isomorphicGitBridge: isomorphicGitBridge2,
|
|
1886
2064
|
noSDK,
|
|
1887
2065
|
noTelemetry,
|
|
1888
2066
|
watchFolders,
|
|
1889
2067
|
verbose,
|
|
1890
|
-
dev
|
|
2068
|
+
dev,
|
|
2069
|
+
local
|
|
1891
2070
|
}) {
|
|
1892
2071
|
buildLock.disable();
|
|
1893
2072
|
reBuildLock.disable();
|
|
1894
|
-
const rootPath2 =
|
|
2073
|
+
const rootPath2 = ctx.rootPath;
|
|
1895
2074
|
const t = new import_metrics3.Telemetry({ disabled: Boolean(noTelemetry) });
|
|
1896
2075
|
t.submitRecord({
|
|
1897
2076
|
event: {
|
|
1898
2077
|
name: "tinacms:cli:server:start:invoke"
|
|
1899
2078
|
}
|
|
1900
2079
|
});
|
|
1901
|
-
const
|
|
1902
|
-
const
|
|
1903
|
-
const
|
|
1904
|
-
const store = experimentalData ? new import_datalayer3.LevelStore(rootPath2) : new import_datalayer3.FilesystemStore({ rootPath: rootPath2 });
|
|
2080
|
+
const bridge = ctx.bridge;
|
|
2081
|
+
const database = ctx.database;
|
|
2082
|
+
const store = ctx.store;
|
|
1905
2083
|
const shouldBuild = bridge.supportsBuilding();
|
|
1906
|
-
const database = await (0, import_graphql11.createDatabase)({ store, bridge });
|
|
1907
2084
|
let ready = false;
|
|
1908
|
-
const build2 = async (noSDK2) => {
|
|
1909
|
-
database.clearCache();
|
|
1910
|
-
await buildLock.promise;
|
|
1911
|
-
buildLock.enable();
|
|
1912
|
-
try {
|
|
1913
|
-
if (!process.env.CI && !noWatch) {
|
|
1914
|
-
await store.close();
|
|
1915
|
-
await resetGeneratedFolder();
|
|
1916
|
-
await store.open();
|
|
1917
|
-
}
|
|
1918
|
-
const cliFlags = [];
|
|
1919
|
-
if (isomorphicGitBridge2) {
|
|
1920
|
-
cliFlags.push("isomorphicGitBridge");
|
|
1921
|
-
}
|
|
1922
|
-
const database2 = await (0, import_graphql11.createDatabase)({ store, bridge });
|
|
1923
|
-
await compileSchema(null, null, { verbose, dev });
|
|
1924
|
-
const schema = await (0, import_graphql11.buildSchema)(rootPath2, database2, cliFlags);
|
|
1925
|
-
await genTypes({ schema }, () => {
|
|
1926
|
-
}, { noSDK: noSDK2, verbose });
|
|
1927
|
-
} catch (error) {
|
|
1928
|
-
throw error;
|
|
1929
|
-
} finally {
|
|
1930
|
-
buildLock.disable();
|
|
1931
|
-
}
|
|
1932
|
-
};
|
|
1933
2085
|
const state = {
|
|
1934
2086
|
server: null,
|
|
1935
2087
|
sockets: []
|
|
1936
2088
|
};
|
|
1937
2089
|
let isReady = false;
|
|
2090
|
+
const beforeBuild = async () => {
|
|
2091
|
+
await buildLock.promise;
|
|
2092
|
+
buildLock.enable();
|
|
2093
|
+
};
|
|
2094
|
+
const afterBuild = async () => {
|
|
2095
|
+
buildLock.disable();
|
|
2096
|
+
};
|
|
1938
2097
|
const start = async () => {
|
|
1939
2098
|
await buildLock.promise;
|
|
1940
2099
|
buildLock.enable();
|
|
@@ -1983,7 +2142,7 @@ or`);
|
|
|
1983
2142
|
});
|
|
1984
2143
|
});
|
|
1985
2144
|
};
|
|
1986
|
-
const foldersToWatch = (watchFolders || []).map((x) =>
|
|
2145
|
+
const foldersToWatch = (watchFolders || []).map((x) => import_path11.default.join(rootPath2, x));
|
|
1987
2146
|
if (!noWatch && !process.env.CI) {
|
|
1988
2147
|
import_chokidar.default.watch([
|
|
1989
2148
|
...foldersToWatch,
|
|
@@ -1993,14 +2152,27 @@ or`);
|
|
|
1993
2152
|
ignored: [
|
|
1994
2153
|
"**/node_modules/**/*",
|
|
1995
2154
|
"**/.next/**/*",
|
|
1996
|
-
`${
|
|
2155
|
+
`${import_path11.default.resolve(rootPath2)}/.tina/__generated__/**/*`
|
|
1997
2156
|
]
|
|
1998
2157
|
}).on("ready", async () => {
|
|
1999
2158
|
if (verbose)
|
|
2000
2159
|
console.log("Generating Tina config");
|
|
2001
2160
|
try {
|
|
2002
2161
|
if (shouldBuild) {
|
|
2003
|
-
await build2(
|
|
2162
|
+
await build2({
|
|
2163
|
+
bridge,
|
|
2164
|
+
ctx,
|
|
2165
|
+
database,
|
|
2166
|
+
store,
|
|
2167
|
+
dev,
|
|
2168
|
+
isomorphicGitBridge: isomorphicGitBridge2,
|
|
2169
|
+
local: true,
|
|
2170
|
+
noSDK,
|
|
2171
|
+
noWatch,
|
|
2172
|
+
verbose,
|
|
2173
|
+
beforeBuild,
|
|
2174
|
+
afterBuild
|
|
2175
|
+
});
|
|
2004
2176
|
}
|
|
2005
2177
|
ready = true;
|
|
2006
2178
|
isReady = true;
|
|
@@ -2018,7 +2190,20 @@ or`);
|
|
|
2018
2190
|
logger.info("Tina change detected, regenerating config");
|
|
2019
2191
|
try {
|
|
2020
2192
|
if (shouldBuild) {
|
|
2021
|
-
await build2(
|
|
2193
|
+
await build2({
|
|
2194
|
+
bridge,
|
|
2195
|
+
ctx,
|
|
2196
|
+
database,
|
|
2197
|
+
store,
|
|
2198
|
+
dev,
|
|
2199
|
+
isomorphicGitBridge: isomorphicGitBridge2,
|
|
2200
|
+
local: true,
|
|
2201
|
+
noSDK,
|
|
2202
|
+
noWatch,
|
|
2203
|
+
verbose,
|
|
2204
|
+
beforeBuild,
|
|
2205
|
+
afterBuild
|
|
2206
|
+
});
|
|
2022
2207
|
}
|
|
2023
2208
|
if (isReady) {
|
|
2024
2209
|
await restart();
|
|
@@ -2041,7 +2226,20 @@ or`);
|
|
|
2041
2226
|
logger.info("Detected CI environment, omitting watch commands...");
|
|
2042
2227
|
}
|
|
2043
2228
|
if (shouldBuild) {
|
|
2044
|
-
await build2(
|
|
2229
|
+
await build2({
|
|
2230
|
+
bridge,
|
|
2231
|
+
ctx,
|
|
2232
|
+
database,
|
|
2233
|
+
store,
|
|
2234
|
+
dev,
|
|
2235
|
+
isomorphicGitBridge: isomorphicGitBridge2,
|
|
2236
|
+
local: true,
|
|
2237
|
+
noSDK,
|
|
2238
|
+
noWatch,
|
|
2239
|
+
verbose,
|
|
2240
|
+
beforeBuild,
|
|
2241
|
+
afterBuild
|
|
2242
|
+
});
|
|
2045
2243
|
}
|
|
2046
2244
|
await start();
|
|
2047
2245
|
next();
|
|
@@ -2147,13 +2345,22 @@ stack: ${code.stack || "No stack was provided"}`);
|
|
|
2147
2345
|
}
|
|
2148
2346
|
};
|
|
2149
2347
|
|
|
2348
|
+
// src/buildTina/attachPath.ts
|
|
2349
|
+
var import_fs_extra8 = __toModule(require("fs-extra"));
|
|
2350
|
+
var import_path12 = __toModule(require("path"));
|
|
2351
|
+
var attachPath = async (ctx, next, _options) => {
|
|
2352
|
+
ctx.rootPath = process.cwd();
|
|
2353
|
+
const tinaPath = import_path12.default.join(ctx.rootPath, ".tina");
|
|
2354
|
+
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"));
|
|
2355
|
+
next();
|
|
2356
|
+
};
|
|
2357
|
+
|
|
2150
2358
|
// src/cmds/baseCmds.ts
|
|
2151
|
-
var CMD_GEN_TYPES = "schema:types";
|
|
2152
2359
|
var CMD_START_SERVER = "server:start";
|
|
2153
|
-
var
|
|
2154
|
-
var CMD_WAIT_FOR_DB = "server:waitForDB";
|
|
2360
|
+
var CMD_DEV = "dev";
|
|
2155
2361
|
var INIT = "init";
|
|
2156
2362
|
var AUDIT = "audit";
|
|
2363
|
+
var CMD_BUILD = "build";
|
|
2157
2364
|
var startServerPortOption = {
|
|
2158
2365
|
name: "--port <port>",
|
|
2159
2366
|
description: "Specify a port to run the server on. (default 4001)"
|
|
@@ -2207,6 +2414,17 @@ var developmentOption = {
|
|
|
2207
2414
|
name: "--dev",
|
|
2208
2415
|
description: "Uses NODE_ENV=development when compiling client and schema"
|
|
2209
2416
|
};
|
|
2417
|
+
var localOption = {
|
|
2418
|
+
name: "--local",
|
|
2419
|
+
description: "Uses the local file system graphql server",
|
|
2420
|
+
defaultValue: false
|
|
2421
|
+
};
|
|
2422
|
+
var checkOptions = async (_ctx, next, options) => {
|
|
2423
|
+
if (options == null ? void 0 : options.experimentalData) {
|
|
2424
|
+
logger.warn(warnText("Warning: you are using the `--experimentalData`flag. This flag is not needed and can safely be removed. It will be deprecated in a future version"));
|
|
2425
|
+
}
|
|
2426
|
+
next();
|
|
2427
|
+
};
|
|
2210
2428
|
var baseCmds = [
|
|
2211
2429
|
{
|
|
2212
2430
|
command: CMD_START_SERVER,
|
|
@@ -2221,39 +2439,62 @@ var baseCmds = [
|
|
|
2221
2439
|
noTelemetryOption,
|
|
2222
2440
|
watchFileOption,
|
|
2223
2441
|
verboseOption,
|
|
2224
|
-
developmentOption
|
|
2442
|
+
developmentOption,
|
|
2443
|
+
localOption
|
|
2225
2444
|
],
|
|
2226
|
-
action: (options) => chain([
|
|
2445
|
+
action: (options) => chain([
|
|
2446
|
+
attachPath,
|
|
2447
|
+
async (ctx, next, _) => {
|
|
2448
|
+
logger.warn(warnText("server:start will be deprecated in the future, please use `tinacms dev` instead"));
|
|
2449
|
+
next();
|
|
2450
|
+
},
|
|
2451
|
+
checkOptions,
|
|
2452
|
+
buildSetupCmdServerStart,
|
|
2453
|
+
startServer,
|
|
2454
|
+
startSubprocess
|
|
2455
|
+
], options)
|
|
2227
2456
|
},
|
|
2228
2457
|
{
|
|
2229
|
-
command:
|
|
2230
|
-
description: "
|
|
2458
|
+
command: CMD_DEV,
|
|
2459
|
+
description: "Builds tina and starts the dev server.",
|
|
2231
2460
|
options: [
|
|
2461
|
+
startServerPortOption,
|
|
2232
2462
|
subCommand,
|
|
2233
|
-
experimentalDatalayer,
|
|
2234
2463
|
isomorphicGitBridge,
|
|
2464
|
+
noWatchOption,
|
|
2465
|
+
noSDKCodegenOption,
|
|
2235
2466
|
noTelemetryOption,
|
|
2236
|
-
|
|
2237
|
-
|
|
2467
|
+
watchFileOption,
|
|
2468
|
+
verboseOption
|
|
2238
2469
|
],
|
|
2239
|
-
action: (options) => chain([
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
2470
|
+
action: (options) => chain([
|
|
2471
|
+
attachPath,
|
|
2472
|
+
checkOptions,
|
|
2473
|
+
buildSetupCmdServerStart,
|
|
2474
|
+
startServer,
|
|
2475
|
+
startSubprocess
|
|
2476
|
+
], options)
|
|
2246
2477
|
},
|
|
2247
2478
|
{
|
|
2248
|
-
command:
|
|
2249
|
-
description: "
|
|
2479
|
+
command: CMD_BUILD,
|
|
2480
|
+
description: "Build Tina",
|
|
2250
2481
|
options: [
|
|
2251
2482
|
experimentalDatalayer,
|
|
2252
2483
|
isomorphicGitBridge,
|
|
2253
2484
|
noSDKCodegenOption,
|
|
2254
|
-
noTelemetryOption
|
|
2485
|
+
noTelemetryOption,
|
|
2486
|
+
verboseOption,
|
|
2487
|
+
developmentOption,
|
|
2488
|
+
localOption
|
|
2255
2489
|
],
|
|
2256
|
-
action: (options) => chain([
|
|
2490
|
+
action: (options) => chain([
|
|
2491
|
+
attachPath,
|
|
2492
|
+
checkOptions,
|
|
2493
|
+
buildSetupCmdBuild,
|
|
2494
|
+
buildCmdBuild,
|
|
2495
|
+
compileClient,
|
|
2496
|
+
waitForDB
|
|
2497
|
+
], options)
|
|
2257
2498
|
},
|
|
2258
2499
|
{
|
|
2259
2500
|
command: INIT,
|
|
@@ -2265,15 +2506,13 @@ var baseCmds = [
|
|
|
2265
2506
|
],
|
|
2266
2507
|
description: "Add Tina Cloud to an existing project",
|
|
2267
2508
|
action: (options) => chain([
|
|
2509
|
+
attachPath,
|
|
2510
|
+
checkOptions,
|
|
2268
2511
|
checkDeps,
|
|
2269
2512
|
initTina,
|
|
2270
2513
|
installDeps,
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
next();
|
|
2274
|
-
},
|
|
2275
|
-
attachSchema,
|
|
2276
|
-
genTypes,
|
|
2514
|
+
buildSetupCmdBuild,
|
|
2515
|
+
buildCmdBuild,
|
|
2277
2516
|
tinaSetup,
|
|
2278
2517
|
successMessage
|
|
2279
2518
|
], options)
|
|
@@ -2283,16 +2522,9 @@ var baseCmds = [
|
|
|
2283
2522
|
command: AUDIT,
|
|
2284
2523
|
description: "Audit your schema and the files to check for errors",
|
|
2285
2524
|
action: (options) => chain([
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
},
|
|
2290
|
-
async (_ctx, next) => {
|
|
2291
|
-
await compileSchema(_ctx, next, options);
|
|
2292
|
-
next();
|
|
2293
|
-
},
|
|
2294
|
-
attachSchema,
|
|
2295
|
-
genTypes,
|
|
2525
|
+
attachPath,
|
|
2526
|
+
buildSetupCmdAudit,
|
|
2527
|
+
auditCmdBuild,
|
|
2296
2528
|
async (_ctx, next) => {
|
|
2297
2529
|
logger.level = "info";
|
|
2298
2530
|
logger.info(import_chalk7.default.hex("#eb6337").bgWhite("Welcome to tina audit \u{1F999}"));
|