@tinacms/cli 0.60.11 → 0.60.14
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/CHANGELOG.md +33 -0
- package/README.md +1 -0
- package/bin/tinacms +2 -2
- package/dist/cmds/compile/defaultSchema.d.ts +1 -1
- package/dist/cmds/compile/index.d.ts +4 -1
- package/dist/cmds/init/setup-files/index.d.ts +1 -13
- package/dist/cmds/start-server/index.d.ts +2 -1
- package/dist/codegen/index.d.ts +1 -0
- package/dist/index.js +838 -770
- package/package.json +6 -5
package/dist/index.js
CHANGED
|
@@ -79,7 +79,7 @@ var init_server = __esm({
|
|
|
79
79
|
# We've got a simple query set up for you to get started
|
|
80
80
|
# but there's plenty more for you to explore on your own!
|
|
81
81
|
query MyQuery {
|
|
82
|
-
|
|
82
|
+
collections {
|
|
83
83
|
documents {
|
|
84
84
|
id
|
|
85
85
|
sys {
|
|
@@ -114,7 +114,11 @@ var commander = __toModule(require("commander"));
|
|
|
114
114
|
|
|
115
115
|
// pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/package.json
|
|
116
116
|
var name = "@tinacms/cli";
|
|
117
|
-
var version = "0.60.
|
|
117
|
+
var version = "0.60.14";
|
|
118
|
+
|
|
119
|
+
// pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/cmds/query-gen/attachSchema.ts
|
|
120
|
+
var import_graphql = __toModule(require("@tinacms/graphql"));
|
|
121
|
+
var import_datalayer = __toModule(require("@tinacms/datalayer"));
|
|
118
122
|
|
|
119
123
|
// pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/utils/theme.ts
|
|
120
124
|
var import_chalk = __toModule(require("chalk"));
|
|
@@ -127,29 +131,6 @@ var logText = import_chalk.default.italic.gray;
|
|
|
127
131
|
var warnText = import_chalk.default.yellowBright.bgBlack;
|
|
128
132
|
var CONFIRMATION_TEXT = import_chalk.default.dim("enter to confirm");
|
|
129
133
|
|
|
130
|
-
// pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/middleware.ts
|
|
131
|
-
var chain = async (cmds, options) => {
|
|
132
|
-
const ctx = {};
|
|
133
|
-
const next = async (middlewareIndex) => {
|
|
134
|
-
if (middlewareIndex >= cmds.length) {
|
|
135
|
-
process.exit(0);
|
|
136
|
-
}
|
|
137
|
-
try {
|
|
138
|
-
await cmds[middlewareIndex](ctx, () => next(middlewareIndex + 1), options || {});
|
|
139
|
-
} catch (err) {
|
|
140
|
-
console.error(` ${dangerText(err)}`);
|
|
141
|
-
process.exit(1);
|
|
142
|
-
}
|
|
143
|
-
};
|
|
144
|
-
if (cmds.length > 0) {
|
|
145
|
-
await next(0);
|
|
146
|
-
}
|
|
147
|
-
};
|
|
148
|
-
|
|
149
|
-
// pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/cmds/query-gen/attachSchema.ts
|
|
150
|
-
var import_graphql = __toModule(require("@tinacms/graphql"));
|
|
151
|
-
var import_datalayer = __toModule(require("@tinacms/datalayer"));
|
|
152
|
-
|
|
153
134
|
// pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/logger/index.ts
|
|
154
135
|
var import_log4js = __toModule(require("log4js"));
|
|
155
136
|
var logger = import_log4js.default.getLogger();
|
|
@@ -173,11 +154,12 @@ async function attachSchema(ctx, next, options) {
|
|
|
173
154
|
next();
|
|
174
155
|
}
|
|
175
156
|
|
|
157
|
+
// pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/cmds/query-gen/genTypes.ts
|
|
158
|
+
var import_graphql6 = __toModule(require("graphql"));
|
|
159
|
+
var import_fs_extra = __toModule(require("fs-extra"));
|
|
160
|
+
|
|
176
161
|
// pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/codegen/index.ts
|
|
177
162
|
var import_graphql5 = __toModule(require("graphql"));
|
|
178
|
-
var import_core = __toModule(require("@graphql-codegen/core"));
|
|
179
|
-
var import_typescript = __toModule(require("@graphql-codegen/typescript"));
|
|
180
|
-
var import_typescript_operations = __toModule(require("@graphql-codegen/typescript-operations"));
|
|
181
163
|
|
|
182
164
|
// pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/codegen/plugin.ts
|
|
183
165
|
var AddGeneratedClientFunc = (_schema, _documents, _config, _info) => {
|
|
@@ -214,6 +196,13 @@ var AddGeneratedClient = {
|
|
|
214
196
|
plugin: AddGeneratedClientFunc
|
|
215
197
|
};
|
|
216
198
|
|
|
199
|
+
// pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/codegen/index.ts
|
|
200
|
+
var import_graphql_file_loader = __toModule(require("@graphql-tools/graphql-file-loader"));
|
|
201
|
+
var import_core = __toModule(require("@graphql-codegen/core"));
|
|
202
|
+
var import_load = __toModule(require("@graphql-tools/load"));
|
|
203
|
+
var import_typescript_operations = __toModule(require("@graphql-codegen/typescript-operations"));
|
|
204
|
+
var import_typescript = __toModule(require("@graphql-codegen/typescript"));
|
|
205
|
+
|
|
217
206
|
// pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/codegen/sdkPlugin/index.ts
|
|
218
207
|
var import_graphql3 = __toModule(require("graphql"));
|
|
219
208
|
var import_graphql4 = __toModule(require("graphql"));
|
|
@@ -296,10 +285,12 @@ var plugin = (schema, documents, config) => {
|
|
|
296
285
|
};
|
|
297
286
|
|
|
298
287
|
// pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/codegen/index.ts
|
|
299
|
-
var
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
288
|
+
var generateTypes = async (schema, queryPathGlob = process.cwd(), fragDocPath = process.cwd(), options = {
|
|
289
|
+
noSDK: false,
|
|
290
|
+
verbose: false
|
|
291
|
+
}) => {
|
|
292
|
+
if (options.verbose)
|
|
293
|
+
logger.info("Generating types...");
|
|
303
294
|
try {
|
|
304
295
|
let docs = [];
|
|
305
296
|
let fragDocs = [];
|
|
@@ -364,8 +355,6 @@ var generateTypes = async (schema, queryPathGlob = process.cwd(), fragDocPath =
|
|
|
364
355
|
};
|
|
365
356
|
|
|
366
357
|
// pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/cmds/query-gen/genTypes.ts
|
|
367
|
-
var import_graphql6 = __toModule(require("graphql"));
|
|
368
|
-
var import_fs_extra = __toModule(require("fs-extra"));
|
|
369
358
|
async function genTypes({ schema }, next, options) {
|
|
370
359
|
const typesPath = process.cwd() + "/.tina/__generated__/types.ts";
|
|
371
360
|
const fragPath = process.cwd() + "/.tina/__generated__/*.{graphql,gql}";
|
|
@@ -375,7 +364,7 @@ async function genTypes({ schema }, next, options) {
|
|
|
375
364
|
// DO NOT MODIFY THIS FILE. This file is automatically generated by Tina
|
|
376
365
|
${typescriptTypes}
|
|
377
366
|
`);
|
|
378
|
-
logger.info(`Typescript types => ${logText(typesPath)}`);
|
|
367
|
+
logger.info(` Typescript types => ${logText(typesPath)}`);
|
|
379
368
|
const schemaString = await (0, import_graphql6.printSchema)(schema);
|
|
380
369
|
const schemaPath = process.cwd() + "/.tina/__generated__/schema.gql";
|
|
381
370
|
await import_fs_extra.default.outputFile(schemaPath, `# DO NOT MODIFY THIS FILE. This file is automatically generated by Tina
|
|
@@ -385,467 +374,261 @@ schema {
|
|
|
385
374
|
mutation: Mutation
|
|
386
375
|
}
|
|
387
376
|
`);
|
|
388
|
-
logger.info(`GraphQL types ====> ${logText(schemaPath)}
|
|
377
|
+
logger.info(` GraphQL types ====> ${logText(schemaPath)}
|
|
378
|
+
`);
|
|
389
379
|
next();
|
|
390
380
|
}
|
|
391
381
|
|
|
392
|
-
// pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/cmds/
|
|
393
|
-
var
|
|
394
|
-
var import_path4 = __toModule(require("path"));
|
|
395
|
-
var import_graphql7 = __toModule(require("@tinacms/graphql"));
|
|
382
|
+
// pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/cmds/audit/index.ts
|
|
383
|
+
var import_graphql9 = __toModule(require("@tinacms/graphql"));
|
|
396
384
|
var import_datalayer2 = __toModule(require("@tinacms/datalayer"));
|
|
397
385
|
|
|
398
|
-
// pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/cmds/
|
|
399
|
-
var
|
|
400
|
-
var
|
|
401
|
-
var
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
name: "title",
|
|
418
|
-
},
|
|
419
|
-
{
|
|
420
|
-
type: "rich-text",
|
|
421
|
-
label: "Blog Post Body",
|
|
422
|
-
name: "body",
|
|
423
|
-
isBody: true,
|
|
424
|
-
templates: [
|
|
425
|
-
{
|
|
426
|
-
name: "PageSection",
|
|
427
|
-
label: "Page Section",
|
|
428
|
-
fields: [
|
|
429
|
-
{
|
|
430
|
-
type: "string",
|
|
431
|
-
name: "heading",
|
|
432
|
-
label: "Heading",
|
|
433
|
-
},
|
|
434
|
-
{
|
|
435
|
-
type: "string",
|
|
436
|
-
name: "content",
|
|
437
|
-
label: "Content",
|
|
438
|
-
ui: {
|
|
439
|
-
component: "textarea"
|
|
386
|
+
// pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/cmds/audit/audit.ts
|
|
387
|
+
var import_graphql7 = __toModule(require("@tinacms/graphql"));
|
|
388
|
+
var import_path2 = __toModule(require("path"));
|
|
389
|
+
var import_graphql8 = __toModule(require("@tinacms/graphql"));
|
|
390
|
+
var import_chalk2 = __toModule(require("chalk"));
|
|
391
|
+
var auditCollection = async (args) => {
|
|
392
|
+
let warning = false;
|
|
393
|
+
const { collection, database, rootPath: rootPath2 } = args;
|
|
394
|
+
logger.info(`Checking collection ${collection.name}`);
|
|
395
|
+
const query = `query {
|
|
396
|
+
collection(collection: "${collection.name}") {
|
|
397
|
+
format
|
|
398
|
+
documents {
|
|
399
|
+
edges {
|
|
400
|
+
node {
|
|
401
|
+
...on Document {
|
|
402
|
+
_sys {
|
|
403
|
+
extension
|
|
404
|
+
path
|
|
440
405
|
}
|
|
441
406
|
}
|
|
442
|
-
|
|
443
|
-
}
|
|
444
|
-
|
|
445
|
-
}
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
const
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
process.env.NODE_ENV == 'development'
|
|
461
|
-
? 'http://localhost:4001/graphql'
|
|
462
|
-
: \`https://content.tinajs.io/content/\${process.env.NEXT_PUBLIC_TINA_CLIENT_ID}/github/\${branch}\`
|
|
463
|
-
|
|
464
|
-
export const tinaConfig = defineConfig({
|
|
465
|
-
apiURL,
|
|
466
|
-
cmsCallback: (cms) => {
|
|
467
|
-
// add your CMS callback code here (if you want)
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
`;
|
|
413
|
+
const result = await (0, import_graphql7.resolve)({
|
|
414
|
+
database,
|
|
415
|
+
query,
|
|
416
|
+
variables: {}
|
|
417
|
+
});
|
|
418
|
+
const format = result.data.collection.format;
|
|
419
|
+
const docs = result.data.collection.documents.edges;
|
|
420
|
+
docs.forEach((x) => {
|
|
421
|
+
const node = x.node;
|
|
422
|
+
if (node._sys.extension.replace(".", "") !== format) {
|
|
423
|
+
warning = true;
|
|
424
|
+
logger.warn(import_chalk2.default.yellowBright(`WARNING: there is a file with extension \`${node._sys.extension}\` but in your schema it is defined to be \`.${format}\`
|
|
468
425
|
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
426
|
+
location: ${import_path2.default.join(rootPath2, node._sys.path)}`));
|
|
427
|
+
}
|
|
428
|
+
});
|
|
429
|
+
return warning;
|
|
430
|
+
};
|
|
431
|
+
var auditDocuments = async (args) => {
|
|
432
|
+
const { collection, database, rootPath: rootPath2, useDefaultValues } = args;
|
|
433
|
+
const query = `query {
|
|
434
|
+
collection(collection: "${collection.name}") {
|
|
435
|
+
format
|
|
436
|
+
slug
|
|
437
|
+
documents {
|
|
438
|
+
edges {
|
|
439
|
+
node {
|
|
440
|
+
...on Document {
|
|
441
|
+
_sys {
|
|
442
|
+
extension
|
|
443
|
+
path
|
|
444
|
+
relativePath
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
`;
|
|
453
|
+
const result = await (0, import_graphql7.resolve)({
|
|
454
|
+
database,
|
|
455
|
+
query,
|
|
456
|
+
variables: {}
|
|
457
|
+
});
|
|
458
|
+
let error = false;
|
|
459
|
+
const documents = result.data.collection.documents.edges;
|
|
460
|
+
for (let i = 0; i < documents.length; i++) {
|
|
461
|
+
const node = documents[i].node;
|
|
462
|
+
const fullPath = import_path2.default.join(rootPath2, node._sys.path);
|
|
463
|
+
logger.info(`Checking document: ${fullPath}`);
|
|
464
|
+
const documentQuery = `query {
|
|
465
|
+
document(collection: "${collection.name}", relativePath: "${node._sys.relativePath}") {
|
|
466
|
+
__typename
|
|
467
|
+
...on Document {
|
|
468
|
+
_values
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
}`;
|
|
472
|
+
const docResult = await (0, import_graphql7.resolve)({
|
|
473
|
+
database,
|
|
474
|
+
query: documentQuery,
|
|
475
|
+
variables: {}
|
|
476
|
+
});
|
|
477
|
+
const topLevelDefaults = {};
|
|
478
|
+
if (useDefaultValues && typeof collection.fields !== "string") {
|
|
479
|
+
collection.fields.filter((x) => !x.list).forEach((x) => {
|
|
480
|
+
const value = x.ui;
|
|
481
|
+
if (typeof value !== "undefined") {
|
|
482
|
+
topLevelDefaults[x.name] = value.defaultValue;
|
|
483
|
+
}
|
|
479
484
|
});
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
485
|
+
}
|
|
486
|
+
const params = transformDocumentIntoMutationRequestPayload(docResult.data.document._values, {
|
|
487
|
+
includeCollection: true,
|
|
488
|
+
includeTemplate: typeof collection.templates !== "undefined"
|
|
489
|
+
}, topLevelDefaults);
|
|
490
|
+
const mutation = `mutation($collection: String!, $relativePath: String!, $params: DocumentMutation!) {
|
|
491
|
+
updateDocument(
|
|
492
|
+
collection: $collection,
|
|
493
|
+
relativePath: $relativePath,
|
|
494
|
+
params: $params
|
|
495
|
+
){__typename}
|
|
496
|
+
}`;
|
|
497
|
+
const mutationRes = await (0, import_graphql7.resolve)({
|
|
498
|
+
database,
|
|
499
|
+
query: mutation,
|
|
500
|
+
variables: {
|
|
501
|
+
params,
|
|
502
|
+
collection: collection.name,
|
|
503
|
+
relativePath: node._sys.relativePath
|
|
504
|
+
},
|
|
505
|
+
silenceErrors: true
|
|
484
506
|
});
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
// pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/lib/getSchemaPath.ts
|
|
492
|
-
var import_path2 = __toModule(require("path"));
|
|
493
|
-
var import_fs_extra2 = __toModule(require("fs-extra"));
|
|
494
|
-
var ErrorMessage = "Must provide a `.tina/schema.{ts,js,tsx,jsx}`";
|
|
495
|
-
var getSchemaPath = ({ projectDir }) => {
|
|
496
|
-
if (!import_fs_extra2.default.existsSync(projectDir)) {
|
|
497
|
-
throw new Error(ErrorMessage);
|
|
498
|
-
}
|
|
499
|
-
const inputPathTS = import_path2.default.join(projectDir, "schema.ts");
|
|
500
|
-
const inputPathJS = import_path2.default.join(projectDir, "schema.js");
|
|
501
|
-
const inputPathTSX = import_path2.default.join(projectDir, "schema.tsx");
|
|
502
|
-
const inputPathJSX = import_path2.default.join(projectDir, "schema.jsx");
|
|
503
|
-
let inputFile;
|
|
504
|
-
if (import_fs_extra2.default.existsSync(inputPathTS)) {
|
|
505
|
-
inputFile = inputPathTS;
|
|
506
|
-
} else if (import_fs_extra2.default.existsSync(inputPathJS)) {
|
|
507
|
-
inputFile = inputPathJS;
|
|
508
|
-
} else if (import_fs_extra2.default.existsSync(inputPathTSX)) {
|
|
509
|
-
inputFile = inputPathTSX;
|
|
510
|
-
} else if (import_fs_extra2.default.existsSync(inputPathJSX)) {
|
|
511
|
-
inputFile = inputPathJSX;
|
|
512
|
-
}
|
|
513
|
-
if (!inputFile) {
|
|
514
|
-
throw new Error(ErrorMessage);
|
|
507
|
+
if (mutationRes.errors) {
|
|
508
|
+
mutationRes.errors.forEach((err) => {
|
|
509
|
+
error = true;
|
|
510
|
+
logger.error(import_chalk2.default.red(err.message));
|
|
511
|
+
});
|
|
512
|
+
}
|
|
515
513
|
}
|
|
516
|
-
return
|
|
514
|
+
return error;
|
|
517
515
|
};
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
this.name = "BuildSchemaError";
|
|
524
|
-
}
|
|
525
|
-
};
|
|
526
|
-
var ExecuteSchemaError = class extends Error {
|
|
527
|
-
constructor(message) {
|
|
528
|
-
super(message);
|
|
529
|
-
this.name = "ExecuteSchemaError";
|
|
530
|
-
}
|
|
531
|
-
};
|
|
532
|
-
var handleServerErrors = (e) => {
|
|
533
|
-
if (e instanceof BuildSchemaError) {
|
|
534
|
-
logger.error(`${dangerText("ERROR: your schema was not successfully built: see https://tina.io/docs/errors/esbuild-error/ for more details")}
|
|
535
|
-
Error Message Below
|
|
536
|
-
${e}`);
|
|
537
|
-
} else if (e instanceof ExecuteSchemaError) {
|
|
538
|
-
logger.error(`${dangerText("ERROR: your schema was not successfully executed: see https://tina.io/docs/errors/esbuild-error/ for more details")}
|
|
539
|
-
Error Message Below
|
|
540
|
-
${e}`);
|
|
541
|
-
} else {
|
|
542
|
-
logger.info(dangerText("Compilation failed with errors. Server has not been restarted.") + ` see error below
|
|
543
|
-
${e.message}`);
|
|
544
|
-
}
|
|
545
|
-
};
|
|
546
|
-
|
|
547
|
-
// pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/cmds/compile/index.ts
|
|
548
|
-
var tinaPath = import_path3.default.join(process.cwd(), ".tina");
|
|
549
|
-
var packageJSONFilePath = import_path3.default.join(process.cwd(), "package.json");
|
|
550
|
-
var tinaGeneratedPath = import_path3.default.join(tinaPath, "__generated__");
|
|
551
|
-
var tinaTempPath = import_path3.default.join(tinaGeneratedPath, "temp");
|
|
552
|
-
var tinaConfigPath = import_path3.default.join(tinaGeneratedPath, "config");
|
|
553
|
-
var resetGeneratedFolder = async () => {
|
|
554
|
-
try {
|
|
555
|
-
await import_fs_extra3.default.rmdir(tinaGeneratedPath, {
|
|
556
|
-
recursive: true
|
|
557
|
-
});
|
|
558
|
-
} catch (e) {
|
|
559
|
-
console.log(e);
|
|
560
|
-
}
|
|
561
|
-
await import_fs_extra3.default.mkdir(tinaGeneratedPath);
|
|
562
|
-
await import_fs_extra3.default.outputFile(import_path3.default.join(tinaGeneratedPath, ".gitignore"), "db");
|
|
563
|
-
};
|
|
564
|
-
var cleanup = async ({ tinaTempPath: tinaTempPath2 }) => {
|
|
565
|
-
await import_fs_extra3.default.remove(tinaTempPath2);
|
|
516
|
+
var transformDocumentIntoMutationRequestPayload = (document, instructions, defaults) => {
|
|
517
|
+
const _a = document, { _collection, __typename, _template } = _a, rest = __objRest(_a, ["_collection", "__typename", "_template"]);
|
|
518
|
+
const params = transformParams(rest);
|
|
519
|
+
const paramsWithTemplate = instructions.includeTemplate ? { [_template]: params } : params;
|
|
520
|
+
return instructions.includeCollection ? { [_collection]: __spreadValues(__spreadValues({}, defaults), filterObject(paramsWithTemplate)) } : __spreadValues(__spreadValues({}, defaults), filterObject(paramsWithTemplate));
|
|
566
521
|
};
|
|
567
|
-
var
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
try {
|
|
571
|
-
getSchemaPath({ projectDir: tinaPath });
|
|
572
|
-
} catch {
|
|
573
|
-
schemaExists = false;
|
|
522
|
+
var transformParams = (data) => {
|
|
523
|
+
if (["string", "number", "boolean"].includes(typeof data)) {
|
|
524
|
+
return data;
|
|
574
525
|
}
|
|
575
|
-
if (
|
|
576
|
-
|
|
577
|
-
.tina/schema.ts not found, Creating one for you...
|
|
578
|
-
See Documentation: https://tina.io/docs/tina-cloud/cli/#getting-started"
|
|
579
|
-
`));
|
|
580
|
-
const file = import_path3.default.join(tinaPath, "schema.ts");
|
|
581
|
-
await import_fs_extra3.default.ensureFile(file);
|
|
582
|
-
await import_fs_extra3.default.writeFile(file, defaultSchema);
|
|
526
|
+
if (Array.isArray(data)) {
|
|
527
|
+
return data.map((item) => transformParams(item));
|
|
583
528
|
}
|
|
584
529
|
try {
|
|
585
|
-
|
|
530
|
+
(0, import_graphql8.assertShape)(data, (yup) => yup.object({ _template: yup.string().required() }));
|
|
531
|
+
const _a = data, { _template, __typename } = _a, rest = __objRest(_a, ["_template", "__typename"]);
|
|
532
|
+
const nested = transformParams(rest);
|
|
533
|
+
return { [_template]: nested };
|
|
586
534
|
} catch (e) {
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
535
|
+
if (e.message === "Failed to assertShape - _template is a required field") {
|
|
536
|
+
if (!data) {
|
|
537
|
+
return void 0;
|
|
538
|
+
return [];
|
|
539
|
+
}
|
|
540
|
+
const accum = {};
|
|
541
|
+
Object.entries(data).map(([keyName, value]) => {
|
|
542
|
+
accum[keyName] = transformParams(value);
|
|
543
|
+
});
|
|
544
|
+
return accum;
|
|
545
|
+
} else {
|
|
546
|
+
if (!data) {
|
|
547
|
+
return void 0;
|
|
548
|
+
return [];
|
|
549
|
+
}
|
|
550
|
+
throw e;
|
|
593
551
|
}
|
|
594
|
-
});
|
|
595
|
-
try {
|
|
596
|
-
const schemaFunc = require(import_path3.default.join(tinaTempPath, "schema.js"));
|
|
597
|
-
const schemaObject = schemaFunc.default;
|
|
598
|
-
await import_fs_extra3.default.outputFile(import_path3.default.join(tinaConfigPath, "schema.json"), JSON.stringify(schemaObject, null, 2));
|
|
599
|
-
await cleanup({ tinaTempPath });
|
|
600
|
-
} catch (e) {
|
|
601
|
-
await cleanup({ tinaTempPath });
|
|
602
|
-
throw new ExecuteSchemaError(e);
|
|
603
552
|
}
|
|
604
553
|
};
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
const devDeps = (packageJSON == null ? void 0 : packageJSON.devDependencies) || [];
|
|
611
|
-
const external = Object.keys(__spreadValues(__spreadValues(__spreadValues({}, deps), peerDeps), devDeps));
|
|
612
|
-
const inputFile = getSchemaPath({ projectDir });
|
|
613
|
-
const outputPath = import_path3.default.join(tempDir, "schema.js");
|
|
614
|
-
await (0, import_esbuild.build)({
|
|
615
|
-
bundle: true,
|
|
616
|
-
platform: "neutral",
|
|
617
|
-
target: ["node10.4"],
|
|
618
|
-
entryPoints: [inputFile],
|
|
619
|
-
treeShaking: true,
|
|
620
|
-
external: [...external, "./node_modules/*"],
|
|
621
|
-
loader: loaders,
|
|
622
|
-
outfile: outputPath
|
|
623
|
-
});
|
|
624
|
-
logger.info(logText(`Javascript built`));
|
|
625
|
-
};
|
|
626
|
-
var defineSchema = (config) => {
|
|
627
|
-
return config;
|
|
628
|
-
};
|
|
629
|
-
var loaders = {
|
|
630
|
-
".aac": "file",
|
|
631
|
-
".css": "file",
|
|
632
|
-
".eot": "file",
|
|
633
|
-
".flac": "file",
|
|
634
|
-
".gif": "file",
|
|
635
|
-
".jpeg": "file",
|
|
636
|
-
".jpg": "file",
|
|
637
|
-
".json": "json",
|
|
638
|
-
".mp3": "file",
|
|
639
|
-
".mp4": "file",
|
|
640
|
-
".ogg": "file",
|
|
641
|
-
".otf": "file",
|
|
642
|
-
".png": "file",
|
|
643
|
-
".svg": "file",
|
|
644
|
-
".ttf": "file",
|
|
645
|
-
".wav": "file",
|
|
646
|
-
".webm": "file",
|
|
647
|
-
".webp": "file",
|
|
648
|
-
".woff": "file",
|
|
649
|
-
".woff2": "file",
|
|
650
|
-
".js": "jsx",
|
|
651
|
-
".jsx": "jsx",
|
|
652
|
-
".tsx": "tsx"
|
|
653
|
-
};
|
|
554
|
+
function filterObject(obj) {
|
|
555
|
+
const ret = {};
|
|
556
|
+
Object.keys(obj).filter((key) => obj[key] !== void 0).forEach((key) => ret[key] = obj[key]);
|
|
557
|
+
return ret;
|
|
558
|
+
}
|
|
654
559
|
|
|
655
|
-
// pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/cmds/
|
|
656
|
-
var
|
|
560
|
+
// pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/cmds/audit/index.ts
|
|
561
|
+
var import_chalk3 = __toModule(require("chalk"));
|
|
562
|
+
var import_prompts = __toModule(require("prompts"));
|
|
657
563
|
var import_metrics = __toModule(require("@tinacms/metrics"));
|
|
564
|
+
var rootPath = process.cwd();
|
|
565
|
+
var audit = async (ctx, next, options) => {
|
|
566
|
+
const telemetry = new import_metrics.Telemetry({ disabled: options.noTelemetry });
|
|
567
|
+
await telemetry.submitRecord({
|
|
568
|
+
event: {
|
|
569
|
+
name: "tinacms:cli:audit:invoke",
|
|
570
|
+
clean: Boolean(options.clean),
|
|
571
|
+
useDefaults: Boolean(options.useDefaultValues)
|
|
572
|
+
}
|
|
573
|
+
});
|
|
574
|
+
if (options.clean) {
|
|
575
|
+
logger.info(`You are using the \`--clean\` option. This will modify your content as if a user is submitting a form. Before running this you should have a ${import_chalk3.default.bold("clean git tree")} so unwanted changes can be undone.
|
|
658
576
|
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
577
|
+
`);
|
|
578
|
+
const res = await (0, import_prompts.default)({
|
|
579
|
+
name: "useClean",
|
|
580
|
+
type: "confirm",
|
|
581
|
+
message: `Do you want to continue?`
|
|
582
|
+
});
|
|
583
|
+
if (!res.useClean) {
|
|
584
|
+
logger.warn(import_chalk3.default.yellowBright("\u26A0\uFE0F Audit not complete"));
|
|
585
|
+
process.exit(0);
|
|
586
|
+
}
|
|
665
587
|
}
|
|
666
|
-
|
|
667
|
-
|
|
588
|
+
if (options.useDefaultValues && !options.clean) {
|
|
589
|
+
logger.warn(import_chalk3.default.yellowBright("WARNING: using the `--useDefaultValues` without the `--clean` flag has no effect. Please re-run audit and add the `--clean` flag"));
|
|
590
|
+
}
|
|
591
|
+
const bridge = options.clean ? new import_datalayer2.FilesystemBridge(rootPath) : new import_datalayer2.AuditFileSystemBridge(rootPath);
|
|
592
|
+
const store = options.clean ? new import_datalayer2.FilesystemStore({ rootPath }) : new import_datalayer2.AuditFilesystemStore({ rootPath });
|
|
593
|
+
const database = await (0, import_graphql9.createDatabase)({ store, bridge });
|
|
594
|
+
const schema = await database.getSchema();
|
|
595
|
+
const collections = schema.getCollections();
|
|
596
|
+
let warning = false;
|
|
597
|
+
let error = false;
|
|
598
|
+
for (let i = 0; i < collections.length; i++) {
|
|
599
|
+
const collection = collections[i];
|
|
600
|
+
const returnWarning = await auditCollection({
|
|
601
|
+
collection,
|
|
602
|
+
database,
|
|
603
|
+
rootPath,
|
|
604
|
+
useDefaultValues: options.useDefaultValues
|
|
605
|
+
});
|
|
606
|
+
const returnError = await auditDocuments({
|
|
607
|
+
collection,
|
|
608
|
+
database,
|
|
609
|
+
rootPath,
|
|
610
|
+
useDefaultValues: options.useDefaultValues
|
|
611
|
+
});
|
|
612
|
+
warning = warning || returnWarning;
|
|
613
|
+
error = error || returnError;
|
|
668
614
|
}
|
|
615
|
+
ctx.warning = warning;
|
|
616
|
+
ctx.error = error;
|
|
617
|
+
next();
|
|
669
618
|
};
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
noWatch,
|
|
678
|
-
experimentalData,
|
|
679
|
-
noSDK,
|
|
680
|
-
noTelemetry,
|
|
681
|
-
watchFolders
|
|
682
|
-
}) {
|
|
683
|
-
lock.disable();
|
|
684
|
-
const rootPath2 = process.cwd();
|
|
685
|
-
const t = new import_metrics.Telemetry({ disabled: Boolean(noTelemetry) });
|
|
686
|
-
t.submitRecord({
|
|
687
|
-
event: {
|
|
688
|
-
name: "tinacms:cli:server:start:invoke"
|
|
689
|
-
}
|
|
690
|
-
});
|
|
691
|
-
if (!process.env.CI && !noWatch) {
|
|
692
|
-
await resetGeneratedFolder();
|
|
619
|
+
var printFinalMessage = async (ctx, next, _options) => {
|
|
620
|
+
if (ctx.error) {
|
|
621
|
+
logger.error(import_chalk3.default.redBright(`\u203C\uFE0F Audit ${import_chalk3.default.bold("failed")} with errors`));
|
|
622
|
+
} else if (ctx.warning) {
|
|
623
|
+
logger.warn(import_chalk3.default.yellowBright("\u26A0\uFE0F Audit passed with warnings"));
|
|
624
|
+
} else {
|
|
625
|
+
logger.info(import_chalk3.default.greenBright("\u2705 Audit passed"));
|
|
693
626
|
}
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
const shouldBuild = bridge.supportsBuilding();
|
|
697
|
-
const database = await (0, import_graphql7.createDatabase)({ store, bridge });
|
|
698
|
-
const startSubprocess = () => {
|
|
699
|
-
if (typeof command === "string") {
|
|
700
|
-
const commands = command.split(" ");
|
|
701
|
-
const firstCommand = commands[0];
|
|
702
|
-
const args = commands.slice(1) || [];
|
|
703
|
-
const ps = import_child_process.default.spawn(firstCommand, args, {
|
|
704
|
-
stdio: "inherit",
|
|
705
|
-
shell: true
|
|
706
|
-
});
|
|
707
|
-
ps.on("error", (code) => {
|
|
708
|
-
logger.error(dangerText(`An error has occurred in the Next.js child process. Error message below`));
|
|
709
|
-
logger.error(`name: ${code.name}
|
|
710
|
-
message: ${code.message}
|
|
711
|
-
|
|
712
|
-
stack: ${code.stack || "No stack was provided"}`);
|
|
713
|
-
});
|
|
714
|
-
ps.on("close", (code) => {
|
|
715
|
-
logger.info(`child process exited with code ${code}`);
|
|
716
|
-
process.exit(code);
|
|
717
|
-
});
|
|
718
|
-
}
|
|
719
|
-
};
|
|
720
|
-
let ready = false;
|
|
721
|
-
const build2 = async (noSDK2) => {
|
|
722
|
-
await lock.promise;
|
|
723
|
-
lock.enable();
|
|
724
|
-
try {
|
|
725
|
-
if (!process.env.CI && !noWatch) {
|
|
726
|
-
await resetGeneratedFolder();
|
|
727
|
-
}
|
|
728
|
-
const database2 = await (0, import_graphql7.createDatabase)({ store, bridge });
|
|
729
|
-
await compile(null, null);
|
|
730
|
-
const schema = await (0, import_graphql7.buildSchema)(rootPath2, database2);
|
|
731
|
-
await genTypes({ schema }, () => {
|
|
732
|
-
}, { noSDK: noSDK2 });
|
|
733
|
-
} catch (error) {
|
|
734
|
-
throw error;
|
|
735
|
-
} finally {
|
|
736
|
-
lock.disable();
|
|
737
|
-
}
|
|
738
|
-
};
|
|
739
|
-
const foldersToWatch = (watchFolders || []).map((x) => import_path4.default.join(rootPath2, x));
|
|
740
|
-
if (!noWatch && !process.env.CI) {
|
|
741
|
-
import_chokidar.default.watch([
|
|
742
|
-
...foldersToWatch,
|
|
743
|
-
`${rootPath2}/.tina/**/*.{ts,gql,graphql,js,tsx,jsx}`
|
|
744
|
-
], {
|
|
745
|
-
ignored: [
|
|
746
|
-
"**/node_modules/**/*",
|
|
747
|
-
"**/.next/**/*",
|
|
748
|
-
`${import_path4.default.resolve(rootPath2)}/.tina/__generated__/**/*`
|
|
749
|
-
]
|
|
750
|
-
}).on("ready", async () => {
|
|
751
|
-
console.log("Generating Tina config");
|
|
752
|
-
try {
|
|
753
|
-
if (shouldBuild) {
|
|
754
|
-
await build2(noSDK);
|
|
755
|
-
}
|
|
756
|
-
ready = true;
|
|
757
|
-
startSubprocess();
|
|
758
|
-
} catch (e) {
|
|
759
|
-
handleServerErrors(e);
|
|
760
|
-
console.log(e);
|
|
761
|
-
process.exit(0);
|
|
762
|
-
}
|
|
763
|
-
}).on("all", async () => {
|
|
764
|
-
if (ready) {
|
|
765
|
-
logger.info("Tina change detected, regenerating config");
|
|
766
|
-
try {
|
|
767
|
-
if (shouldBuild) {
|
|
768
|
-
await build2(noSDK);
|
|
769
|
-
}
|
|
770
|
-
} catch (e) {
|
|
771
|
-
handleServerErrors(e);
|
|
772
|
-
t.submitRecord({
|
|
773
|
-
event: {
|
|
774
|
-
name: "tinacms:cli:server:error",
|
|
775
|
-
errorMessage: e.message
|
|
776
|
-
}
|
|
777
|
-
});
|
|
778
|
-
}
|
|
779
|
-
}
|
|
780
|
-
});
|
|
781
|
-
} else {
|
|
782
|
-
if (shouldBuild) {
|
|
783
|
-
await build2(noSDK);
|
|
784
|
-
}
|
|
785
|
-
}
|
|
786
|
-
const state = {
|
|
787
|
-
server: null,
|
|
788
|
-
sockets: []
|
|
789
|
-
};
|
|
790
|
-
let isReady = false;
|
|
791
|
-
const start = async () => {
|
|
792
|
-
const s = (init_server(), server_exports);
|
|
793
|
-
state.server = await s.default(database);
|
|
794
|
-
state.server.listen(port, () => {
|
|
795
|
-
logger.info(`Started Filesystem GraphQL server on port: ${port}`);
|
|
796
|
-
logger.info(`Visit the playground at http://localhost:${port}/altair/`);
|
|
797
|
-
});
|
|
798
|
-
state.server.on("error", function(e) {
|
|
799
|
-
if (e.code === "EADDRINUSE") {
|
|
800
|
-
logger.error(dangerText(`Port 4001 already in use`));
|
|
801
|
-
process.exit();
|
|
802
|
-
}
|
|
803
|
-
throw e;
|
|
804
|
-
});
|
|
805
|
-
state.server.on("connection", (socket) => {
|
|
806
|
-
state.sockets.push(socket);
|
|
807
|
-
});
|
|
808
|
-
};
|
|
809
|
-
const restart = async () => {
|
|
810
|
-
logger.info("Detected change to gql package, restarting...");
|
|
811
|
-
delete require.cache[gqlPackageFile];
|
|
812
|
-
state.sockets.forEach((socket) => {
|
|
813
|
-
if (socket.destroyed === false) {
|
|
814
|
-
socket.destroy();
|
|
815
|
-
}
|
|
816
|
-
});
|
|
817
|
-
state.sockets = [];
|
|
818
|
-
state.server.close(() => {
|
|
819
|
-
logger.info("Server closed");
|
|
820
|
-
start();
|
|
821
|
-
});
|
|
822
|
-
};
|
|
823
|
-
if (!noWatch && !process.env.CI) {
|
|
824
|
-
import_chokidar.default.watch([gqlPackageFile]).on("ready", async () => {
|
|
825
|
-
isReady = true;
|
|
826
|
-
start();
|
|
827
|
-
}).on("all", async () => {
|
|
828
|
-
if (isReady) {
|
|
829
|
-
restart();
|
|
830
|
-
}
|
|
831
|
-
});
|
|
832
|
-
} else {
|
|
833
|
-
if (process.env.CI) {
|
|
834
|
-
logger.info("Detected CI environment, omitting watch commands...");
|
|
835
|
-
}
|
|
836
|
-
start();
|
|
837
|
-
startSubprocess();
|
|
838
|
-
}
|
|
839
|
-
}
|
|
840
|
-
|
|
841
|
-
// pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/cmds/init/index.ts
|
|
842
|
-
var import_fs_extra4 = __toModule(require("fs-extra"));
|
|
843
|
-
var import_path5 = __toModule(require("path"));
|
|
844
|
-
var import_progress = __toModule(require("progress"));
|
|
845
|
-
var import_prompts = __toModule(require("prompts"));
|
|
846
|
-
var import_metrics2 = __toModule(require("@tinacms/metrics"));
|
|
627
|
+
next();
|
|
628
|
+
};
|
|
847
629
|
|
|
848
630
|
// pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/cmds/init/setup-files/index.ts
|
|
631
|
+
var import_chalk4 = __toModule(require("chalk"));
|
|
849
632
|
var adminPage = `import { TinaAdmin } from 'tinacms';
|
|
850
633
|
export default TinaAdmin;
|
|
851
634
|
`;
|
|
@@ -854,7 +637,7 @@ title: Vote For Pedro
|
|
|
854
637
|
---
|
|
855
638
|
# Welcome to the blog.
|
|
856
639
|
|
|
857
|
-
> To edit this site head over to the [\`/admin\`](/admin) route. Then click the pencil icon in the bottom lefthand corner to start editing \u{1F999}.
|
|
640
|
+
> To edit this site head over to the [\`/admin\`](/admin) route. Then click the pencil icon in the bottom lefthand corner to start editing \u{1F999}.
|
|
858
641
|
|
|
859
642
|
# Dixi gaude Arethusa
|
|
860
643
|
|
|
@@ -879,7 +662,7 @@ mille rigidi sub taurum.
|
|
|
879
662
|
`;
|
|
880
663
|
var nextPostPage = () => `// THIS FILE HAS BEEN GENERATED WITH THE TINA CLI.
|
|
881
664
|
// This is a demo file once you have tina setup feel free to delete this file
|
|
882
|
-
|
|
665
|
+
|
|
883
666
|
import { staticRequest, gql } from "tinacms";
|
|
884
667
|
import Head from "next/head";
|
|
885
668
|
import { createGlobalStyle } from "styled-components";
|
|
@@ -888,11 +671,9 @@ var nextPostPage = () => `// THIS FILE HAS BEEN GENERATED WITH THE TINA CLI.
|
|
|
888
671
|
|
|
889
672
|
const query = gql\`
|
|
890
673
|
query BlogPostQuery($relativePath: String!) {
|
|
891
|
-
|
|
892
|
-
data {
|
|
674
|
+
posts(relativePath: $relativePath) {
|
|
893
675
|
title
|
|
894
|
-
|
|
895
|
-
}
|
|
676
|
+
body
|
|
896
677
|
}
|
|
897
678
|
}
|
|
898
679
|
\`
|
|
@@ -930,7 +711,7 @@ var nextPostPage = () => `// THIS FILE HAS BEEN GENERATED WITH THE TINA CLI.
|
|
|
930
711
|
text-decoration: underline;
|
|
931
712
|
}
|
|
932
713
|
\`;
|
|
933
|
-
|
|
714
|
+
|
|
934
715
|
const BlogPage = (props) => {
|
|
935
716
|
const { data } = useTina({
|
|
936
717
|
query,
|
|
@@ -957,10 +738,10 @@ var nextPostPage = () => `// THIS FILE HAS BEEN GENERATED WITH THE TINA CLI.
|
|
|
957
738
|
}}
|
|
958
739
|
>
|
|
959
740
|
<h1 className="text-3xl m-8 text-center leading-8 font-extrabold tracking-tight text-gray-900 sm:text-4xl">
|
|
960
|
-
{data.
|
|
741
|
+
{data.posts.title}
|
|
961
742
|
</h1>
|
|
962
743
|
<ContentSection
|
|
963
|
-
content={data.
|
|
744
|
+
content={data.posts.body}
|
|
964
745
|
></ContentSection>
|
|
965
746
|
</div>
|
|
966
747
|
<div className="bg-green-100 text-center">
|
|
@@ -978,7 +759,7 @@ var nextPostPage = () => `// THIS FILE HAS BEEN GENERATED WITH THE TINA CLI.
|
|
|
978
759
|
</>
|
|
979
760
|
);
|
|
980
761
|
};
|
|
981
|
-
|
|
762
|
+
|
|
982
763
|
export const getStaticProps = async ({ params }) => {
|
|
983
764
|
const variables = { relativePath: \`\${params.filename}.md\` }
|
|
984
765
|
let data = {}
|
|
@@ -999,16 +780,18 @@ var nextPostPage = () => `// THIS FILE HAS BEEN GENERATED WITH THE TINA CLI.
|
|
|
999
780
|
},
|
|
1000
781
|
}
|
|
1001
782
|
};
|
|
1002
|
-
|
|
783
|
+
|
|
1003
784
|
export const getStaticPaths = async () => {
|
|
1004
785
|
const postsListData = (await staticRequest({
|
|
1005
786
|
query: gql\`
|
|
1006
787
|
query GetPostsList {
|
|
1007
|
-
|
|
788
|
+
postsConnection {
|
|
1008
789
|
edges {
|
|
1009
790
|
node {
|
|
1010
|
-
|
|
1011
|
-
|
|
791
|
+
...on Document {
|
|
792
|
+
_sys {
|
|
793
|
+
filename
|
|
794
|
+
}
|
|
1012
795
|
}
|
|
1013
796
|
}
|
|
1014
797
|
}
|
|
@@ -1016,15 +799,15 @@ var nextPostPage = () => `// THIS FILE HAS BEEN GENERATED WITH THE TINA CLI.
|
|
|
1016
799
|
}
|
|
1017
800
|
\`,
|
|
1018
801
|
}));
|
|
1019
|
-
|
|
802
|
+
|
|
1020
803
|
return {
|
|
1021
|
-
paths: postsListData.
|
|
1022
|
-
params: { filename: post.node.
|
|
804
|
+
paths: postsListData.postsConnection.edges.map((post) => ({
|
|
805
|
+
params: { filename: post.node._sys.filename },
|
|
1023
806
|
})),
|
|
1024
807
|
fallback: false,
|
|
1025
808
|
};
|
|
1026
809
|
};
|
|
1027
|
-
|
|
810
|
+
|
|
1028
811
|
export default BlogPage;
|
|
1029
812
|
|
|
1030
813
|
const PageSection = props => {
|
|
@@ -1039,7 +822,7 @@ var nextPostPage = () => `// THIS FILE HAS BEEN GENERATED WITH THE TINA CLI.
|
|
|
1039
822
|
const components = {
|
|
1040
823
|
PageSection: PageSection,
|
|
1041
824
|
}
|
|
1042
|
-
|
|
825
|
+
|
|
1043
826
|
const ContentSection = ({ content }) => {
|
|
1044
827
|
return (
|
|
1045
828
|
<div className="relative py-16 bg-white overflow-hidden">
|
|
@@ -1155,25 +938,24 @@ var nextPostPage = () => `// THIS FILE HAS BEEN GENERATED WITH THE TINA CLI.
|
|
|
1155
938
|
</div>
|
|
1156
939
|
);
|
|
1157
940
|
};
|
|
1158
|
-
|
|
941
|
+
|
|
1159
942
|
`;
|
|
1160
|
-
var AppJsContent = (usingSrc, extraImports) =>
|
|
943
|
+
var AppJsContent = (usingSrc, extraImports) => {
|
|
944
|
+
const importLine = import_chalk4.default.green(`+ import Tina from '${usingSrc ? "../" : ""}../.tina/components/TinaDynamicProvider.js'`);
|
|
945
|
+
return `${importLine}
|
|
946
|
+
${extraImports || ""}
|
|
1161
947
|
|
|
1162
|
-
|
|
1163
|
-
const App = ({ Component, pageProps }) => {
|
|
948
|
+
const App = ({ Component, pageProps }) => {
|
|
1164
949
|
return (
|
|
1165
|
-
<Tina>
|
|
1166
|
-
|
|
1167
|
-
</Tina>
|
|
950
|
+
${import_chalk4.default.green("+ <Tina>")}
|
|
951
|
+
<Component {...pageProps} />
|
|
952
|
+
${import_chalk4.default.green("+ </Tina>")}
|
|
1168
953
|
)
|
|
1169
954
|
}
|
|
1170
|
-
|
|
955
|
+
|
|
1171
956
|
export default App
|
|
1172
|
-
|
|
1173
957
|
`;
|
|
1174
|
-
|
|
1175
|
-
// pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/cmds/init/index.ts
|
|
1176
|
-
var import_chalk2 = __toModule(require("chalk"));
|
|
958
|
+
};
|
|
1177
959
|
|
|
1178
960
|
// pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/cmds/init/setup-files/tinaProvider.ts
|
|
1179
961
|
var TinaProvider = `import TinaCMS from 'tinacms'
|
|
@@ -1221,6 +1003,12 @@ function extendNextScripts(scripts) {
|
|
|
1221
1003
|
}
|
|
1222
1004
|
|
|
1223
1005
|
// pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/cmds/init/index.ts
|
|
1006
|
+
var import_fs_extra2 = __toModule(require("fs-extra"));
|
|
1007
|
+
var import_progress = __toModule(require("progress"));
|
|
1008
|
+
var import_metrics2 = __toModule(require("@tinacms/metrics"));
|
|
1009
|
+
var import_chalk5 = __toModule(require("chalk"));
|
|
1010
|
+
var import_path3 = __toModule(require("path"));
|
|
1011
|
+
var import_prompts2 = __toModule(require("prompts"));
|
|
1224
1012
|
function execShellCommand(cmd) {
|
|
1225
1013
|
const exec = require("child_process").exec;
|
|
1226
1014
|
return new Promise((resolve2, _reject) => {
|
|
@@ -1234,14 +1022,19 @@ function execShellCommand(cmd) {
|
|
|
1234
1022
|
}
|
|
1235
1023
|
async function initTina(ctx, next, options) {
|
|
1236
1024
|
const telemetry = new import_metrics2.Telemetry({ disabled: options.noTelemetry });
|
|
1237
|
-
await telemetry.submitRecord({
|
|
1025
|
+
await telemetry.submitRecord({
|
|
1026
|
+
event: {
|
|
1027
|
+
name: "tinacms:cli:init:invoke",
|
|
1028
|
+
schemaFileType: options.schemaFileType || "ts"
|
|
1029
|
+
}
|
|
1030
|
+
});
|
|
1238
1031
|
logger.info(successText("Setting up Tina..."));
|
|
1239
1032
|
next();
|
|
1240
1033
|
}
|
|
1241
1034
|
var MIN_REACT_VERSION = ">=16.14.0";
|
|
1242
1035
|
async function checkDeps(ctx, next, options) {
|
|
1243
1036
|
const bar = new import_progress.default("Checking dependencies. :prog", 1);
|
|
1244
|
-
const packageJSON = JSON.parse((await
|
|
1037
|
+
const packageJSON = JSON.parse((await import_fs_extra2.default.readFileSync(packageJSONPath)).toString());
|
|
1245
1038
|
if (!checkPackage(packageJSON, "react") || !checkPackage(packageJSON, "react-dom")) {
|
|
1246
1039
|
const message = `Unable to initialize Tina due to outdated dependencies, try upgrading the following packages:
|
|
1247
1040
|
"react@${MIN_REACT_VERSION}"
|
|
@@ -1307,334 +1100,600 @@ async function installDeps(ctx, next, options) {
|
|
|
1307
1100
|
next();
|
|
1308
1101
|
}
|
|
1309
1102
|
var baseDir = process.cwd();
|
|
1310
|
-
var packageJSONPath =
|
|
1311
|
-
var blogContentPath =
|
|
1312
|
-
var blogPostPath =
|
|
1313
|
-
var TinaFolder =
|
|
1314
|
-
var componentFolder =
|
|
1315
|
-
var TinaProviderPath =
|
|
1316
|
-
var TinaDynamicProvider =
|
|
1103
|
+
var packageJSONPath = import_path3.default.join(baseDir, "package.json");
|
|
1104
|
+
var blogContentPath = import_path3.default.join(baseDir, "content", "posts");
|
|
1105
|
+
var blogPostPath = import_path3.default.join(blogContentPath, "HelloWorld.md");
|
|
1106
|
+
var TinaFolder = import_path3.default.join(baseDir, ".tina");
|
|
1107
|
+
var componentFolder = import_path3.default.join(TinaFolder, "components");
|
|
1108
|
+
var TinaProviderPath = import_path3.default.join(componentFolder, "TinaProvider.js");
|
|
1109
|
+
var TinaDynamicProvider = import_path3.default.join(componentFolder, "TinaDynamicProvider.js");
|
|
1317
1110
|
async function tinaSetup(_ctx, next, _options) {
|
|
1318
|
-
const
|
|
1319
|
-
if (!
|
|
1111
|
+
const usingSrc = import_fs_extra2.default.pathExistsSync(import_path3.default.join(baseDir, "src"));
|
|
1112
|
+
if (!import_fs_extra2.default.pathExistsSync(blogPostPath)) {
|
|
1320
1113
|
logger.info(logText("Adding a content folder..."));
|
|
1321
|
-
|
|
1322
|
-
|
|
1114
|
+
import_fs_extra2.default.mkdirpSync(blogContentPath);
|
|
1115
|
+
import_fs_extra2.default.writeFileSync(blogPostPath, blogPost);
|
|
1323
1116
|
}
|
|
1324
|
-
if (!
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1117
|
+
if (!import_fs_extra2.default.existsSync(TinaProviderPath) && !import_fs_extra2.default.existsSync(TinaDynamicProvider)) {
|
|
1118
|
+
import_fs_extra2.default.mkdirpSync(componentFolder);
|
|
1119
|
+
import_fs_extra2.default.writeFileSync(TinaProviderPath, TinaProvider.replace(/'\.\.\/schema\.ts'/, `'../schema.${_ctx.schemaFileType || "ts"}'`));
|
|
1120
|
+
import_fs_extra2.default.writeFileSync(TinaDynamicProvider, TinaProviderDynamic);
|
|
1328
1121
|
}
|
|
1329
1122
|
logger.level = "info";
|
|
1330
|
-
const pagesPath =
|
|
1331
|
-
const appPath =
|
|
1332
|
-
const appPathTS =
|
|
1333
|
-
const appExtension =
|
|
1334
|
-
if (!
|
|
1123
|
+
const pagesPath = import_path3.default.join(baseDir, usingSrc ? "src" : "", "pages");
|
|
1124
|
+
const appPath = import_path3.default.join(pagesPath, "_app.js");
|
|
1125
|
+
const appPathTS = import_path3.default.join(pagesPath, "_app.tsx");
|
|
1126
|
+
const appExtension = import_fs_extra2.default.existsSync(appPath) ? ".js" : ".tsx";
|
|
1127
|
+
if (!import_fs_extra2.default.pathExistsSync(appPath) && !import_fs_extra2.default.pathExistsSync(appPathTS)) {
|
|
1335
1128
|
logger.info(logText("Adding _app.js ... \u2705"));
|
|
1336
|
-
|
|
1129
|
+
import_fs_extra2.default.writeFileSync(appPath, AppJsContent(usingSrc));
|
|
1337
1130
|
} else {
|
|
1338
|
-
const override = await (0,
|
|
1131
|
+
const override = await (0, import_prompts2.default)({
|
|
1339
1132
|
name: "res",
|
|
1340
1133
|
type: "confirm",
|
|
1341
|
-
message: `do you want us to ${
|
|
1134
|
+
message: `do you want us to ${import_chalk5.default.bold(`override`)} your _app${appExtension}?`
|
|
1342
1135
|
});
|
|
1136
|
+
_ctx.overrideApp = override.res;
|
|
1343
1137
|
if (override.res) {
|
|
1344
1138
|
logger.info(logText(`Adding _app${appExtension} ... \u2705`));
|
|
1345
|
-
const appPathWithExtension =
|
|
1346
|
-
const fileContent =
|
|
1139
|
+
const appPathWithExtension = import_path3.default.join(pagesPath, `_app${appExtension}`);
|
|
1140
|
+
const fileContent = import_fs_extra2.default.pathExistsSync(appPath) ? (0, import_fs_extra2.readFileSync)(appPath) : (0, import_fs_extra2.readFileSync)(appPathTS);
|
|
1347
1141
|
const matches = [
|
|
1348
1142
|
...fileContent.toString().matchAll(/^.*import.*\.css("|').*$/gm)
|
|
1349
1143
|
];
|
|
1350
1144
|
const primaryMatches = matches.map((x) => x[0]);
|
|
1351
|
-
|
|
1352
|
-
} else {
|
|
1353
|
-
logger.info(dangerText(`Heads up, to enable live-editing you'll need to wrap your page or site in Tina:
|
|
1354
|
-
`, warnText(AppJsContent(useingSrc))));
|
|
1145
|
+
import_fs_extra2.default.writeFileSync(appPathWithExtension, AppJsContent(usingSrc, primaryMatches.join("\n")));
|
|
1355
1146
|
}
|
|
1356
1147
|
}
|
|
1357
|
-
const tinaBlogPagePath =
|
|
1358
|
-
const tinaBlogPagePathFile =
|
|
1359
|
-
if (!
|
|
1360
|
-
|
|
1361
|
-
|
|
1148
|
+
const tinaBlogPagePath = import_path3.default.join(pagesPath, "demo", "blog");
|
|
1149
|
+
const tinaBlogPagePathFile = import_path3.default.join(tinaBlogPagePath, "[filename].js");
|
|
1150
|
+
if (!import_fs_extra2.default.pathExistsSync(tinaBlogPagePathFile)) {
|
|
1151
|
+
import_fs_extra2.default.mkdirpSync(tinaBlogPagePath);
|
|
1152
|
+
import_fs_extra2.default.writeFileSync(tinaBlogPagePathFile, nextPostPage());
|
|
1362
1153
|
}
|
|
1363
1154
|
logger.info("Adding a content folder... \u2705");
|
|
1364
|
-
const packagePath =
|
|
1365
|
-
const pack = JSON.parse((0,
|
|
1155
|
+
const packagePath = import_path3.default.join(baseDir, "package.json");
|
|
1156
|
+
const pack = JSON.parse((0, import_fs_extra2.readFileSync)(packagePath).toString());
|
|
1366
1157
|
const oldScripts = pack.scripts || {};
|
|
1367
1158
|
const newPack = JSON.stringify(__spreadProps(__spreadValues({}, pack), {
|
|
1368
1159
|
scripts: extendNextScripts(oldScripts)
|
|
1369
1160
|
}), null, 2);
|
|
1370
|
-
(0,
|
|
1371
|
-
const adminPath =
|
|
1372
|
-
if (
|
|
1161
|
+
(0, import_fs_extra2.writeFileSync)(packagePath, newPack);
|
|
1162
|
+
const adminPath = import_path3.default.join(pagesPath, "admin.js");
|
|
1163
|
+
if (import_fs_extra2.default.pathExistsSync(import_path3.default.join(pagesPath, "admin"))) {
|
|
1373
1164
|
logger.warn(`Unable to add /pages/admin.js, this path already exists.
|
|
1374
1165
|
Learn more about toggling edit-mode at https://tina.io/docs/tinacms-context/#manually-toggling-edit-mode`);
|
|
1375
1166
|
return next();
|
|
1376
1167
|
}
|
|
1377
|
-
(0,
|
|
1168
|
+
(0, import_fs_extra2.outputFileSync)(adminPath, adminPage);
|
|
1378
1169
|
next();
|
|
1379
1170
|
}
|
|
1380
1171
|
async function successMessage(ctx, next, options) {
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1172
|
+
const usingSrc = import_fs_extra2.default.pathExistsSync(import_path3.default.join(baseDir, "src"));
|
|
1173
|
+
logger.info(`Tina setup ${import_chalk5.default.underline.green("done")} \u2705
|
|
1174
|
+
`);
|
|
1175
|
+
logger.info("Next Steps: \n");
|
|
1176
|
+
if (!ctx.overrideApp) {
|
|
1177
|
+
logger.info(`${import_chalk5.default.bold("Add the Tina wrapper")}`);
|
|
1178
|
+
logger.info(`\u26A0\uFE0F Before using Tina, you will NEED to add the Tina wrapper to your _app.jsx
|
|
1384
1179
|
`);
|
|
1180
|
+
logger.info(`${AppJsContent(usingSrc)}`);
|
|
1181
|
+
}
|
|
1182
|
+
logger.info(`${import_chalk5.default.bold("Run your site with Tina")}`);
|
|
1183
|
+
logger.info(` yarn dev
|
|
1184
|
+
`);
|
|
1185
|
+
logger.info(`${import_chalk5.default.bold("Start Editing")}`);
|
|
1186
|
+
logger.info(` Go to 'http://localhost:3000/admin'
|
|
1187
|
+
`);
|
|
1188
|
+
logger.info(`${import_chalk5.default.bold("Read the docs")}`);
|
|
1189
|
+
logger.info(` Check out 'https://tina.io/docs/introduction/tina-init/#adding-tina' for help getting started with Tina
|
|
1190
|
+
`);
|
|
1191
|
+
logger.info(`Enjoy Tina! \u{1F999}`);
|
|
1385
1192
|
next();
|
|
1386
1193
|
}
|
|
1387
1194
|
|
|
1388
|
-
// pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/
|
|
1389
|
-
var
|
|
1390
|
-
|
|
1195
|
+
// pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/middleware.ts
|
|
1196
|
+
var chain = async (cmds, options) => {
|
|
1197
|
+
const ctx = {};
|
|
1198
|
+
const next = async (middlewareIndex) => {
|
|
1199
|
+
if (middlewareIndex >= cmds.length) {
|
|
1200
|
+
process.exit(0);
|
|
1201
|
+
}
|
|
1202
|
+
try {
|
|
1203
|
+
await cmds[middlewareIndex](ctx, () => next(middlewareIndex + 1), options || {});
|
|
1204
|
+
} catch (err) {
|
|
1205
|
+
console.error(` ${dangerText(err)}`);
|
|
1206
|
+
process.exit(1);
|
|
1207
|
+
}
|
|
1208
|
+
};
|
|
1209
|
+
if (cmds.length > 0) {
|
|
1210
|
+
await next(0);
|
|
1211
|
+
}
|
|
1212
|
+
};
|
|
1391
1213
|
|
|
1392
|
-
// pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/cmds/
|
|
1393
|
-
var
|
|
1394
|
-
var import_path6 = __toModule(require("path"));
|
|
1395
|
-
var import_graphql9 = __toModule(require("@tinacms/graphql"));
|
|
1396
|
-
var import_chalk3 = __toModule(require("chalk"));
|
|
1397
|
-
var auditCollection = async (args) => {
|
|
1398
|
-
let warning = false;
|
|
1399
|
-
const { collection, database, rootPath: rootPath2 } = args;
|
|
1400
|
-
logger.info(`Checking collection ${collection.name}`);
|
|
1401
|
-
const query = `query {
|
|
1402
|
-
getCollection(collection: "${collection.name}") {
|
|
1403
|
-
format
|
|
1404
|
-
documents {
|
|
1405
|
-
edges {
|
|
1406
|
-
node {
|
|
1407
|
-
...on Document {
|
|
1408
|
-
sys {
|
|
1409
|
-
extension
|
|
1410
|
-
path
|
|
1411
|
-
}
|
|
1412
|
-
}
|
|
1413
|
-
}
|
|
1414
|
-
}
|
|
1415
|
-
}
|
|
1416
|
-
}
|
|
1417
|
-
}
|
|
1418
|
-
`;
|
|
1419
|
-
const result = await (0, import_graphql8.resolve)({
|
|
1420
|
-
database,
|
|
1421
|
-
query,
|
|
1422
|
-
variables: {}
|
|
1423
|
-
});
|
|
1424
|
-
const format = result.data.getCollection.format;
|
|
1425
|
-
const docs = result.data.getCollection.documents.edges;
|
|
1426
|
-
docs.forEach((x) => {
|
|
1427
|
-
const node = x.node;
|
|
1428
|
-
if (node.sys.extension.replace(".", "") !== format) {
|
|
1429
|
-
warning = true;
|
|
1430
|
-
logger.warn(import_chalk3.default.yellowBright(`WARNING: there is a file with extension \`${node.sys.extension}\` but in your schema it is defined to be \`.${format}\`
|
|
1214
|
+
// pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/cmds/baseCmds.ts
|
|
1215
|
+
var import_chalk7 = __toModule(require("chalk"));
|
|
1431
1216
|
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1217
|
+
// pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/cmds/start-server/errors/index.ts
|
|
1218
|
+
var BuildSchemaError = class extends Error {
|
|
1219
|
+
constructor(message) {
|
|
1220
|
+
super(message);
|
|
1221
|
+
this.name = "BuildSchemaError";
|
|
1222
|
+
}
|
|
1436
1223
|
};
|
|
1437
|
-
var
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1224
|
+
var ExecuteSchemaError = class extends Error {
|
|
1225
|
+
constructor(message) {
|
|
1226
|
+
super(message);
|
|
1227
|
+
this.name = "ExecuteSchemaError";
|
|
1228
|
+
}
|
|
1229
|
+
};
|
|
1230
|
+
var handleServerErrors = (e) => {
|
|
1231
|
+
if (e.name === "BuildSchemaError") {
|
|
1232
|
+
logger.error(`${dangerText("ERROR: your schema was not successfully built: see https://tina.io/docs/errors/esbuild-error/ for more details")}
|
|
1233
|
+
Error Message Below
|
|
1234
|
+
${e}`);
|
|
1235
|
+
} else if (e.name === "ExecuteSchemaError") {
|
|
1236
|
+
logger.error(`${dangerText("ERROR: your schema was not successfully executed: see https://tina.io/docs/errors/esbuild-error/ for more details")}
|
|
1237
|
+
Error Message Below
|
|
1238
|
+
${e}`);
|
|
1239
|
+
} else if (e.name === "TinaSchemaValidationError") {
|
|
1240
|
+
logger.error(`${dangerText("ERROR: your schema was not successfully validated: see https://tina.io/docs/schema/ for instructions on how to setup a schema")}
|
|
1241
|
+
Error Message Below
|
|
1242
|
+
${e}`);
|
|
1243
|
+
} else {
|
|
1244
|
+
logger.info(dangerText("Compilation failed with errors. Server has not been restarted.") + ` see error below
|
|
1245
|
+
${e.message}`);
|
|
1246
|
+
}
|
|
1247
|
+
};
|
|
1248
|
+
|
|
1249
|
+
// pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/cmds/compile/index.ts
|
|
1250
|
+
var import_fs_extra4 = __toModule(require("fs-extra"));
|
|
1251
|
+
var import_path5 = __toModule(require("path"));
|
|
1252
|
+
var import_esbuild = __toModule(require("esbuild"));
|
|
1253
|
+
|
|
1254
|
+
// pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/cmds/compile/defaultSchema.ts
|
|
1255
|
+
var defaultSchema = (sep) => `
|
|
1256
|
+
import { defineSchema, defineConfig } from "tinacms";
|
|
1257
|
+
|
|
1258
|
+
const schema = defineSchema({
|
|
1259
|
+
collections: [
|
|
1260
|
+
{
|
|
1261
|
+
label: "Blog Posts",
|
|
1262
|
+
name: "posts",
|
|
1263
|
+
path: "content${sep}posts",
|
|
1264
|
+
fields: [
|
|
1265
|
+
{
|
|
1266
|
+
type: "string",
|
|
1267
|
+
label: "Title",
|
|
1268
|
+
name: "title",
|
|
1269
|
+
},
|
|
1270
|
+
{
|
|
1271
|
+
type: "rich-text",
|
|
1272
|
+
label: "Blog Post Body",
|
|
1273
|
+
name: "body",
|
|
1274
|
+
isBody: true,
|
|
1275
|
+
templates: [
|
|
1276
|
+
{
|
|
1277
|
+
name: "PageSection",
|
|
1278
|
+
label: "Page Section",
|
|
1279
|
+
fields: [
|
|
1280
|
+
{
|
|
1281
|
+
type: "string",
|
|
1282
|
+
name: "heading",
|
|
1283
|
+
label: "Heading",
|
|
1284
|
+
},
|
|
1285
|
+
{
|
|
1286
|
+
type: "string",
|
|
1287
|
+
name: "content",
|
|
1288
|
+
label: "Content",
|
|
1289
|
+
ui: {
|
|
1290
|
+
component: "textarea"
|
|
1451
1291
|
}
|
|
1452
1292
|
}
|
|
1453
|
-
|
|
1454
|
-
}
|
|
1455
|
-
|
|
1456
|
-
}
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1293
|
+
],
|
|
1294
|
+
},
|
|
1295
|
+
]
|
|
1296
|
+
},
|
|
1297
|
+
],
|
|
1298
|
+
},
|
|
1299
|
+
],
|
|
1300
|
+
});
|
|
1301
|
+
|
|
1302
|
+
export default schema
|
|
1303
|
+
|
|
1304
|
+
// Your tina config
|
|
1305
|
+
// ==============
|
|
1306
|
+
const branch = 'main'
|
|
1307
|
+
// When working locally, hit our local filesystem.
|
|
1308
|
+
// On a Vercel deployment, hit the Tina Cloud API
|
|
1309
|
+
const apiURL =
|
|
1310
|
+
process.env.NODE_ENV == 'development'
|
|
1311
|
+
? 'http://localhost:4001/graphql'
|
|
1312
|
+
: \`https://content.tinajs.io/content/\${process.env.NEXT_PUBLIC_TINA_CLIENT_ID}/github/\${branch}\`
|
|
1313
|
+
|
|
1314
|
+
export const tinaConfig = defineConfig({
|
|
1315
|
+
apiURL,
|
|
1316
|
+
schema,
|
|
1317
|
+
cmsCallback: (cms) => {
|
|
1318
|
+
// add your CMS callback code here (if you want)
|
|
1319
|
+
|
|
1320
|
+
// The Route Mapper
|
|
1321
|
+
/**
|
|
1322
|
+
* 1. Import \`tinacms\` and \`RouteMappingPlugin\`
|
|
1323
|
+
**/
|
|
1324
|
+
import("tinacms").then(({ RouteMappingPlugin }) => {
|
|
1325
|
+
/**
|
|
1326
|
+
* 2. Define the \`RouteMappingPlugin\` see https://tina.io/docs/tinacms-context/#the-routemappingplugin for more details
|
|
1327
|
+
**/
|
|
1328
|
+
const RouteMapping = new RouteMappingPlugin((collection, document) => {
|
|
1329
|
+
return undefined;
|
|
1490
1330
|
});
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
}, topLevelDefaults);
|
|
1496
|
-
const mutation = `mutation($collection: String!, $relativePath: String!, $params: DocumentMutation!) {
|
|
1497
|
-
updateDocument(
|
|
1498
|
-
collection: $collection,
|
|
1499
|
-
relativePath: $relativePath,
|
|
1500
|
-
params: $params
|
|
1501
|
-
){__typename}
|
|
1502
|
-
}`;
|
|
1503
|
-
const mutationRes = await (0, import_graphql8.resolve)({
|
|
1504
|
-
database,
|
|
1505
|
-
query: mutation,
|
|
1506
|
-
variables: {
|
|
1507
|
-
params,
|
|
1508
|
-
collection: collection.name,
|
|
1509
|
-
relativePath: node.sys.relativePath
|
|
1510
|
-
},
|
|
1511
|
-
silenceErrors: true
|
|
1331
|
+
/**
|
|
1332
|
+
* 3. Add the \`RouteMappingPlugin\` to the \`cms\`.
|
|
1333
|
+
**/
|
|
1334
|
+
cms.plugins.add(RouteMapping);
|
|
1512
1335
|
});
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1336
|
+
|
|
1337
|
+
return cms;
|
|
1338
|
+
},
|
|
1339
|
+
});
|
|
1340
|
+
`;
|
|
1341
|
+
|
|
1342
|
+
// pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/lib/getSchemaPath.ts
|
|
1343
|
+
var import_path4 = __toModule(require("path"));
|
|
1344
|
+
var import_fs_extra3 = __toModule(require("fs-extra"));
|
|
1345
|
+
var ErrorMessage = "Must provide a `.tina/schema.{ts,js,tsx,jsx}`";
|
|
1346
|
+
var getSchemaPath = ({ projectDir }) => {
|
|
1347
|
+
if (!import_fs_extra3.default.existsSync(projectDir)) {
|
|
1348
|
+
throw new Error(ErrorMessage);
|
|
1349
|
+
}
|
|
1350
|
+
const inputPathTS = import_path4.default.join(projectDir, "schema.ts");
|
|
1351
|
+
const inputPathJS = import_path4.default.join(projectDir, "schema.js");
|
|
1352
|
+
const inputPathTSX = import_path4.default.join(projectDir, "schema.tsx");
|
|
1353
|
+
const inputPathJSX = import_path4.default.join(projectDir, "schema.jsx");
|
|
1354
|
+
let inputFile;
|
|
1355
|
+
if (import_fs_extra3.default.existsSync(inputPathTS)) {
|
|
1356
|
+
inputFile = inputPathTS;
|
|
1357
|
+
} else if (import_fs_extra3.default.existsSync(inputPathJS)) {
|
|
1358
|
+
inputFile = inputPathJS;
|
|
1359
|
+
} else if (import_fs_extra3.default.existsSync(inputPathTSX)) {
|
|
1360
|
+
inputFile = inputPathTSX;
|
|
1361
|
+
} else if (import_fs_extra3.default.existsSync(inputPathJSX)) {
|
|
1362
|
+
inputFile = inputPathJSX;
|
|
1363
|
+
}
|
|
1364
|
+
if (!inputFile) {
|
|
1365
|
+
throw new Error(ErrorMessage);
|
|
1366
|
+
}
|
|
1367
|
+
return inputFile;
|
|
1368
|
+
};
|
|
1369
|
+
|
|
1370
|
+
// pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/cmds/compile/index.ts
|
|
1371
|
+
var tinaPath = import_path5.default.join(process.cwd(), ".tina");
|
|
1372
|
+
var packageJSONFilePath = import_path5.default.join(process.cwd(), "package.json");
|
|
1373
|
+
var tinaGeneratedPath = import_path5.default.join(tinaPath, "__generated__");
|
|
1374
|
+
var tinaTempPath = import_path5.default.join(tinaGeneratedPath, "temp");
|
|
1375
|
+
var tinaConfigPath = import_path5.default.join(tinaGeneratedPath, "config");
|
|
1376
|
+
var resetGeneratedFolder = async () => {
|
|
1377
|
+
try {
|
|
1378
|
+
await import_fs_extra4.default.rmdir(tinaGeneratedPath, {
|
|
1379
|
+
recursive: true
|
|
1380
|
+
});
|
|
1381
|
+
} catch (e) {
|
|
1382
|
+
console.log(e);
|
|
1383
|
+
}
|
|
1384
|
+
await import_fs_extra4.default.mkdir(tinaGeneratedPath);
|
|
1385
|
+
await import_fs_extra4.default.outputFile(import_path5.default.join(tinaGeneratedPath, ".gitignore"), "db");
|
|
1386
|
+
};
|
|
1387
|
+
var cleanup = async ({ tinaTempPath: tinaTempPath2 }) => {
|
|
1388
|
+
await import_fs_extra4.default.remove(tinaTempPath2);
|
|
1389
|
+
};
|
|
1390
|
+
var compile = async (_ctx, _next, options) => {
|
|
1391
|
+
if (!options.schemaFileType)
|
|
1392
|
+
options = __spreadProps(__spreadValues({}, options), { schemaFileType: "ts" });
|
|
1393
|
+
if (options.verbose) {
|
|
1394
|
+
logger.info(logText("Compiling..."));
|
|
1395
|
+
}
|
|
1396
|
+
const { schemaFileType: requestedSchemaFileType = "ts" } = options;
|
|
1397
|
+
const schemaFileType2 = (requestedSchemaFileType === "ts" || requestedSchemaFileType === "tsx") && "ts" || (requestedSchemaFileType === "js" || requestedSchemaFileType === "jsx") && "js";
|
|
1398
|
+
if (!schemaFileType2) {
|
|
1399
|
+
throw new Error(`Requested schema file type '${requestedSchemaFileType}' is not valid. Supported schema file types: 'ts, js, tsx, jsx'`);
|
|
1400
|
+
}
|
|
1401
|
+
if (_ctx) {
|
|
1402
|
+
_ctx.schemaFileType = schemaFileType2;
|
|
1403
|
+
}
|
|
1404
|
+
let schemaExists = true;
|
|
1405
|
+
try {
|
|
1406
|
+
getSchemaPath({ projectDir: tinaPath });
|
|
1407
|
+
} catch {
|
|
1408
|
+
schemaExists = false;
|
|
1409
|
+
}
|
|
1410
|
+
if (!schemaExists) {
|
|
1411
|
+
logger.info(dangerText(`
|
|
1412
|
+
.tina/schema.${schemaFileType2} not found, Creating one for you...
|
|
1413
|
+
See Documentation: https://tina.io/docs/tina-cloud/cli/#getting-started"
|
|
1414
|
+
`));
|
|
1415
|
+
const file = import_path5.default.join(tinaPath, `schema.${schemaFileType2}`);
|
|
1416
|
+
await import_fs_extra4.default.ensureFile(file);
|
|
1417
|
+
await import_fs_extra4.default.writeFile(file, defaultSchema(import_path5.default.sep));
|
|
1418
|
+
}
|
|
1419
|
+
try {
|
|
1420
|
+
await transpile(tinaPath, tinaTempPath, options.verbose);
|
|
1421
|
+
} catch (e) {
|
|
1422
|
+
await cleanup({ tinaTempPath });
|
|
1423
|
+
throw new BuildSchemaError(e);
|
|
1424
|
+
}
|
|
1425
|
+
Object.keys(require.cache).map((key) => {
|
|
1426
|
+
if (key.startsWith(tinaTempPath)) {
|
|
1427
|
+
delete require.cache[require.resolve(key)];
|
|
1428
|
+
}
|
|
1429
|
+
});
|
|
1430
|
+
try {
|
|
1431
|
+
const schemaFunc = require(import_path5.default.join(tinaTempPath, "schema.js"));
|
|
1432
|
+
const schemaObject = schemaFunc.default;
|
|
1433
|
+
await import_fs_extra4.default.outputFile(import_path5.default.join(tinaConfigPath, "schema.json"), JSON.stringify(schemaObject, null, 2));
|
|
1434
|
+
await cleanup({ tinaTempPath });
|
|
1435
|
+
} catch (e) {
|
|
1436
|
+
await cleanup({ tinaTempPath });
|
|
1437
|
+
if (e instanceof Error) {
|
|
1438
|
+
if (e.name === "TinaSchemaValidationError") {
|
|
1439
|
+
throw e;
|
|
1440
|
+
}
|
|
1518
1441
|
}
|
|
1442
|
+
throw new ExecuteSchemaError(e);
|
|
1519
1443
|
}
|
|
1520
|
-
return error;
|
|
1521
1444
|
};
|
|
1522
|
-
var
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
const
|
|
1526
|
-
|
|
1445
|
+
var transpile = async (projectDir, tempDir, verbose) => {
|
|
1446
|
+
if (verbose)
|
|
1447
|
+
logger.info(logText("Building javascript..."));
|
|
1448
|
+
const packageJSON = JSON.parse(import_fs_extra4.default.readFileSync(packageJSONFilePath).toString() || "{}");
|
|
1449
|
+
const deps = (packageJSON == null ? void 0 : packageJSON.dependencies) || [];
|
|
1450
|
+
const peerDeps = (packageJSON == null ? void 0 : packageJSON.peerDependencies) || [];
|
|
1451
|
+
const devDeps = (packageJSON == null ? void 0 : packageJSON.devDependencies) || [];
|
|
1452
|
+
const external = Object.keys(__spreadValues(__spreadValues(__spreadValues({}, deps), peerDeps), devDeps));
|
|
1453
|
+
const inputFile = getSchemaPath({ projectDir });
|
|
1454
|
+
const outputPath = import_path5.default.join(tempDir, "schema.js");
|
|
1455
|
+
await (0, import_esbuild.build)({
|
|
1456
|
+
bundle: true,
|
|
1457
|
+
platform: "neutral",
|
|
1458
|
+
target: ["node10.4"],
|
|
1459
|
+
entryPoints: [inputFile],
|
|
1460
|
+
treeShaking: true,
|
|
1461
|
+
external: [...external, "./node_modules/*"],
|
|
1462
|
+
loader: loaders,
|
|
1463
|
+
outfile: outputPath
|
|
1464
|
+
});
|
|
1465
|
+
if (verbose)
|
|
1466
|
+
logger.info(logText(`Javascript built`));
|
|
1467
|
+
};
|
|
1468
|
+
var defineSchema = (config) => {
|
|
1469
|
+
return config;
|
|
1470
|
+
};
|
|
1471
|
+
var loaders = {
|
|
1472
|
+
".aac": "file",
|
|
1473
|
+
".css": "file",
|
|
1474
|
+
".eot": "file",
|
|
1475
|
+
".flac": "file",
|
|
1476
|
+
".gif": "file",
|
|
1477
|
+
".jpeg": "file",
|
|
1478
|
+
".jpg": "file",
|
|
1479
|
+
".json": "json",
|
|
1480
|
+
".mp3": "file",
|
|
1481
|
+
".mp4": "file",
|
|
1482
|
+
".ogg": "file",
|
|
1483
|
+
".otf": "file",
|
|
1484
|
+
".png": "file",
|
|
1485
|
+
".svg": "file",
|
|
1486
|
+
".ttf": "file",
|
|
1487
|
+
".wav": "file",
|
|
1488
|
+
".webm": "file",
|
|
1489
|
+
".webp": "file",
|
|
1490
|
+
".woff": "file",
|
|
1491
|
+
".woff2": "file",
|
|
1492
|
+
".js": "jsx",
|
|
1493
|
+
".jsx": "jsx",
|
|
1494
|
+
".tsx": "tsx"
|
|
1527
1495
|
};
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1496
|
+
|
|
1497
|
+
// pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/cmds/start-server/index.ts
|
|
1498
|
+
var import_datalayer3 = __toModule(require("@tinacms/datalayer"));
|
|
1499
|
+
var import_graphql10 = __toModule(require("@tinacms/graphql"));
|
|
1500
|
+
|
|
1501
|
+
// pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/cmds/start-server/lock.ts
|
|
1502
|
+
var AsyncLock = class {
|
|
1503
|
+
constructor() {
|
|
1504
|
+
this.disable = () => {
|
|
1505
|
+
};
|
|
1506
|
+
this.promise = Promise.resolve();
|
|
1534
1507
|
}
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
const _a = data, { _template, __typename } = _a, rest = __objRest(_a, ["_template", "__typename"]);
|
|
1538
|
-
const nested = transformParams(rest);
|
|
1539
|
-
return { [_template]: nested };
|
|
1540
|
-
} catch (e) {
|
|
1541
|
-
if (e.message === "Failed to assertShape - _template is a required field") {
|
|
1542
|
-
if (!data) {
|
|
1543
|
-
return void 0;
|
|
1544
|
-
return [];
|
|
1545
|
-
}
|
|
1546
|
-
const accum = {};
|
|
1547
|
-
Object.entries(data).map(([keyName, value]) => {
|
|
1548
|
-
accum[keyName] = transformParams(value);
|
|
1549
|
-
});
|
|
1550
|
-
return accum;
|
|
1551
|
-
} else {
|
|
1552
|
-
if (!data) {
|
|
1553
|
-
return void 0;
|
|
1554
|
-
return [];
|
|
1555
|
-
}
|
|
1556
|
-
throw e;
|
|
1557
|
-
}
|
|
1508
|
+
enable() {
|
|
1509
|
+
this.promise = new Promise((resolve2) => this.disable = resolve2);
|
|
1558
1510
|
}
|
|
1559
1511
|
};
|
|
1560
|
-
function filterObject(obj) {
|
|
1561
|
-
const ret = {};
|
|
1562
|
-
Object.keys(obj).filter((key) => obj[key] !== void 0).forEach((key) => ret[key] = obj[key]);
|
|
1563
|
-
return ret;
|
|
1564
|
-
}
|
|
1565
1512
|
|
|
1566
|
-
// pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/cmds/
|
|
1567
|
-
var import_chalk4 = __toModule(require("chalk"));
|
|
1568
|
-
var import_prompts2 = __toModule(require("prompts"));
|
|
1513
|
+
// pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/cmds/start-server/index.ts
|
|
1569
1514
|
var import_metrics3 = __toModule(require("@tinacms/metrics"));
|
|
1570
|
-
var
|
|
1571
|
-
var
|
|
1572
|
-
|
|
1573
|
-
|
|
1515
|
+
var import_chalk6 = __toModule(require("chalk"));
|
|
1516
|
+
var import_child_process = __toModule(require("child_process"));
|
|
1517
|
+
var import_chokidar = __toModule(require("chokidar"));
|
|
1518
|
+
var import_path6 = __toModule(require("path"));
|
|
1519
|
+
var lock = new AsyncLock();
|
|
1520
|
+
var gqlPackageFile = require.resolve("@tinacms/graphql");
|
|
1521
|
+
async function startServer(_ctx, _next, {
|
|
1522
|
+
port = 4001,
|
|
1523
|
+
command,
|
|
1524
|
+
noWatch,
|
|
1525
|
+
experimentalData,
|
|
1526
|
+
noSDK,
|
|
1527
|
+
noTelemetry,
|
|
1528
|
+
watchFolders,
|
|
1529
|
+
verbose
|
|
1530
|
+
}) {
|
|
1531
|
+
lock.disable();
|
|
1532
|
+
const rootPath2 = process.cwd();
|
|
1533
|
+
const t = new import_metrics3.Telemetry({ disabled: Boolean(noTelemetry) });
|
|
1534
|
+
t.submitRecord({
|
|
1574
1535
|
event: {
|
|
1575
|
-
name: "tinacms:cli:
|
|
1576
|
-
clean: Boolean(options.clean),
|
|
1577
|
-
useDefaults: Boolean(options.useDefaultValues)
|
|
1536
|
+
name: "tinacms:cli:server:start:invoke"
|
|
1578
1537
|
}
|
|
1579
1538
|
});
|
|
1580
|
-
if (
|
|
1581
|
-
|
|
1539
|
+
if (!process.env.CI && !noWatch) {
|
|
1540
|
+
await resetGeneratedFolder();
|
|
1541
|
+
}
|
|
1542
|
+
const bridge = new import_datalayer3.FilesystemBridge(rootPath2);
|
|
1543
|
+
const store = experimentalData ? new import_datalayer3.LevelStore(rootPath2) : new import_datalayer3.FilesystemStore({ rootPath: rootPath2 });
|
|
1544
|
+
const shouldBuild = bridge.supportsBuilding();
|
|
1545
|
+
const database = await (0, import_graphql10.createDatabase)({ store, bridge });
|
|
1546
|
+
const startSubprocess = () => {
|
|
1547
|
+
if (typeof command === "string") {
|
|
1548
|
+
const commands = command.split(" ");
|
|
1549
|
+
const firstCommand = commands[0];
|
|
1550
|
+
const args = commands.slice(1) || [];
|
|
1551
|
+
const ps = import_child_process.default.spawn(firstCommand, args, {
|
|
1552
|
+
stdio: "inherit",
|
|
1553
|
+
shell: true
|
|
1554
|
+
});
|
|
1555
|
+
ps.on("error", (code) => {
|
|
1556
|
+
logger.error(dangerText(`An error has occurred in the Next.js child process. Error message below`));
|
|
1557
|
+
logger.error(`name: ${code.name}
|
|
1558
|
+
message: ${code.message}
|
|
1582
1559
|
|
|
1583
|
-
`);
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1560
|
+
stack: ${code.stack || "No stack was provided"}`);
|
|
1561
|
+
});
|
|
1562
|
+
ps.on("close", (code) => {
|
|
1563
|
+
logger.info(`child process exited with code ${code}`);
|
|
1564
|
+
process.exit(code);
|
|
1565
|
+
});
|
|
1566
|
+
}
|
|
1567
|
+
};
|
|
1568
|
+
let ready = false;
|
|
1569
|
+
const build2 = async (noSDK2) => {
|
|
1570
|
+
await lock.promise;
|
|
1571
|
+
lock.enable();
|
|
1572
|
+
try {
|
|
1573
|
+
if (!process.env.CI && !noWatch) {
|
|
1574
|
+
await resetGeneratedFolder();
|
|
1575
|
+
}
|
|
1576
|
+
const database2 = await (0, import_graphql10.createDatabase)({ store, bridge });
|
|
1577
|
+
await compile(null, null, { verbose });
|
|
1578
|
+
const schema = await (0, import_graphql10.buildSchema)(rootPath2, database2);
|
|
1579
|
+
await genTypes({ schema }, () => {
|
|
1580
|
+
}, { noSDK: noSDK2, verbose });
|
|
1581
|
+
} catch (error) {
|
|
1582
|
+
throw error;
|
|
1583
|
+
} finally {
|
|
1584
|
+
lock.disable();
|
|
1585
|
+
}
|
|
1586
|
+
};
|
|
1587
|
+
const foldersToWatch = (watchFolders || []).map((x) => import_path6.default.join(rootPath2, x));
|
|
1588
|
+
if (!noWatch && !process.env.CI) {
|
|
1589
|
+
import_chokidar.default.watch([
|
|
1590
|
+
...foldersToWatch,
|
|
1591
|
+
`${rootPath2}/.tina/**/*.{ts,gql,graphql,js,tsx,jsx}`
|
|
1592
|
+
], {
|
|
1593
|
+
ignored: [
|
|
1594
|
+
"**/node_modules/**/*",
|
|
1595
|
+
"**/.next/**/*",
|
|
1596
|
+
`${import_path6.default.resolve(rootPath2)}/.tina/__generated__/**/*`
|
|
1597
|
+
]
|
|
1598
|
+
}).on("ready", async () => {
|
|
1599
|
+
if (verbose)
|
|
1600
|
+
console.log("Generating Tina config");
|
|
1601
|
+
try {
|
|
1602
|
+
if (shouldBuild) {
|
|
1603
|
+
await build2(noSDK);
|
|
1604
|
+
}
|
|
1605
|
+
ready = true;
|
|
1606
|
+
startSubprocess();
|
|
1607
|
+
} catch (e) {
|
|
1608
|
+
handleServerErrors(e);
|
|
1609
|
+
console.log(e);
|
|
1610
|
+
process.exit(0);
|
|
1611
|
+
}
|
|
1612
|
+
}).on("all", async () => {
|
|
1613
|
+
if (ready) {
|
|
1614
|
+
logger.info("Tina change detected, regenerating config");
|
|
1615
|
+
try {
|
|
1616
|
+
if (shouldBuild) {
|
|
1617
|
+
await build2(noSDK);
|
|
1618
|
+
}
|
|
1619
|
+
} catch (e) {
|
|
1620
|
+
handleServerErrors(e);
|
|
1621
|
+
t.submitRecord({
|
|
1622
|
+
event: {
|
|
1623
|
+
name: "tinacms:cli:server:error",
|
|
1624
|
+
errorMessage: e.message
|
|
1625
|
+
}
|
|
1626
|
+
});
|
|
1627
|
+
}
|
|
1628
|
+
}
|
|
1588
1629
|
});
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1630
|
+
} else {
|
|
1631
|
+
if (shouldBuild) {
|
|
1632
|
+
await build2(noSDK);
|
|
1592
1633
|
}
|
|
1593
1634
|
}
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
const
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1635
|
+
const state = {
|
|
1636
|
+
server: null,
|
|
1637
|
+
sockets: []
|
|
1638
|
+
};
|
|
1639
|
+
let isReady = false;
|
|
1640
|
+
const start = async () => {
|
|
1641
|
+
const s = (init_server(), server_exports);
|
|
1642
|
+
state.server = await s.default(database);
|
|
1643
|
+
state.server.listen(port, () => {
|
|
1644
|
+
const altairUrl = `http://localhost:${port}/altair/`;
|
|
1645
|
+
const cmsUrl = `[your-development-url]/admin`;
|
|
1646
|
+
if (verbose)
|
|
1647
|
+
logger.info(`Started Filesystem GraphQL server on port: ${port}`);
|
|
1648
|
+
logger.info(`Visit the GraphQL playground at ${import_chalk6.default.underline.blueBright(altairUrl)}
|
|
1649
|
+
or`);
|
|
1650
|
+
logger.info(`Enter the CMS at ${import_chalk6.default.underline.blueBright(cmsUrl)}
|
|
1651
|
+
`);
|
|
1611
1652
|
});
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1653
|
+
state.server.on("error", function(e) {
|
|
1654
|
+
if (e.code === "EADDRINUSE") {
|
|
1655
|
+
logger.error(dangerText(`Port 4001 already in use`));
|
|
1656
|
+
process.exit();
|
|
1657
|
+
}
|
|
1658
|
+
throw e;
|
|
1659
|
+
});
|
|
1660
|
+
state.server.on("connection", (socket) => {
|
|
1661
|
+
state.sockets.push(socket);
|
|
1662
|
+
});
|
|
1663
|
+
};
|
|
1664
|
+
const restart = async () => {
|
|
1665
|
+
logger.info("Detected change to gql package, restarting...");
|
|
1666
|
+
delete require.cache[gqlPackageFile];
|
|
1667
|
+
state.sockets.forEach((socket) => {
|
|
1668
|
+
if (socket.destroyed === false) {
|
|
1669
|
+
socket.destroy();
|
|
1670
|
+
}
|
|
1671
|
+
});
|
|
1672
|
+
state.sockets = [];
|
|
1673
|
+
state.server.close(() => {
|
|
1674
|
+
logger.info("Server closed");
|
|
1675
|
+
start();
|
|
1676
|
+
});
|
|
1677
|
+
};
|
|
1678
|
+
if (!noWatch && !process.env.CI) {
|
|
1679
|
+
import_chokidar.default.watch([gqlPackageFile]).on("ready", async () => {
|
|
1680
|
+
isReady = true;
|
|
1681
|
+
start();
|
|
1682
|
+
}).on("all", async () => {
|
|
1683
|
+
if (isReady) {
|
|
1684
|
+
restart();
|
|
1685
|
+
}
|
|
1617
1686
|
});
|
|
1618
|
-
warning = warning || returnWarning;
|
|
1619
|
-
error = error || returnError;
|
|
1620
|
-
}
|
|
1621
|
-
ctx.warning = warning;
|
|
1622
|
-
ctx.error = error;
|
|
1623
|
-
next();
|
|
1624
|
-
};
|
|
1625
|
-
var printFinalMessage = async (ctx, next, _options) => {
|
|
1626
|
-
if (ctx.error) {
|
|
1627
|
-
logger.error(import_chalk4.default.redBright(`\u203C\uFE0F Audit ${import_chalk4.default.bold("failed")} with errors`));
|
|
1628
|
-
} else if (ctx.warning) {
|
|
1629
|
-
logger.warn(import_chalk4.default.yellowBright("\u26A0\uFE0F Audit passed with warnings"));
|
|
1630
1687
|
} else {
|
|
1631
|
-
|
|
1688
|
+
if (process.env.CI) {
|
|
1689
|
+
logger.info("Detected CI environment, omitting watch commands...");
|
|
1690
|
+
}
|
|
1691
|
+
start();
|
|
1692
|
+
startSubprocess();
|
|
1632
1693
|
}
|
|
1633
|
-
|
|
1634
|
-
};
|
|
1694
|
+
}
|
|
1635
1695
|
|
|
1636
1696
|
// pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/cmds/baseCmds.ts
|
|
1637
|
-
var import_chalk5 = __toModule(require("chalk"));
|
|
1638
1697
|
var CMD_GEN_TYPES = "schema:types";
|
|
1639
1698
|
var CMD_START_SERVER = "server:start";
|
|
1640
1699
|
var CMD_COMPILE_MODELS = "schema:compile";
|
|
@@ -1648,6 +1707,10 @@ var experimentalDatalayer = {
|
|
|
1648
1707
|
name: "--experimentalData",
|
|
1649
1708
|
description: "Build the server with additional data querying capabilities"
|
|
1650
1709
|
};
|
|
1710
|
+
var schemaFileType = {
|
|
1711
|
+
name: "--schemaFileType [fileType]",
|
|
1712
|
+
description: "The file type to use for the Tina schema"
|
|
1713
|
+
};
|
|
1651
1714
|
var subCommand = {
|
|
1652
1715
|
name: "-c, --command <command>",
|
|
1653
1716
|
description: "The sub-command to run"
|
|
@@ -1676,6 +1739,10 @@ var watchFileOption = {
|
|
|
1676
1739
|
name: "-w, --watchFolders [folders...]",
|
|
1677
1740
|
description: "a list of folders (relative to where this is being run) that the cli will watch for changes"
|
|
1678
1741
|
};
|
|
1742
|
+
var verboseOption = {
|
|
1743
|
+
name: "-v, --verbose",
|
|
1744
|
+
description: "increase verbosity of logged output"
|
|
1745
|
+
};
|
|
1679
1746
|
var baseCmds = [
|
|
1680
1747
|
{
|
|
1681
1748
|
command: CMD_START_SERVER,
|
|
@@ -1687,7 +1754,8 @@ var baseCmds = [
|
|
|
1687
1754
|
noWatchOption,
|
|
1688
1755
|
noSDKCodegenOption,
|
|
1689
1756
|
noTelemetryOption,
|
|
1690
|
-
watchFileOption
|
|
1757
|
+
watchFileOption,
|
|
1758
|
+
verboseOption
|
|
1691
1759
|
],
|
|
1692
1760
|
action: (options) => chain([startServer], options)
|
|
1693
1761
|
},
|
|
@@ -1705,14 +1773,14 @@ var baseCmds = [
|
|
|
1705
1773
|
},
|
|
1706
1774
|
{
|
|
1707
1775
|
command: INIT,
|
|
1708
|
-
options: [experimentalDatalayer, noTelemetryOption],
|
|
1776
|
+
options: [experimentalDatalayer, noTelemetryOption, schemaFileType],
|
|
1709
1777
|
description: "Add Tina Cloud to an existing project",
|
|
1710
1778
|
action: (options) => chain([
|
|
1711
1779
|
checkDeps,
|
|
1712
1780
|
initTina,
|
|
1713
1781
|
installDeps,
|
|
1714
|
-
async (_ctx, next) => {
|
|
1715
|
-
await compile(_ctx, next);
|
|
1782
|
+
async (_ctx, next, options2) => {
|
|
1783
|
+
await compile(_ctx, next, options2);
|
|
1716
1784
|
next();
|
|
1717
1785
|
},
|
|
1718
1786
|
attachSchema,
|
|
@@ -1731,14 +1799,14 @@ var baseCmds = [
|
|
|
1731
1799
|
next();
|
|
1732
1800
|
},
|
|
1733
1801
|
async (_ctx, next) => {
|
|
1734
|
-
await compile(_ctx, next);
|
|
1802
|
+
await compile(_ctx, next, options);
|
|
1735
1803
|
next();
|
|
1736
1804
|
},
|
|
1737
1805
|
attachSchema,
|
|
1738
1806
|
genTypes,
|
|
1739
1807
|
async (_ctx, next) => {
|
|
1740
1808
|
logger.level = "info";
|
|
1741
|
-
logger.info(
|
|
1809
|
+
logger.info(import_chalk7.default.hex("#eb6337").bgWhite("Welcome to tina audit \u{1F999}"));
|
|
1742
1810
|
next();
|
|
1743
1811
|
},
|
|
1744
1812
|
audit,
|