@tinacms/cli 1.3.1 → 1.3.2
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/index.js +773 -484
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -1,58 +1,29 @@
|
|
|
1
1
|
var __create = Object.create;
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
|
-
var __defProps = Object.defineProperties;
|
|
4
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
6
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
8
5
|
var __getProtoOf = Object.getPrototypeOf;
|
|
9
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
11
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
12
|
-
var __spreadValues = (a, b) => {
|
|
13
|
-
for (var prop in b || (b = {}))
|
|
14
|
-
if (__hasOwnProp.call(b, prop))
|
|
15
|
-
__defNormalProp(a, prop, b[prop]);
|
|
16
|
-
if (__getOwnPropSymbols)
|
|
17
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
18
|
-
if (__propIsEnum.call(b, prop))
|
|
19
|
-
__defNormalProp(a, prop, b[prop]);
|
|
20
|
-
}
|
|
21
|
-
return a;
|
|
22
|
-
};
|
|
23
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
24
|
-
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
25
|
-
var __objRest = (source, exclude) => {
|
|
26
|
-
var target = {};
|
|
27
|
-
for (var prop in source)
|
|
28
|
-
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
29
|
-
target[prop] = source[prop];
|
|
30
|
-
if (source != null && __getOwnPropSymbols)
|
|
31
|
-
for (var prop of __getOwnPropSymbols(source)) {
|
|
32
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
33
|
-
target[prop] = source[prop];
|
|
34
|
-
}
|
|
35
|
-
return target;
|
|
36
|
-
};
|
|
37
7
|
var __esm = (fn, res) => function __init() {
|
|
38
|
-
return fn && (res = (0, fn[
|
|
8
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
39
9
|
};
|
|
40
10
|
var __export = (target, all) => {
|
|
41
|
-
__markAsModule(target);
|
|
42
11
|
for (var name2 in all)
|
|
43
12
|
__defProp(target, name2, { get: all[name2], enumerable: true });
|
|
44
13
|
};
|
|
45
|
-
var
|
|
46
|
-
if (
|
|
47
|
-
for (let key of __getOwnPropNames(
|
|
48
|
-
if (!__hasOwnProp.call(
|
|
49
|
-
__defProp(
|
|
14
|
+
var __copyProps = (to, from, except, desc) => {
|
|
15
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
16
|
+
for (let key of __getOwnPropNames(from))
|
|
17
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
18
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
50
19
|
}
|
|
51
|
-
return
|
|
52
|
-
};
|
|
53
|
-
var __toModule = (module2) => {
|
|
54
|
-
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", module2 && module2.__esModule && "default" in module2 ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
|
|
20
|
+
return to;
|
|
55
21
|
};
|
|
22
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
23
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
24
|
+
mod
|
|
25
|
+
));
|
|
26
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
56
27
|
|
|
57
28
|
// src/utils/index.ts
|
|
58
29
|
var parseMediaFolder;
|
|
@@ -70,11 +41,11 @@ var init_utils = __esm({
|
|
|
70
41
|
});
|
|
71
42
|
|
|
72
43
|
// src/server/models/media.ts
|
|
73
|
-
var import_fs_extra6,
|
|
44
|
+
var import_fs_extra6, import_path6, MediaModel;
|
|
74
45
|
var init_media = __esm({
|
|
75
46
|
"src/server/models/media.ts"() {
|
|
76
|
-
import_fs_extra6 =
|
|
77
|
-
|
|
47
|
+
import_fs_extra6 = __toESM(require("fs-extra"));
|
|
48
|
+
import_path6 = require("path");
|
|
78
49
|
init_utils();
|
|
79
50
|
MediaModel = class {
|
|
80
51
|
constructor({ rootPath: rootPath2, publicFolder, mediaRoot }) {
|
|
@@ -84,11 +55,16 @@ var init_media = __esm({
|
|
|
84
55
|
}
|
|
85
56
|
async listMedia(args) {
|
|
86
57
|
try {
|
|
87
|
-
const folderPath = (0,
|
|
58
|
+
const folderPath = (0, import_path6.join)(
|
|
59
|
+
this.rootPath,
|
|
60
|
+
this.publicFolder,
|
|
61
|
+
this.mediaRoot,
|
|
62
|
+
args.searchPath
|
|
63
|
+
);
|
|
88
64
|
const searchPath = parseMediaFolder(args.searchPath);
|
|
89
65
|
const filesStr = await import_fs_extra6.default.readdir(folderPath);
|
|
90
66
|
const filesProm = filesStr.map(async (file) => {
|
|
91
|
-
const filePath = (0,
|
|
67
|
+
const filePath = (0, import_path6.join)(folderPath, file);
|
|
92
68
|
const stat = await import_fs_extra6.default.stat(filePath);
|
|
93
69
|
let src = `/${file}`;
|
|
94
70
|
const isFile = stat.isFile();
|
|
@@ -145,7 +121,12 @@ var init_media = __esm({
|
|
|
145
121
|
}
|
|
146
122
|
async deleteMedia(args) {
|
|
147
123
|
try {
|
|
148
|
-
const file = (0,
|
|
124
|
+
const file = (0, import_path6.join)(
|
|
125
|
+
this.rootPath,
|
|
126
|
+
this.publicFolder,
|
|
127
|
+
this.mediaRoot,
|
|
128
|
+
args.searchPath
|
|
129
|
+
);
|
|
149
130
|
await import_fs_extra6.default.stat(file);
|
|
150
131
|
await import_fs_extra6.default.remove(file);
|
|
151
132
|
return { ok: true };
|
|
@@ -159,15 +140,19 @@ var init_media = __esm({
|
|
|
159
140
|
});
|
|
160
141
|
|
|
161
142
|
// src/server/routes/index.ts
|
|
162
|
-
var import_express,
|
|
143
|
+
var import_express, import_path7, import_multer, createMediaRouter;
|
|
163
144
|
var init_routes = __esm({
|
|
164
145
|
"src/server/routes/index.ts"() {
|
|
165
|
-
import_express =
|
|
166
|
-
|
|
167
|
-
import_multer =
|
|
146
|
+
import_express = require("express");
|
|
147
|
+
import_path7 = require("path");
|
|
148
|
+
import_multer = __toESM(require("multer"));
|
|
168
149
|
init_media();
|
|
169
150
|
createMediaRouter = (config2) => {
|
|
170
|
-
const mediaFolder = (0,
|
|
151
|
+
const mediaFolder = (0, import_path7.join)(
|
|
152
|
+
config2.rootPath,
|
|
153
|
+
config2.publicFolder,
|
|
154
|
+
config2.mediaRoot
|
|
155
|
+
);
|
|
171
156
|
const storage = import_multer.default.diskStorage({
|
|
172
157
|
destination: function(req, file, cb) {
|
|
173
158
|
cb(null, mediaFolder);
|
|
@@ -217,11 +202,11 @@ var init_routes = __esm({
|
|
|
217
202
|
var import_cors, import_http, import_express2, import_altair_express_middleware, import_body_parser, gqlServer;
|
|
218
203
|
var init_server = __esm({
|
|
219
204
|
"src/server/server.ts"() {
|
|
220
|
-
import_cors =
|
|
221
|
-
import_http =
|
|
222
|
-
import_express2 =
|
|
223
|
-
import_altair_express_middleware =
|
|
224
|
-
import_body_parser =
|
|
205
|
+
import_cors = __toESM(require("cors"));
|
|
206
|
+
import_http = __toESM(require("http"));
|
|
207
|
+
import_express2 = __toESM(require("express"));
|
|
208
|
+
import_altair_express_middleware = require("altair-express-middleware");
|
|
209
|
+
import_body_parser = __toESM(require("body-parser"));
|
|
225
210
|
init_routes();
|
|
226
211
|
init_utils();
|
|
227
212
|
gqlServer = async (database, verbose) => {
|
|
@@ -231,9 +216,11 @@ var init_server = __esm({
|
|
|
231
216
|
const server = import_http.default.createServer(app);
|
|
232
217
|
app.use((0, import_cors.default)());
|
|
233
218
|
app.use(import_body_parser.default.json());
|
|
234
|
-
app.use(
|
|
235
|
-
|
|
236
|
-
|
|
219
|
+
app.use(
|
|
220
|
+
"/altair",
|
|
221
|
+
(0, import_altair_express_middleware.altairExpress)({
|
|
222
|
+
endpointURL: "/graphql",
|
|
223
|
+
initialQuery: `# Welcome to Tina!
|
|
237
224
|
# We've got a simple query set up for you to get started
|
|
238
225
|
# but there's plenty more for you to explore on your own!
|
|
239
226
|
query MyQuery {
|
|
@@ -247,7 +234,8 @@ var init_server = __esm({
|
|
|
247
234
|
}
|
|
248
235
|
}
|
|
249
236
|
}`
|
|
250
|
-
|
|
237
|
+
})
|
|
238
|
+
);
|
|
251
239
|
app.post("/graphql", async (req, res) => {
|
|
252
240
|
const { query, variables } = req.body;
|
|
253
241
|
const config2 = {
|
|
@@ -265,11 +253,14 @@ var init_server = __esm({
|
|
|
265
253
|
const db = database;
|
|
266
254
|
const schema = await db.getSchema();
|
|
267
255
|
const mediaPaths = (_c = (_b = (_a = schema == null ? void 0 : schema.schema) == null ? void 0 : _a.config) == null ? void 0 : _b.media) == null ? void 0 : _c.tina;
|
|
268
|
-
app.use(
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
256
|
+
app.use(
|
|
257
|
+
"/media",
|
|
258
|
+
createMediaRouter({
|
|
259
|
+
rootPath: db.bridge.rootPath,
|
|
260
|
+
publicFolder: parseMediaFolder((mediaPaths == null ? void 0 : mediaPaths.publicFolder) || ""),
|
|
261
|
+
mediaRoot: parseMediaFolder((mediaPaths == null ? void 0 : mediaPaths.mediaRoot) || "")
|
|
262
|
+
})
|
|
263
|
+
);
|
|
273
264
|
return server;
|
|
274
265
|
};
|
|
275
266
|
}
|
|
@@ -296,22 +287,23 @@ var init_server3 = __esm({
|
|
|
296
287
|
});
|
|
297
288
|
|
|
298
289
|
// src/index.ts
|
|
299
|
-
|
|
290
|
+
var src_exports = {};
|
|
291
|
+
__export(src_exports, {
|
|
300
292
|
defineSchema: () => defineSchema,
|
|
301
293
|
init: () => init
|
|
302
294
|
});
|
|
303
|
-
|
|
295
|
+
module.exports = __toCommonJS(src_exports);
|
|
296
|
+
var commander = __toESM(require("commander"));
|
|
304
297
|
|
|
305
298
|
// package.json
|
|
306
299
|
var name = "@tinacms/cli";
|
|
307
|
-
var version = "1.3.
|
|
300
|
+
var version = "1.3.2";
|
|
308
301
|
|
|
309
302
|
// src/cmds/audit/audit.ts
|
|
310
|
-
var import_graphql =
|
|
311
|
-
var import_path = __toModule(require("path"));
|
|
303
|
+
var import_graphql = require("@tinacms/graphql");
|
|
312
304
|
|
|
313
305
|
// src/logger/index.ts
|
|
314
|
-
var import_log4js =
|
|
306
|
+
var import_log4js = __toESM(require("log4js"));
|
|
315
307
|
var logger = import_log4js.default.getLogger();
|
|
316
308
|
import_log4js.default.configure({
|
|
317
309
|
appenders: {
|
|
@@ -322,8 +314,8 @@ import_log4js.default.configure({
|
|
|
322
314
|
logger.level = "info";
|
|
323
315
|
|
|
324
316
|
// src/cmds/audit/audit.ts
|
|
325
|
-
var import_graphql2 =
|
|
326
|
-
var import_chalk =
|
|
317
|
+
var import_graphql2 = require("@tinacms/graphql");
|
|
318
|
+
var import_chalk = __toESM(require("chalk"));
|
|
327
319
|
var auditDocuments = async (args) => {
|
|
328
320
|
const { collection, database, useDefaultValues, documents } = args;
|
|
329
321
|
let error = false;
|
|
@@ -351,7 +343,9 @@ var auditDocuments = async (args) => {
|
|
|
351
343
|
docResult.errors.forEach((err) => {
|
|
352
344
|
logger.error(import_chalk.default.red(err.message));
|
|
353
345
|
if (err.originalError.originalError) {
|
|
354
|
-
logger.error(
|
|
346
|
+
logger.error(
|
|
347
|
+
import_chalk.default.red(` ${err.originalError.originalError.message}`)
|
|
348
|
+
);
|
|
355
349
|
}
|
|
356
350
|
});
|
|
357
351
|
} else {
|
|
@@ -364,10 +358,14 @@ var auditDocuments = async (args) => {
|
|
|
364
358
|
}
|
|
365
359
|
});
|
|
366
360
|
}
|
|
367
|
-
const params = transformDocumentIntoMutationRequestPayload(
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
361
|
+
const params = transformDocumentIntoMutationRequestPayload(
|
|
362
|
+
docResult.data.document._values,
|
|
363
|
+
{
|
|
364
|
+
includeCollection: true,
|
|
365
|
+
includeTemplate: typeof collection.templates !== "undefined"
|
|
366
|
+
},
|
|
367
|
+
topLevelDefaults
|
|
368
|
+
);
|
|
371
369
|
const mutation = `mutation($collection: String!, $relativePath: String!, $params: DocumentUpdateMutation!) {
|
|
372
370
|
updateDocument(
|
|
373
371
|
collection: $collection,
|
|
@@ -398,10 +396,10 @@ var auditDocuments = async (args) => {
|
|
|
398
396
|
return error;
|
|
399
397
|
};
|
|
400
398
|
var transformDocumentIntoMutationRequestPayload = (document, instructions, defaults) => {
|
|
401
|
-
const
|
|
399
|
+
const { _collection, __typename, _template, ...rest } = document;
|
|
402
400
|
const params = transformParams(rest);
|
|
403
401
|
const paramsWithTemplate = instructions.includeTemplate ? { [_template]: params } : params;
|
|
404
|
-
return instructions.includeCollection ? { [_collection]:
|
|
402
|
+
return instructions.includeCollection ? { [_collection]: { ...defaults, ...filterObject(paramsWithTemplate) } } : { ...defaults, ...filterObject(paramsWithTemplate) };
|
|
405
403
|
};
|
|
406
404
|
var transformParams = (data) => {
|
|
407
405
|
if (["string", "number", "boolean"].includes(typeof data)) {
|
|
@@ -411,8 +409,11 @@ var transformParams = (data) => {
|
|
|
411
409
|
return data.map((item) => transformParams(item));
|
|
412
410
|
}
|
|
413
411
|
try {
|
|
414
|
-
(0, import_graphql2.assertShape)(
|
|
415
|
-
|
|
412
|
+
(0, import_graphql2.assertShape)(
|
|
413
|
+
data,
|
|
414
|
+
(yup) => yup.object({ _template: yup.string().required() })
|
|
415
|
+
);
|
|
416
|
+
const { _template, __typename, ...rest } = data;
|
|
416
417
|
const nested = transformParams(rest);
|
|
417
418
|
return { [_template]: nested };
|
|
418
419
|
} catch (e) {
|
|
@@ -442,12 +443,12 @@ function filterObject(obj) {
|
|
|
442
443
|
}
|
|
443
444
|
|
|
444
445
|
// src/cmds/audit/index.ts
|
|
445
|
-
var import_chalk3 =
|
|
446
|
-
var import_prompts =
|
|
447
|
-
var import_metrics =
|
|
446
|
+
var import_chalk3 = __toESM(require("chalk"));
|
|
447
|
+
var import_prompts = __toESM(require("prompts"));
|
|
448
|
+
var import_metrics = require("@tinacms/metrics");
|
|
448
449
|
|
|
449
450
|
// src/utils/theme.ts
|
|
450
|
-
var import_chalk2 =
|
|
451
|
+
var import_chalk2 = __toESM(require("chalk"));
|
|
451
452
|
var successText = import_chalk2.default.bold.green;
|
|
452
453
|
var focusText = import_chalk2.default.bold;
|
|
453
454
|
var dangerText = import_chalk2.default.bold.red;
|
|
@@ -475,9 +476,13 @@ var audit = async (ctx, next, options) => {
|
|
|
475
476
|
}
|
|
476
477
|
});
|
|
477
478
|
if (options.clean) {
|
|
478
|
-
logger.info(
|
|
479
|
+
logger.info(
|
|
480
|
+
`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(
|
|
481
|
+
"clean git tree"
|
|
482
|
+
)} so unwanted changes can be undone.
|
|
479
483
|
|
|
480
|
-
`
|
|
484
|
+
`
|
|
485
|
+
);
|
|
481
486
|
const res = await (0, import_prompts.default)({
|
|
482
487
|
name: "useClean",
|
|
483
488
|
type: "confirm",
|
|
@@ -489,7 +494,11 @@ var audit = async (ctx, next, options) => {
|
|
|
489
494
|
}
|
|
490
495
|
}
|
|
491
496
|
if (options.useDefaultValues && !options.clean) {
|
|
492
|
-
logger.warn(
|
|
497
|
+
logger.warn(
|
|
498
|
+
import_chalk3.default.yellowBright(
|
|
499
|
+
"WARNING: using the `--useDefaultValues` without the `--clean` flag has no effect. Please re-run audit and add the `--clean` flag"
|
|
500
|
+
)
|
|
501
|
+
);
|
|
493
502
|
}
|
|
494
503
|
const database = ctx.database;
|
|
495
504
|
const schema = await database.getSchema();
|
|
@@ -497,8 +506,13 @@ var audit = async (ctx, next, options) => {
|
|
|
497
506
|
let error = false;
|
|
498
507
|
for (let i = 0; i < collections.length; i++) {
|
|
499
508
|
const collection = collections[i];
|
|
500
|
-
const docs = await database.query(
|
|
501
|
-
|
|
509
|
+
const docs = await database.query(
|
|
510
|
+
{ collection: collection.name, first: -1, filterChain: [] },
|
|
511
|
+
(item) => ({ path: item })
|
|
512
|
+
);
|
|
513
|
+
logger.info(
|
|
514
|
+
`Checking ${neutralText(collection.name)} collection. ${docs.edges.length} Documents`
|
|
515
|
+
);
|
|
502
516
|
const returnError = await auditDocuments({
|
|
503
517
|
collection,
|
|
504
518
|
database,
|
|
@@ -514,7 +528,9 @@ var audit = async (ctx, next, options) => {
|
|
|
514
528
|
};
|
|
515
529
|
var printFinalMessage = async (ctx, next, _options) => {
|
|
516
530
|
if (ctx.error) {
|
|
517
|
-
logger.error(
|
|
531
|
+
logger.error(
|
|
532
|
+
import_chalk3.default.redBright(`\u203C\uFE0F Audit ${import_chalk3.default.bold("failed")} with errors`)
|
|
533
|
+
);
|
|
518
534
|
} else if (ctx.warning) {
|
|
519
535
|
logger.warn(import_chalk3.default.yellowBright("\u26A0\uFE0F Audit passed with warnings"));
|
|
520
536
|
} else {
|
|
@@ -524,7 +540,7 @@ var printFinalMessage = async (ctx, next, _options) => {
|
|
|
524
540
|
};
|
|
525
541
|
|
|
526
542
|
// src/cmds/baseCmds.ts
|
|
527
|
-
var import_config2 =
|
|
543
|
+
var import_config2 = require("dotenv/config");
|
|
528
544
|
|
|
529
545
|
// src/middleware.ts
|
|
530
546
|
var chain = async (cmds, options) => {
|
|
@@ -534,7 +550,11 @@ var chain = async (cmds, options) => {
|
|
|
534
550
|
process.exit(0);
|
|
535
551
|
}
|
|
536
552
|
try {
|
|
537
|
-
await cmds[middlewareIndex](
|
|
553
|
+
await cmds[middlewareIndex](
|
|
554
|
+
ctx,
|
|
555
|
+
() => next(middlewareIndex + 1),
|
|
556
|
+
options || {}
|
|
557
|
+
);
|
|
538
558
|
} catch (err) {
|
|
539
559
|
console.error(` ${dangerText(err)}`);
|
|
540
560
|
if (err.stack) {
|
|
@@ -549,12 +569,12 @@ var chain = async (cmds, options) => {
|
|
|
549
569
|
};
|
|
550
570
|
|
|
551
571
|
// src/cmds/baseCmds.ts
|
|
552
|
-
var import_chalk4 =
|
|
572
|
+
var import_chalk4 = __toESM(require("chalk"));
|
|
553
573
|
|
|
554
574
|
// src/cmds/start-server/index.ts
|
|
555
|
-
var
|
|
556
|
-
var import_chokidar =
|
|
557
|
-
var import_metrics2 =
|
|
575
|
+
var import_path8 = __toESM(require("path"));
|
|
576
|
+
var import_chokidar = __toESM(require("chokidar"));
|
|
577
|
+
var import_metrics2 = require("@tinacms/metrics");
|
|
558
578
|
|
|
559
579
|
// src/cmds/start-server/lock.ts
|
|
560
580
|
var AsyncLock = class {
|
|
@@ -569,7 +589,7 @@ var AsyncLock = class {
|
|
|
569
589
|
};
|
|
570
590
|
|
|
571
591
|
// src/cmds/start-server/errors/index.ts
|
|
572
|
-
var import_graphql3 =
|
|
592
|
+
var import_graphql3 = require("@tinacms/graphql");
|
|
573
593
|
var BuildSchemaError = class extends Error {
|
|
574
594
|
constructor(message) {
|
|
575
595
|
super(message);
|
|
@@ -584,41 +604,51 @@ var ExecuteSchemaError = class extends Error {
|
|
|
584
604
|
};
|
|
585
605
|
var handleServerErrors = (e) => {
|
|
586
606
|
if (e.name === "BuildSchemaError") {
|
|
587
|
-
logger.error(`${dangerText(
|
|
607
|
+
logger.error(`${dangerText(
|
|
608
|
+
"ERROR: your schema was not successfully built: see https://tina.io/docs/errors/esbuild-error/ for more details"
|
|
609
|
+
)}
|
|
588
610
|
Error Message Below
|
|
589
611
|
${e}`);
|
|
590
612
|
} else if (e.name === "ExecuteSchemaError") {
|
|
591
|
-
logger.error(`${dangerText(
|
|
613
|
+
logger.error(`${dangerText(
|
|
614
|
+
"ERROR: your schema was not successfully executed: see https://tina.io/docs/errors/esbuild-error/ for more details"
|
|
615
|
+
)}
|
|
592
616
|
Error Message Below
|
|
593
617
|
${e}`);
|
|
594
618
|
} else if (e.name === "TinaSchemaValidationError") {
|
|
595
|
-
logger.error(`${dangerText(
|
|
619
|
+
logger.error(`${dangerText(
|
|
620
|
+
"ERROR: your schema was not successfully validated: see https://tina.io/docs/schema/ for instructions on how to setup a schema"
|
|
621
|
+
)}
|
|
596
622
|
Error Message Below
|
|
597
623
|
${e}`);
|
|
598
624
|
} else if (e instanceof import_graphql3.TinaFetchError) {
|
|
599
625
|
(0, import_graphql3.handleFetchErrorError)(e, true);
|
|
600
626
|
} else {
|
|
601
|
-
logger.info(
|
|
602
|
-
|
|
627
|
+
logger.info(
|
|
628
|
+
dangerText(
|
|
629
|
+
"Compilation failed with errors. Server has not been restarted."
|
|
630
|
+
) + ` see error below
|
|
631
|
+
${e.message}`
|
|
632
|
+
);
|
|
603
633
|
}
|
|
604
634
|
};
|
|
605
635
|
|
|
606
636
|
// src/buildTina/index.ts
|
|
607
|
-
var import_fs_extra5 =
|
|
608
|
-
var import_graphql9 =
|
|
609
|
-
var import_datalayer =
|
|
610
|
-
var import_memory_level =
|
|
611
|
-
var
|
|
637
|
+
var import_fs_extra5 = __toESM(require("fs-extra"));
|
|
638
|
+
var import_graphql9 = require("@tinacms/graphql");
|
|
639
|
+
var import_datalayer = require("@tinacms/datalayer");
|
|
640
|
+
var import_memory_level = require("memory-level");
|
|
641
|
+
var import_path5 = __toESM(require("path"));
|
|
612
642
|
|
|
613
643
|
// src/cmds/compile/index.ts
|
|
614
|
-
var _ =
|
|
615
|
-
var import_fs_extra2 =
|
|
616
|
-
var
|
|
617
|
-
var import_esbuild =
|
|
644
|
+
var _ = __toESM(require("lodash"));
|
|
645
|
+
var import_fs_extra2 = __toESM(require("fs-extra"));
|
|
646
|
+
var import_path2 = __toESM(require("path"));
|
|
647
|
+
var import_esbuild = require("esbuild");
|
|
618
648
|
|
|
619
649
|
// src/lib/getPath.ts
|
|
620
|
-
var
|
|
621
|
-
var import_fs_extra =
|
|
650
|
+
var import_path = __toESM(require("path"));
|
|
651
|
+
var import_fs_extra = __toESM(require("fs-extra"));
|
|
622
652
|
var fileExists = ({
|
|
623
653
|
projectDir,
|
|
624
654
|
filename,
|
|
@@ -627,11 +657,13 @@ var fileExists = ({
|
|
|
627
657
|
if (!import_fs_extra.default.existsSync(projectDir)) {
|
|
628
658
|
return false;
|
|
629
659
|
}
|
|
630
|
-
const filePaths = allowedTypes.map(
|
|
660
|
+
const filePaths = allowedTypes.map(
|
|
661
|
+
(ext) => import_path.default.join(projectDir, `${filename}.${ext}`)
|
|
662
|
+
);
|
|
631
663
|
let inputFile = void 0;
|
|
632
|
-
filePaths.every((
|
|
633
|
-
if (import_fs_extra.default.existsSync(
|
|
634
|
-
inputFile =
|
|
664
|
+
filePaths.every((path11) => {
|
|
665
|
+
if (import_fs_extra.default.existsSync(path11)) {
|
|
666
|
+
inputFile = path11;
|
|
635
667
|
return false;
|
|
636
668
|
}
|
|
637
669
|
return true;
|
|
@@ -651,11 +683,13 @@ var getPath = ({
|
|
|
651
683
|
throw new Error(`Could not find ${projectDir}`);
|
|
652
684
|
}
|
|
653
685
|
}
|
|
654
|
-
const filePaths = allowedTypes.map(
|
|
686
|
+
const filePaths = allowedTypes.map(
|
|
687
|
+
(ext) => import_path.default.join(projectDir, `${filename}.${ext}`)
|
|
688
|
+
);
|
|
655
689
|
let inputFile = void 0;
|
|
656
|
-
filePaths.every((
|
|
657
|
-
if (import_fs_extra.default.existsSync(
|
|
658
|
-
inputFile =
|
|
690
|
+
filePaths.every((path11) => {
|
|
691
|
+
if (import_fs_extra.default.existsSync(path11)) {
|
|
692
|
+
inputFile = path11;
|
|
659
693
|
return false;
|
|
660
694
|
}
|
|
661
695
|
return true;
|
|
@@ -689,11 +723,11 @@ var resetGeneratedFolder = async ({
|
|
|
689
723
|
const file = generatedFilesToRemove[index];
|
|
690
724
|
if (file === "db") {
|
|
691
725
|
try {
|
|
692
|
-
await import_fs_extra2.default.remove(
|
|
726
|
+
await import_fs_extra2.default.remove(import_path2.default.join(tinaGeneratedPath, file));
|
|
693
727
|
} catch (_e) {
|
|
694
728
|
}
|
|
695
729
|
} else {
|
|
696
|
-
await import_fs_extra2.default.remove(
|
|
730
|
+
await import_fs_extra2.default.remove(import_path2.default.join(tinaGeneratedPath, file));
|
|
697
731
|
}
|
|
698
732
|
}
|
|
699
733
|
}
|
|
@@ -702,18 +736,26 @@ var resetGeneratedFolder = async ({
|
|
|
702
736
|
}
|
|
703
737
|
await import_fs_extra2.default.mkdirp(tinaGeneratedPath);
|
|
704
738
|
const ext = usingTs ? "ts" : "js";
|
|
705
|
-
if (!await import_fs_extra2.default.pathExists(
|
|
706
|
-
await import_fs_extra2.default.writeFile(
|
|
739
|
+
if (!await import_fs_extra2.default.pathExists(import_path2.default.join(tinaGeneratedPath, `types.${ext}`))) {
|
|
740
|
+
await import_fs_extra2.default.writeFile(
|
|
741
|
+
import_path2.default.join(tinaGeneratedPath, `types.${ext}`),
|
|
742
|
+
`
|
|
707
743
|
export const queries = (client)=>({})
|
|
708
|
-
`
|
|
744
|
+
`
|
|
745
|
+
);
|
|
709
746
|
}
|
|
710
|
-
if (!await import_fs_extra2.default.pathExists(
|
|
711
|
-
await import_fs_extra2.default.writeFile(
|
|
747
|
+
if (!await import_fs_extra2.default.pathExists(import_path2.default.join(tinaGeneratedPath, `client.${ext}`))) {
|
|
748
|
+
await import_fs_extra2.default.writeFile(
|
|
749
|
+
import_path2.default.join(tinaGeneratedPath, `client.${ext}`),
|
|
750
|
+
`
|
|
712
751
|
export const client = ()=>{}
|
|
713
752
|
export default client
|
|
714
|
-
`
|
|
753
|
+
`
|
|
754
|
+
);
|
|
715
755
|
}
|
|
716
|
-
await import_fs_extra2.default.outputFile(
|
|
756
|
+
await import_fs_extra2.default.outputFile(
|
|
757
|
+
import_path2.default.join(tinaGeneratedPath, ".gitignore"),
|
|
758
|
+
`app
|
|
717
759
|
db
|
|
718
760
|
prebuild
|
|
719
761
|
client.ts
|
|
@@ -725,7 +767,8 @@ frags.gql
|
|
|
725
767
|
queries.gql
|
|
726
768
|
schema.gql
|
|
727
769
|
out.jsx
|
|
728
|
-
`
|
|
770
|
+
`
|
|
771
|
+
);
|
|
729
772
|
};
|
|
730
773
|
var cleanup = async ({ tinaTempPath }) => {
|
|
731
774
|
await import_fs_extra2.default.remove(tinaTempPath);
|
|
@@ -735,14 +778,14 @@ var compileFile = async (options, fileName) => {
|
|
|
735
778
|
if (!root) {
|
|
736
779
|
throw new Error("ctx.rootPath has not been attached");
|
|
737
780
|
}
|
|
738
|
-
const tinaPath =
|
|
739
|
-
const tsConfigPath =
|
|
740
|
-
const tinaGeneratedPath =
|
|
741
|
-
const tinaTempPath =
|
|
742
|
-
const packageJSONFilePath =
|
|
781
|
+
const tinaPath = import_path2.default.join(root, ".tina");
|
|
782
|
+
const tsConfigPath = import_path2.default.join(root, "tsconfig.json");
|
|
783
|
+
const tinaGeneratedPath = import_path2.default.join(tinaPath, "__generated__");
|
|
784
|
+
const tinaTempPath = import_path2.default.join(tinaGeneratedPath, `temp_${fileName}`);
|
|
785
|
+
const packageJSONFilePath = import_path2.default.join(root, "package.json");
|
|
743
786
|
if (!options.schemaFileType) {
|
|
744
787
|
const usingTs = await import_fs_extra2.default.pathExists(tsConfigPath);
|
|
745
|
-
options =
|
|
788
|
+
options = { ...options, schemaFileType: usingTs ? "ts" : "js" };
|
|
746
789
|
}
|
|
747
790
|
if (options.verbose) {
|
|
748
791
|
logger.info(logText(`Compiling ${fileName}...`));
|
|
@@ -750,7 +793,9 @@ var compileFile = async (options, fileName) => {
|
|
|
750
793
|
const { schemaFileType: requestedSchemaFileType = "ts" } = options;
|
|
751
794
|
const schemaFileType2 = (requestedSchemaFileType === "ts" || requestedSchemaFileType === "tsx") && "ts" || (requestedSchemaFileType === "js" || requestedSchemaFileType === "jsx") && "js";
|
|
752
795
|
if (!schemaFileType2) {
|
|
753
|
-
throw new Error(
|
|
796
|
+
throw new Error(
|
|
797
|
+
`Requested schema file type '${requestedSchemaFileType}' is not valid. Supported schema file types: 'ts, js, tsx, jsx'`
|
|
798
|
+
);
|
|
754
799
|
}
|
|
755
800
|
try {
|
|
756
801
|
const define = {};
|
|
@@ -763,7 +808,14 @@ var compileFile = async (options, fileName) => {
|
|
|
763
808
|
allowedTypes: ["js", "jsx", "tsx", "ts"],
|
|
764
809
|
errorMessage: `Must provide a ${fileName}.{js,jsx,tsx,ts}`
|
|
765
810
|
});
|
|
766
|
-
await transpile(
|
|
811
|
+
await transpile(
|
|
812
|
+
inputFile,
|
|
813
|
+
`${fileName}.cjs`,
|
|
814
|
+
tinaTempPath,
|
|
815
|
+
options.verbose,
|
|
816
|
+
define,
|
|
817
|
+
packageJSONFilePath
|
|
818
|
+
);
|
|
767
819
|
} catch (e) {
|
|
768
820
|
await cleanup({ tinaTempPath });
|
|
769
821
|
throw new BuildSchemaError(e);
|
|
@@ -775,7 +827,7 @@ var compileFile = async (options, fileName) => {
|
|
|
775
827
|
});
|
|
776
828
|
let returnObject = {};
|
|
777
829
|
try {
|
|
778
|
-
const schemaFunc = require(
|
|
830
|
+
const schemaFunc = require(import_path2.default.join(tinaTempPath, `${fileName}.cjs`));
|
|
779
831
|
returnObject = schemaFunc.default;
|
|
780
832
|
await cleanup({ tinaTempPath });
|
|
781
833
|
} catch (e) {
|
|
@@ -791,9 +843,9 @@ var compileFile = async (options, fileName) => {
|
|
|
791
843
|
};
|
|
792
844
|
var compileSchema = async (options) => {
|
|
793
845
|
const root = options.rootPath;
|
|
794
|
-
const tinaPath =
|
|
795
|
-
const tinaGeneratedPath =
|
|
796
|
-
const tinaConfigPath =
|
|
846
|
+
const tinaPath = import_path2.default.join(root, ".tina");
|
|
847
|
+
const tinaGeneratedPath = import_path2.default.join(tinaPath, "__generated__");
|
|
848
|
+
const tinaConfigPath = import_path2.default.join(tinaGeneratedPath, "config");
|
|
797
849
|
const schemaExists = fileExists({
|
|
798
850
|
projectDir: tinaPath,
|
|
799
851
|
filename: "schema",
|
|
@@ -805,12 +857,16 @@ var compileSchema = async (options) => {
|
|
|
805
857
|
allowedTypes: ["js", "jsx", "tsx", "ts"]
|
|
806
858
|
});
|
|
807
859
|
if (!schemaExists && !configExists) {
|
|
808
|
-
throw new Error(
|
|
860
|
+
throw new Error(
|
|
861
|
+
"No schema or config file found in .tina folder. Please run `npx @tinacms/cli@latest init` to generate a schema file."
|
|
862
|
+
);
|
|
809
863
|
}
|
|
810
864
|
let schema;
|
|
811
865
|
if (schemaExists && !configExists) {
|
|
812
|
-
console.warn(
|
|
813
|
-
|
|
866
|
+
console.warn(
|
|
867
|
+
`schema.{ts,tsx,js,jsx} will soon be deprecated, in favor of the new config.{ts,tsx,js,jsx}
|
|
868
|
+
See here for migration steps, see here: https://tina.io/blog/upgrading-to-iframe`
|
|
869
|
+
);
|
|
814
870
|
schema = await compileFile(options, "schema");
|
|
815
871
|
}
|
|
816
872
|
if (configExists) {
|
|
@@ -818,21 +874,26 @@ See here for migration steps, see here: https://tina.io/blog/upgrading-to-iframe
|
|
|
818
874
|
const configCopy = _.cloneDeep(config2);
|
|
819
875
|
delete configCopy.schema;
|
|
820
876
|
if (config2 == null ? void 0 : config2.schema) {
|
|
821
|
-
schema =
|
|
877
|
+
schema = { ...config2.schema, config: configCopy };
|
|
822
878
|
}
|
|
823
879
|
}
|
|
824
|
-
await import_fs_extra2.default.outputFile(
|
|
880
|
+
await import_fs_extra2.default.outputFile(
|
|
881
|
+
import_path2.default.join(tinaConfigPath, `schema.json`),
|
|
882
|
+
JSON.stringify(schema, null, 2)
|
|
883
|
+
);
|
|
825
884
|
return schema;
|
|
826
885
|
};
|
|
827
886
|
var transpile = async (inputFile, outputFile, tempDir, verbose, define, packageJSONFilePath, platform = "neutral") => {
|
|
828
887
|
if (verbose)
|
|
829
888
|
logger.info(logText("Building javascript..."));
|
|
830
|
-
const packageJSON = JSON.parse(
|
|
889
|
+
const packageJSON = JSON.parse(
|
|
890
|
+
import_fs_extra2.default.readFileSync(packageJSONFilePath).toString() || "{}"
|
|
891
|
+
);
|
|
831
892
|
const deps = (packageJSON == null ? void 0 : packageJSON.dependencies) || [];
|
|
832
893
|
const peerDeps = (packageJSON == null ? void 0 : packageJSON.peerDependencies) || [];
|
|
833
894
|
const devDeps = (packageJSON == null ? void 0 : packageJSON.devDependencies) || [];
|
|
834
|
-
const external = Object.keys(
|
|
835
|
-
const prebuiltInputPath =
|
|
895
|
+
const external = Object.keys({ ...deps, ...peerDeps, ...devDeps });
|
|
896
|
+
const prebuiltInputPath = import_path2.default.join(tempDir, "temp-output.jsx");
|
|
836
897
|
await (0, import_esbuild.build)({
|
|
837
898
|
bundle: true,
|
|
838
899
|
platform,
|
|
@@ -844,9 +905,9 @@ var transpile = async (inputFile, outputFile, tempDir, verbose, define, packageJ
|
|
|
844
905
|
outfile: prebuiltInputPath,
|
|
845
906
|
define
|
|
846
907
|
});
|
|
847
|
-
const tempTsConfigPath =
|
|
908
|
+
const tempTsConfigPath = import_path2.default.join(tempDir, "temp-tsconfig.json");
|
|
848
909
|
await import_fs_extra2.default.outputFileSync(tempTsConfigPath, "{}");
|
|
849
|
-
const outputPath =
|
|
910
|
+
const outputPath = import_path2.default.join(tempDir, outputFile);
|
|
850
911
|
await (0, import_esbuild.build)({
|
|
851
912
|
bundle: true,
|
|
852
913
|
platform,
|
|
@@ -893,12 +954,12 @@ var loaders = {
|
|
|
893
954
|
};
|
|
894
955
|
|
|
895
956
|
// src/cmds/query-gen/genTypes.ts
|
|
896
|
-
var import_graphql8 =
|
|
897
|
-
var import_fs_extra3 =
|
|
898
|
-
var
|
|
957
|
+
var import_graphql8 = require("graphql");
|
|
958
|
+
var import_fs_extra3 = __toESM(require("fs-extra"));
|
|
959
|
+
var import_path3 = __toESM(require("path"));
|
|
899
960
|
|
|
900
961
|
// src/codegen/index.ts
|
|
901
|
-
var import_graphql7 =
|
|
962
|
+
var import_graphql7 = require("graphql");
|
|
902
963
|
|
|
903
964
|
// src/codegen/plugin.ts
|
|
904
965
|
var AddGeneratedClientFunc = (_schema, _documents, _config, _info) => {
|
|
@@ -943,21 +1004,20 @@ var AddGeneratedClient = {
|
|
|
943
1004
|
};
|
|
944
1005
|
|
|
945
1006
|
// src/codegen/index.ts
|
|
946
|
-
var import_graphql_file_loader =
|
|
947
|
-
var import_core =
|
|
948
|
-
var import_load =
|
|
949
|
-
var import_typescript_operations =
|
|
950
|
-
var import_typescript =
|
|
1007
|
+
var import_graphql_file_loader = require("@graphql-tools/graphql-file-loader");
|
|
1008
|
+
var import_core = require("@graphql-codegen/core");
|
|
1009
|
+
var import_load = require("@graphql-tools/load");
|
|
1010
|
+
var import_typescript_operations = require("@graphql-codegen/typescript-operations");
|
|
1011
|
+
var import_typescript = require("@graphql-codegen/typescript");
|
|
951
1012
|
|
|
952
1013
|
// src/codegen/sdkPlugin/index.ts
|
|
953
|
-
var import_graphql5 =
|
|
954
|
-
var import_graphql6 =
|
|
955
|
-
var import_path4 = __toModule(require("path"));
|
|
1014
|
+
var import_graphql5 = require("graphql");
|
|
1015
|
+
var import_graphql6 = require("graphql");
|
|
956
1016
|
|
|
957
1017
|
// src/codegen/sdkPlugin/visitor.ts
|
|
958
|
-
var import_visitor_plugin_common =
|
|
959
|
-
var import_auto_bind =
|
|
960
|
-
var import_graphql4 =
|
|
1018
|
+
var import_visitor_plugin_common = require("@graphql-codegen/visitor-plugin-common");
|
|
1019
|
+
var import_auto_bind = __toESM(require("auto-bind"));
|
|
1020
|
+
var import_graphql4 = require("graphql");
|
|
961
1021
|
var GenericSdkVisitor = class extends import_visitor_plugin_common.ClientSideBaseVisitor {
|
|
962
1022
|
constructor(schema, fragments, rawConfig) {
|
|
963
1023
|
super(schema, fragments, rawConfig, {
|
|
@@ -973,7 +1033,9 @@ var GenericSdkVisitor = class extends import_visitor_plugin_common.ClientSideBas
|
|
|
973
1033
|
}
|
|
974
1034
|
buildOperation(node, documentVariableName, operationType, operationResultType, operationVariablesTypes) {
|
|
975
1035
|
if (node.name == null) {
|
|
976
|
-
throw new Error(
|
|
1036
|
+
throw new Error(
|
|
1037
|
+
"Plugin 'generic-sdk' cannot generate SDK for unnamed operation.\n\n" + (0, import_graphql4.print)(node)
|
|
1038
|
+
);
|
|
977
1039
|
} else {
|
|
978
1040
|
this._operationsToInclude.push({
|
|
979
1041
|
node,
|
|
@@ -988,7 +1050,9 @@ var GenericSdkVisitor = class extends import_visitor_plugin_common.ClientSideBas
|
|
|
988
1050
|
get sdkContent() {
|
|
989
1051
|
const usingObservable = !!this.config.usingObservableFrom;
|
|
990
1052
|
const allPossibleActions = this._operationsToInclude.map((o) => {
|
|
991
|
-
const optionalVariables = !o.node.variableDefinitions || o.node.variableDefinitions.length === 0 || o.node.variableDefinitions.every(
|
|
1053
|
+
const optionalVariables = !o.node.variableDefinitions || o.node.variableDefinitions.length === 0 || o.node.variableDefinitions.every(
|
|
1054
|
+
(v) => v.type.kind !== import_graphql4.Kind.NON_NULL_TYPE || v.defaultValue
|
|
1055
|
+
);
|
|
992
1056
|
const returnType = usingObservable && o.operationType === "Subscription" ? "Observable" : "Promise";
|
|
993
1057
|
return `${o.node.name.value}(variables${optionalVariables ? "?" : ""}: ${o.operationVariablesTypes}, options?: C): ${returnType}<${o.operationResultType}> {
|
|
994
1058
|
return requester<${o.operationResultType}, ${o.operationVariablesTypes}>(${o.documentVariableName}, variables, options);
|
|
@@ -1006,11 +1070,15 @@ var GenericSdkVisitor = class extends import_visitor_plugin_common.ClientSideBas
|
|
|
1006
1070
|
|
|
1007
1071
|
// src/codegen/sdkPlugin/index.ts
|
|
1008
1072
|
var plugin = (schema, documents, config2) => {
|
|
1009
|
-
const allAst = (0, import_graphql6.concatAST)(
|
|
1010
|
-
|
|
1011
|
-
|
|
1073
|
+
const allAst = (0, import_graphql6.concatAST)(
|
|
1074
|
+
documents.reduce((prev, v) => {
|
|
1075
|
+
return [...prev, v.document];
|
|
1076
|
+
}, [])
|
|
1077
|
+
);
|
|
1012
1078
|
const allFragments = [
|
|
1013
|
-
...allAst.definitions.filter(
|
|
1079
|
+
...allAst.definitions.filter(
|
|
1080
|
+
(d) => d.kind === import_graphql6.Kind.FRAGMENT_DEFINITION
|
|
1081
|
+
).map((fragmentDef) => ({
|
|
1014
1082
|
node: fragmentDef,
|
|
1015
1083
|
name: fragmentDef.name.value,
|
|
1016
1084
|
onType: fragmentDef.typeCondition.name.value,
|
|
@@ -1077,7 +1145,9 @@ var loadGraphQLDocuments = async (globPath) => {
|
|
|
1077
1145
|
loaders: [new import_graphql_file_loader.GraphQLFileLoader()]
|
|
1078
1146
|
});
|
|
1079
1147
|
} catch (e) {
|
|
1080
|
-
if ((e.message || "").includes(
|
|
1148
|
+
if ((e.message || "").includes(
|
|
1149
|
+
"Unable to find any GraphQL type definitions for the following pointers:"
|
|
1150
|
+
)) {
|
|
1081
1151
|
} else {
|
|
1082
1152
|
throw e;
|
|
1083
1153
|
}
|
|
@@ -1086,7 +1156,7 @@ var loadGraphQLDocuments = async (globPath) => {
|
|
|
1086
1156
|
};
|
|
1087
1157
|
|
|
1088
1158
|
// src/cmds/query-gen/genTypes.ts
|
|
1089
|
-
var import_esbuild2 =
|
|
1159
|
+
var import_esbuild2 = require("esbuild");
|
|
1090
1160
|
var TINA_HOST = "content.tinajs.io";
|
|
1091
1161
|
async function genClient({
|
|
1092
1162
|
tinaSchema,
|
|
@@ -1094,7 +1164,7 @@ async function genClient({
|
|
|
1094
1164
|
rootPath: rootPath2
|
|
1095
1165
|
}, options) {
|
|
1096
1166
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
1097
|
-
const generatedPath =
|
|
1167
|
+
const generatedPath = import_path3.default.join(rootPath2, ".tina", "__generated__");
|
|
1098
1168
|
const branch = (_a = tinaSchema == null ? void 0 : tinaSchema.config) == null ? void 0 : _a.branch;
|
|
1099
1169
|
const clientId = (_b = tinaSchema == null ? void 0 : tinaSchema.config) == null ? void 0 : _b.clientId;
|
|
1100
1170
|
const token = (_c = tinaSchema.config) == null ? void 0 : _c.token;
|
|
@@ -1107,18 +1177,25 @@ async function genClient({
|
|
|
1107
1177
|
missing.push("clientId");
|
|
1108
1178
|
if (!token)
|
|
1109
1179
|
missing.push("token");
|
|
1110
|
-
throw new Error(
|
|
1180
|
+
throw new Error(
|
|
1181
|
+
`Client not configured properly. Missing ${missing.join(
|
|
1182
|
+
", "
|
|
1183
|
+
)}. Please visit https://tina.io/docs/tina-cloud/connecting-site/ for more information`
|
|
1184
|
+
);
|
|
1111
1185
|
}
|
|
1112
1186
|
let apiURL = options.local ? `http://localhost:${options.port || 4001}/graphql` : `${baseUrl}/content/${clientId}/github/${branch}`;
|
|
1113
1187
|
if ((_g = tinaSchema.config) == null ? void 0 : _g.contentApiUrlOverride) {
|
|
1114
1188
|
apiURL = tinaSchema.config.contentApiUrlOverride;
|
|
1115
1189
|
}
|
|
1116
|
-
const clientPath =
|
|
1117
|
-
import_fs_extra3.default.writeFileSync(
|
|
1190
|
+
const clientPath = import_path3.default.join(generatedPath, `client.${usingTs ? "ts" : "js"}`);
|
|
1191
|
+
import_fs_extra3.default.writeFileSync(
|
|
1192
|
+
clientPath,
|
|
1193
|
+
`import { createClient } from "tinacms/dist/client";
|
|
1118
1194
|
import { queries } from "./types";
|
|
1119
1195
|
export const client = createClient({ url: '${apiURL}', token: '${token}', queries });
|
|
1120
1196
|
export default client;
|
|
1121
|
-
`
|
|
1197
|
+
`
|
|
1198
|
+
);
|
|
1122
1199
|
return apiURL;
|
|
1123
1200
|
}
|
|
1124
1201
|
async function genTypes({
|
|
@@ -1131,7 +1208,12 @@ async function genTypes({
|
|
|
1131
1208
|
const typesDPath = rootPath2 + "/.tina/__generated__/types.d.ts";
|
|
1132
1209
|
const fragPath = rootPath2 + "/.tina/__generated__/*.{graphql,gql}";
|
|
1133
1210
|
const queryPathGlob = rootPath2 + "/.tina/queries/**/*.{graphql,gql}";
|
|
1134
|
-
const typescriptTypes = await generateTypes(
|
|
1211
|
+
const typescriptTypes = await generateTypes(
|
|
1212
|
+
schema,
|
|
1213
|
+
queryPathGlob,
|
|
1214
|
+
fragPath,
|
|
1215
|
+
options
|
|
1216
|
+
);
|
|
1135
1217
|
const code = `//@ts-nocheck
|
|
1136
1218
|
// DO NOT MODIFY THIS FILE. This file is automatically generated by Tina
|
|
1137
1219
|
export function gql(strings: TemplateStringsArray, ...args: string[]): string {
|
|
@@ -1152,21 +1234,24 @@ async function genTypes({
|
|
|
1152
1234
|
}
|
|
1153
1235
|
const schemaString = await (0, import_graphql8.printSchema)(schema);
|
|
1154
1236
|
const schemaPath = rootPath2 + "/.tina/__generated__/schema.gql";
|
|
1155
|
-
await import_fs_extra3.default.outputFile(
|
|
1237
|
+
await import_fs_extra3.default.outputFile(
|
|
1238
|
+
schemaPath,
|
|
1239
|
+
`# DO NOT MODIFY THIS FILE. This file is automatically generated by Tina
|
|
1156
1240
|
${schemaString}
|
|
1157
1241
|
schema {
|
|
1158
1242
|
query: Query
|
|
1159
1243
|
mutation: Mutation
|
|
1160
1244
|
}
|
|
1161
|
-
`
|
|
1245
|
+
`
|
|
1246
|
+
);
|
|
1162
1247
|
next();
|
|
1163
1248
|
}
|
|
1164
1249
|
|
|
1165
1250
|
// src/buildTina/index.ts
|
|
1166
|
-
var import_app =
|
|
1251
|
+
var import_app = require("@tinacms/app");
|
|
1167
1252
|
|
|
1168
1253
|
// src/utils/spinner.ts
|
|
1169
|
-
var import_cli_spinner =
|
|
1254
|
+
var import_cli_spinner = require("cli-spinner");
|
|
1170
1255
|
async function localSpin({
|
|
1171
1256
|
waitFor,
|
|
1172
1257
|
text
|
|
@@ -1202,39 +1287,41 @@ function spin({
|
|
|
1202
1287
|
}
|
|
1203
1288
|
|
|
1204
1289
|
// src/buildTina/attachPath.ts
|
|
1205
|
-
var import_fs_extra4 =
|
|
1206
|
-
var
|
|
1290
|
+
var import_fs_extra4 = require("fs-extra");
|
|
1291
|
+
var import_path4 = __toESM(require("path"));
|
|
1207
1292
|
var attachPath = async (ctx, next, options) => {
|
|
1208
1293
|
ctx.rootPath = options.rootPath || process.cwd();
|
|
1209
1294
|
ctx.usingTs = await isProjectTs(ctx.rootPath);
|
|
1210
1295
|
next();
|
|
1211
1296
|
};
|
|
1212
1297
|
var isProjectTs = async (rootPath2) => {
|
|
1213
|
-
const tinaPath =
|
|
1214
|
-
return await (0, import_fs_extra4.pathExists)(
|
|
1298
|
+
const tinaPath = import_path4.default.join(rootPath2, ".tina");
|
|
1299
|
+
return await (0, import_fs_extra4.pathExists)(import_path4.default.join(tinaPath, "schema.ts")) || await (0, import_fs_extra4.pathExists)(import_path4.default.join(tinaPath, "schema.tsx")) || await (0, import_fs_extra4.pathExists)(import_path4.default.join(tinaPath, "config.ts")) || await (0, import_fs_extra4.pathExists)(import_path4.default.join(tinaPath, "config.tsx"));
|
|
1215
1300
|
};
|
|
1216
1301
|
|
|
1217
1302
|
// src/buildTina/index.ts
|
|
1218
1303
|
var buildSetupCmdBuild = async (ctx, next, opts) => {
|
|
1219
1304
|
const rootPath2 = ctx.rootPath;
|
|
1220
|
-
await buildSetup(
|
|
1305
|
+
await buildSetup({
|
|
1306
|
+
...opts,
|
|
1221
1307
|
rootPath: rootPath2
|
|
1222
|
-
})
|
|
1308
|
+
});
|
|
1223
1309
|
ctx.builder = new ConfigBuilder(ctx.database);
|
|
1224
1310
|
next();
|
|
1225
1311
|
};
|
|
1226
1312
|
var buildSetupCmdServerStart = async (ctx, next, opts) => {
|
|
1227
1313
|
const rootPath2 = ctx.rootPath;
|
|
1228
|
-
await buildSetup(
|
|
1314
|
+
await buildSetup({
|
|
1315
|
+
...opts,
|
|
1229
1316
|
rootPath: rootPath2
|
|
1230
|
-
})
|
|
1317
|
+
});
|
|
1231
1318
|
ctx.builder = new ConfigBuilder(ctx.database);
|
|
1232
1319
|
next();
|
|
1233
1320
|
};
|
|
1234
1321
|
var buildSetupCmdAudit = async (ctx, next, options) => {
|
|
1235
1322
|
const rootPath2 = ctx.rootPath;
|
|
1236
1323
|
const bridge = options.clean ? new import_datalayer.FilesystemBridge(rootPath2) : new import_datalayer.AuditFileSystemBridge(rootPath2);
|
|
1237
|
-
await import_fs_extra5.default.ensureDirSync(
|
|
1324
|
+
await import_fs_extra5.default.ensureDirSync(import_path5.default.join(rootPath2, ".tina", "__generated__"));
|
|
1238
1325
|
const database = await (0, import_graphql9.createDatabase)({
|
|
1239
1326
|
level: new import_memory_level.MemoryLevel({
|
|
1240
1327
|
valueEncoding: "json"
|
|
@@ -1247,12 +1334,13 @@ var buildSetupCmdAudit = async (ctx, next, options) => {
|
|
|
1247
1334
|
next();
|
|
1248
1335
|
};
|
|
1249
1336
|
var buildSetup = async ({ rootPath: rootPath2 }) => {
|
|
1250
|
-
await import_fs_extra5.default.ensureDirSync(
|
|
1337
|
+
await import_fs_extra5.default.ensureDirSync(import_path5.default.join(rootPath2, ".tina", "__generated__"));
|
|
1251
1338
|
};
|
|
1252
1339
|
var buildCmdBuild = async (ctx, next, options) => {
|
|
1253
|
-
const { schema, graphQLSchema, tinaSchema } = await ctx.builder.build(
|
|
1254
|
-
rootPath: ctx.rootPath
|
|
1255
|
-
|
|
1340
|
+
const { schema, graphQLSchema, tinaSchema } = await ctx.builder.build({
|
|
1341
|
+
rootPath: ctx.rootPath,
|
|
1342
|
+
...options
|
|
1343
|
+
});
|
|
1256
1344
|
ctx.schema = schema;
|
|
1257
1345
|
ctx.graphQLSchema = graphQLSchema;
|
|
1258
1346
|
ctx.tinaSchema = tinaSchema;
|
|
@@ -1275,11 +1363,11 @@ var buildCmdBuild = async (ctx, next, options) => {
|
|
|
1275
1363
|
next();
|
|
1276
1364
|
};
|
|
1277
1365
|
var auditCmdBuild = async (ctx, next, options) => {
|
|
1278
|
-
const { graphQLSchema, tinaSchema } = await ctx.builder.build(
|
|
1279
|
-
rootPath: ctx.rootPath
|
|
1280
|
-
|
|
1366
|
+
const { graphQLSchema, tinaSchema } = await ctx.builder.build({
|
|
1367
|
+
rootPath: ctx.rootPath,
|
|
1368
|
+
...options,
|
|
1281
1369
|
verbose: true
|
|
1282
|
-
})
|
|
1370
|
+
});
|
|
1283
1371
|
await spin({
|
|
1284
1372
|
waitFor: async () => {
|
|
1285
1373
|
await ctx.database.indexContent({ graphQLSchema, tinaSchema });
|
|
@@ -1311,7 +1399,7 @@ var ConfigBuilder = class {
|
|
|
1311
1399
|
if (!rootPath2) {
|
|
1312
1400
|
throw new Error("Root path has not been attached");
|
|
1313
1401
|
}
|
|
1314
|
-
const tinaGeneratedPath =
|
|
1402
|
+
const tinaGeneratedPath = import_path5.default.join(rootPath2, ".tina", "__generated__");
|
|
1315
1403
|
this.database.clearCache();
|
|
1316
1404
|
await import_fs_extra5.default.mkdirp(tinaGeneratedPath);
|
|
1317
1405
|
await resetGeneratedFolder({
|
|
@@ -1326,22 +1414,32 @@ var ConfigBuilder = class {
|
|
|
1326
1414
|
});
|
|
1327
1415
|
if (this.database.bridge.addOutputPath && ((_a = compiledSchema.config) == null ? void 0 : _a.localContentPath)) {
|
|
1328
1416
|
if ((_c = (_b = compiledSchema == null ? void 0 : compiledSchema.config) == null ? void 0 : _b.media) == null ? void 0 : _c.tina) {
|
|
1329
|
-
throw new Error(
|
|
1417
|
+
throw new Error(
|
|
1418
|
+
`"media.tina" is not supported when the "localContentPath" property is present.`
|
|
1419
|
+
);
|
|
1330
1420
|
}
|
|
1331
1421
|
let localContentPath = compiledSchema.config.localContentPath;
|
|
1332
1422
|
if (!localContentPath.startsWith("/")) {
|
|
1333
|
-
localContentPath =
|
|
1423
|
+
localContentPath = import_path5.default.join(process.cwd(), ".tina", localContentPath);
|
|
1334
1424
|
}
|
|
1335
1425
|
if (await import_fs_extra5.default.pathExists(localContentPath)) {
|
|
1336
1426
|
logger.info(logText(`Using separate content path ${localContentPath}`));
|
|
1337
1427
|
} else {
|
|
1338
|
-
logger.warn(
|
|
1339
|
-
|
|
1428
|
+
logger.warn(
|
|
1429
|
+
warnText(
|
|
1430
|
+
`Using separate content path ${localContentPath}
|
|
1431
|
+
but no directory was found at that location, creating one...`
|
|
1432
|
+
)
|
|
1433
|
+
);
|
|
1340
1434
|
await import_fs_extra5.default.mkdir(localContentPath);
|
|
1341
1435
|
}
|
|
1342
1436
|
this.database.bridge.addOutputPath(localContentPath);
|
|
1343
1437
|
}
|
|
1344
|
-
const { graphQLSchema, tinaSchema } = await (0, import_graphql9.buildSchema)(
|
|
1438
|
+
const { graphQLSchema, tinaSchema } = await (0, import_graphql9.buildSchema)(
|
|
1439
|
+
rootPath2,
|
|
1440
|
+
this.database,
|
|
1441
|
+
["experimentalData", "isomorphicGitBridge"]
|
|
1442
|
+
);
|
|
1345
1443
|
return { schema: compiledSchema, graphQLSchema, tinaSchema };
|
|
1346
1444
|
}
|
|
1347
1445
|
async genTypedClient({
|
|
@@ -1359,10 +1457,13 @@ var ConfigBuilder = class {
|
|
|
1359
1457
|
noSDK,
|
|
1360
1458
|
verbose
|
|
1361
1459
|
});
|
|
1362
|
-
return genClient(
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1460
|
+
return genClient(
|
|
1461
|
+
{ tinaSchema: compiledSchema, usingTs, rootPath: rootPath2 },
|
|
1462
|
+
{
|
|
1463
|
+
local,
|
|
1464
|
+
port
|
|
1465
|
+
}
|
|
1466
|
+
);
|
|
1366
1467
|
}
|
|
1367
1468
|
};
|
|
1368
1469
|
var buildAdmin = async ({
|
|
@@ -1439,7 +1540,7 @@ async function startServer(ctx, next, {
|
|
|
1439
1540
|
await buildLock.promise;
|
|
1440
1541
|
buildLock.enable();
|
|
1441
1542
|
try {
|
|
1442
|
-
const s = (init_server3(), server_exports);
|
|
1543
|
+
const s = (init_server3(), __toCommonJS(server_exports));
|
|
1443
1544
|
state.server = await s.default(database);
|
|
1444
1545
|
await new Promise((resolve2, reject) => {
|
|
1445
1546
|
state.server.listen(port, () => {
|
|
@@ -1499,7 +1600,11 @@ async function startServer(ctx, next, {
|
|
|
1499
1600
|
ctx.schema = schema;
|
|
1500
1601
|
const missingFormat = (_b = (_a = tinaSchema == null ? void 0 : tinaSchema.schema) == null ? void 0 : _a.collections) == null ? void 0 : _b.filter((x) => !x.format).map((x) => x.name).join(", ");
|
|
1501
1602
|
if (missingFormat) {
|
|
1502
|
-
logger.warn(
|
|
1603
|
+
logger.warn(
|
|
1604
|
+
warnText(
|
|
1605
|
+
`No format provided for collection(s) "${missingFormat}", defaulting to .md`
|
|
1606
|
+
)
|
|
1607
|
+
);
|
|
1503
1608
|
}
|
|
1504
1609
|
const apiUrl = await ctx.builder.genTypedClient({
|
|
1505
1610
|
compiledSchema: schema,
|
|
@@ -1528,19 +1633,22 @@ async function startServer(ctx, next, {
|
|
|
1528
1633
|
await afterBuild();
|
|
1529
1634
|
}
|
|
1530
1635
|
};
|
|
1531
|
-
const foldersToWatch = (watchFolders || []).map((x) =>
|
|
1636
|
+
const foldersToWatch = (watchFolders || []).map((x) => import_path8.default.join(rootPath2, x));
|
|
1532
1637
|
if (!noWatch && !process.env.CI) {
|
|
1533
|
-
import_chokidar.default.watch(
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1638
|
+
import_chokidar.default.watch(
|
|
1639
|
+
[
|
|
1640
|
+
...foldersToWatch,
|
|
1641
|
+
`${rootPath2}/.tina/**/*.{ts,gql,graphql,js,tsx,jsx}`,
|
|
1642
|
+
gqlPackageFile
|
|
1643
|
+
],
|
|
1644
|
+
{
|
|
1645
|
+
ignored: [
|
|
1646
|
+
"**/node_modules/**/*",
|
|
1647
|
+
"**/.next/**/*",
|
|
1648
|
+
`${import_path8.default.resolve(rootPath2)}/.tina/__generated__/**/*`
|
|
1649
|
+
]
|
|
1650
|
+
}
|
|
1651
|
+
).on("ready", async () => {
|
|
1544
1652
|
if (verbose)
|
|
1545
1653
|
console.log("Generating Tina config");
|
|
1546
1654
|
try {
|
|
@@ -1593,8 +1701,8 @@ async function startServer(ctx, next, {
|
|
|
1593
1701
|
}
|
|
1594
1702
|
|
|
1595
1703
|
// src/cmds/statusChecks/waitForIndexing.ts
|
|
1596
|
-
var import_progress =
|
|
1597
|
-
var import_schema_tools =
|
|
1704
|
+
var import_progress = __toESM(require("progress"));
|
|
1705
|
+
var import_schema_tools = require("@tinacms/schema-tools");
|
|
1598
1706
|
var POLLING_INTERVAL = 5e3;
|
|
1599
1707
|
var STATUS_INPROGRESS = "inprogress";
|
|
1600
1708
|
var STATUS_COMPLETE = "complete";
|
|
@@ -1614,7 +1722,10 @@ var waitForDB = async (ctx, next, options) => {
|
|
|
1614
1722
|
if (isLocalClient) {
|
|
1615
1723
|
return next();
|
|
1616
1724
|
}
|
|
1617
|
-
const bar = new import_progress.default(
|
|
1725
|
+
const bar = new import_progress.default(
|
|
1726
|
+
"Checking indexing process in Tina Cloud... :prog",
|
|
1727
|
+
1
|
|
1728
|
+
);
|
|
1618
1729
|
const pollForStatus = async () => {
|
|
1619
1730
|
try {
|
|
1620
1731
|
if (options.verbose) {
|
|
@@ -1625,11 +1736,14 @@ var waitForDB = async (ctx, next, options) => {
|
|
|
1625
1736
|
if (token) {
|
|
1626
1737
|
headers.append("X-API-KEY", token);
|
|
1627
1738
|
}
|
|
1628
|
-
const response = await fetch(
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1739
|
+
const response = await fetch(
|
|
1740
|
+
`https://${host}/db/${clientId}/status/${branch}`,
|
|
1741
|
+
{
|
|
1742
|
+
method: "GET",
|
|
1743
|
+
headers,
|
|
1744
|
+
cache: "no-cache"
|
|
1745
|
+
}
|
|
1746
|
+
);
|
|
1633
1747
|
const { status, error } = await response.json();
|
|
1634
1748
|
const statusMessage = `Indexing status: '${status}'`;
|
|
1635
1749
|
if (status === STATUS_COMPLETE) {
|
|
@@ -1643,9 +1757,13 @@ var waitForDB = async (ctx, next, options) => {
|
|
|
1643
1757
|
}
|
|
1644
1758
|
setTimeout(pollForStatus, POLLING_INTERVAL);
|
|
1645
1759
|
} else if (status === STATUS_FAILED) {
|
|
1646
|
-
throw new IndexFailedError(
|
|
1760
|
+
throw new IndexFailedError(
|
|
1761
|
+
`Attempting to index but responded with status 'failed', To retry the indexing process, click \u201CReset Repository Cache\u201D in tina cloud advance settings. ${error}`
|
|
1762
|
+
);
|
|
1647
1763
|
} else {
|
|
1648
|
-
throw new IndexFailedError(
|
|
1764
|
+
throw new IndexFailedError(
|
|
1765
|
+
`Attempting to index but responded with status 'unknown', To retry the indexing process, click \u201CReset Repository Cache\u201D in tina cloud advance settings. ${error}`
|
|
1766
|
+
);
|
|
1649
1767
|
}
|
|
1650
1768
|
} catch (e) {
|
|
1651
1769
|
if (e instanceof IndexFailedError) {
|
|
@@ -1654,7 +1772,9 @@ var waitForDB = async (ctx, next, options) => {
|
|
|
1654
1772
|
});
|
|
1655
1773
|
throw e;
|
|
1656
1774
|
} else {
|
|
1657
|
-
throw new Error(
|
|
1775
|
+
throw new Error(
|
|
1776
|
+
`Unable to query DB for indexing status, encountered error: ${e.message}`
|
|
1777
|
+
);
|
|
1658
1778
|
}
|
|
1659
1779
|
}
|
|
1660
1780
|
};
|
|
@@ -1665,7 +1785,7 @@ var waitForDB = async (ctx, next, options) => {
|
|
|
1665
1785
|
};
|
|
1666
1786
|
|
|
1667
1787
|
// src/cmds/startSubprocess/index.ts
|
|
1668
|
-
var import_child_process =
|
|
1788
|
+
var import_child_process = __toESM(require("child_process"));
|
|
1669
1789
|
var startSubprocess = async (_ctx, next, { command }) => {
|
|
1670
1790
|
if (typeof command === "string") {
|
|
1671
1791
|
const commands = command.split(" ");
|
|
@@ -1676,7 +1796,11 @@ var startSubprocess = async (_ctx, next, { command }) => {
|
|
|
1676
1796
|
shell: true
|
|
1677
1797
|
});
|
|
1678
1798
|
ps.on("error", (code) => {
|
|
1679
|
-
logger.error(
|
|
1799
|
+
logger.error(
|
|
1800
|
+
dangerText(
|
|
1801
|
+
`An error has occurred in the Next.js child process. Error message below`
|
|
1802
|
+
)
|
|
1803
|
+
);
|
|
1680
1804
|
logger.error(`name: ${code.name}
|
|
1681
1805
|
message: ${code.message}
|
|
1682
1806
|
|
|
@@ -1690,11 +1814,11 @@ stack: ${code.stack || "No stack was provided"}`);
|
|
|
1690
1814
|
};
|
|
1691
1815
|
|
|
1692
1816
|
// src/cmds/init/index.ts
|
|
1693
|
-
var
|
|
1694
|
-
var import_prettier =
|
|
1695
|
-
var import_fs_extra9 =
|
|
1696
|
-
var import_prompts2 =
|
|
1697
|
-
var import_metrics3 =
|
|
1817
|
+
var import_path11 = __toESM(require("path"));
|
|
1818
|
+
var import_prettier = require("prettier");
|
|
1819
|
+
var import_fs_extra9 = __toESM(require("fs-extra"));
|
|
1820
|
+
var import_prompts2 = __toESM(require("prompts"));
|
|
1821
|
+
var import_metrics3 = require("@tinacms/metrics");
|
|
1698
1822
|
|
|
1699
1823
|
// src/cmds/init/setup-files/index.ts
|
|
1700
1824
|
var nextPostPage = ({
|
|
@@ -1922,11 +2046,12 @@ function generateGqlScript(scriptValue) {
|
|
|
1922
2046
|
return `tinacms dev -c "${scriptValue}"`;
|
|
1923
2047
|
}
|
|
1924
2048
|
function extendNextScripts(scripts) {
|
|
1925
|
-
return
|
|
2049
|
+
return {
|
|
2050
|
+
...scripts,
|
|
1926
2051
|
dev: generateGqlScript((scripts == null ? void 0 : scripts.dev) || "next dev"),
|
|
1927
2052
|
build: `tinacms build && ${(scripts == null ? void 0 : scripts.build) || "next build"}`,
|
|
1928
2053
|
start: `tinacms build && ${(scripts == null ? void 0 : scripts.start) || "next start"}`
|
|
1929
|
-
}
|
|
2054
|
+
};
|
|
1930
2055
|
}
|
|
1931
2056
|
|
|
1932
2057
|
// src/cmds/init/setup-files/config.ts
|
|
@@ -2034,10 +2159,10 @@ var configExamples = {
|
|
|
2034
2159
|
};
|
|
2035
2160
|
|
|
2036
2161
|
// src/cmds/forestry-migrate/util/index.ts
|
|
2037
|
-
var import_fs_extra7 =
|
|
2038
|
-
var
|
|
2039
|
-
var import_js_yaml =
|
|
2040
|
-
var import_zod =
|
|
2162
|
+
var import_fs_extra7 = __toESM(require("fs-extra"));
|
|
2163
|
+
var import_path9 = __toESM(require("path"));
|
|
2164
|
+
var import_js_yaml = __toESM(require("js-yaml"));
|
|
2165
|
+
var import_zod = __toESM(require("zod"));
|
|
2041
2166
|
|
|
2042
2167
|
// src/cmds/forestry-migrate/util/errorSingleton.ts
|
|
2043
2168
|
var ErrorSingleton = class {
|
|
@@ -2054,11 +2179,19 @@ var ErrorSingleton = class {
|
|
|
2054
2179
|
this.allErrorNames.push(error);
|
|
2055
2180
|
}
|
|
2056
2181
|
printNameErrors() {
|
|
2057
|
-
logger.error(
|
|
2058
|
-
|
|
2182
|
+
logger.error(
|
|
2183
|
+
dangerText("ERROR: TinaCMS only supports alphanumeric field names")
|
|
2184
|
+
);
|
|
2185
|
+
logger.error(
|
|
2186
|
+
`If you wish to edit any of the following fields or template names you will have to update your content and code to use the new name. See ${linkText(
|
|
2187
|
+
"https://tina.io/docs/forestry/common-errors/#migrating-fields-with-non-alphanumeric-characters"
|
|
2188
|
+
)} for more information.`
|
|
2189
|
+
);
|
|
2059
2190
|
logger.error("The following template and field names have been renamed:`");
|
|
2060
2191
|
this.allErrorNames.forEach((error) => {
|
|
2061
|
-
logger.error(
|
|
2192
|
+
logger.error(
|
|
2193
|
+
`- Content that uses ${error.template}.yaml: ${error.name} -> ${error.newName}`
|
|
2194
|
+
);
|
|
2062
2195
|
});
|
|
2063
2196
|
}
|
|
2064
2197
|
};
|
|
@@ -2091,23 +2224,25 @@ var stringifyTemplateName = (name2, template) => {
|
|
|
2091
2224
|
}
|
|
2092
2225
|
};
|
|
2093
2226
|
var forestryConfigSchema = import_zod.default.object({
|
|
2094
|
-
sections: import_zod.default.array(
|
|
2095
|
-
|
|
2096
|
-
import_zod.default.
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2227
|
+
sections: import_zod.default.array(
|
|
2228
|
+
import_zod.default.object({
|
|
2229
|
+
type: import_zod.default.union([
|
|
2230
|
+
import_zod.default.literal("directory"),
|
|
2231
|
+
import_zod.default.literal("document"),
|
|
2232
|
+
import_zod.default.literal("heading"),
|
|
2233
|
+
import_zod.default.literal("jekyll-pages"),
|
|
2234
|
+
import_zod.default.literal("jekyll-posts")
|
|
2235
|
+
]),
|
|
2236
|
+
label: import_zod.default.string(),
|
|
2237
|
+
path: import_zod.default.string().optional().nullable(),
|
|
2238
|
+
match: import_zod.default.string().optional().nullable(),
|
|
2239
|
+
exclude: import_zod.default.string().optional().nullable(),
|
|
2240
|
+
create: import_zod.default.union([import_zod.default.literal("all"), import_zod.default.literal("documents"), import_zod.default.literal("none")]).optional(),
|
|
2241
|
+
templates: import_zod.default.array(import_zod.default.string()).optional().nullable(),
|
|
2242
|
+
new_doc_ext: import_zod.default.string().optional().nullable(),
|
|
2243
|
+
read_only: import_zod.default.boolean().optional().nullable()
|
|
2244
|
+
})
|
|
2245
|
+
)
|
|
2111
2246
|
});
|
|
2112
2247
|
var forestryFieldWithoutField = import_zod.default.object({
|
|
2113
2248
|
type: import_zod.default.union([
|
|
@@ -2151,9 +2286,11 @@ var forestryFieldWithoutField = import_zod.default.object({
|
|
|
2151
2286
|
}).optional()
|
|
2152
2287
|
}).optional()
|
|
2153
2288
|
});
|
|
2154
|
-
var forestryField = import_zod.default.lazy(
|
|
2155
|
-
|
|
2156
|
-
|
|
2289
|
+
var forestryField = import_zod.default.lazy(
|
|
2290
|
+
() => forestryFieldWithoutField.extend({
|
|
2291
|
+
fields: import_zod.default.array(forestryField).optional()
|
|
2292
|
+
})
|
|
2293
|
+
);
|
|
2157
2294
|
var FrontmatterTemplateSchema = import_zod.default.object({
|
|
2158
2295
|
label: import_zod.default.string(),
|
|
2159
2296
|
hide_body: import_zod.default.boolean().optional(),
|
|
@@ -2169,104 +2306,112 @@ var transformForestryFieldsToTinaFields = ({
|
|
|
2169
2306
|
fields == null ? void 0 : fields.forEach((forestryField2) => {
|
|
2170
2307
|
var _a, _b, _c, _d;
|
|
2171
2308
|
if (forestryField2.name === "menu") {
|
|
2172
|
-
logger.info(
|
|
2309
|
+
logger.info(
|
|
2310
|
+
warnText(
|
|
2311
|
+
`skipping menu field template ${template}.yaml since TinaCMS does not support Hugo or Jekyll menu fields`
|
|
2312
|
+
)
|
|
2313
|
+
);
|
|
2173
2314
|
return;
|
|
2174
2315
|
}
|
|
2175
2316
|
let field;
|
|
2176
2317
|
switch (forestryField2.type) {
|
|
2177
2318
|
case "text":
|
|
2178
|
-
field =
|
|
2179
|
-
type: "string"
|
|
2180
|
-
|
|
2319
|
+
field = {
|
|
2320
|
+
type: "string",
|
|
2321
|
+
...getTinaFieldsFromName(forestryField2.name),
|
|
2181
2322
|
label: forestryField2.label
|
|
2182
|
-
}
|
|
2323
|
+
};
|
|
2183
2324
|
break;
|
|
2184
2325
|
case "textarea":
|
|
2185
|
-
field =
|
|
2186
|
-
type: "string"
|
|
2187
|
-
|
|
2326
|
+
field = {
|
|
2327
|
+
type: "string",
|
|
2328
|
+
...getTinaFieldsFromName(forestryField2.name),
|
|
2188
2329
|
label: forestryField2.label,
|
|
2189
2330
|
ui: {
|
|
2190
2331
|
component: "textarea"
|
|
2191
2332
|
}
|
|
2192
|
-
}
|
|
2333
|
+
};
|
|
2193
2334
|
break;
|
|
2194
2335
|
case "datetime":
|
|
2195
|
-
field =
|
|
2196
|
-
type: forestryField2.type
|
|
2197
|
-
|
|
2336
|
+
field = {
|
|
2337
|
+
type: forestryField2.type,
|
|
2338
|
+
...getTinaFieldsFromName(forestryField2.name),
|
|
2198
2339
|
label: forestryField2.label
|
|
2199
|
-
}
|
|
2340
|
+
};
|
|
2200
2341
|
break;
|
|
2201
2342
|
case "number":
|
|
2202
|
-
field =
|
|
2203
|
-
type: "number"
|
|
2204
|
-
|
|
2343
|
+
field = {
|
|
2344
|
+
type: "number",
|
|
2345
|
+
...getTinaFieldsFromName(forestryField2.name),
|
|
2205
2346
|
label: forestryField2.label
|
|
2206
|
-
}
|
|
2347
|
+
};
|
|
2207
2348
|
break;
|
|
2208
2349
|
case "boolean":
|
|
2209
|
-
field =
|
|
2210
|
-
type: "boolean"
|
|
2211
|
-
|
|
2350
|
+
field = {
|
|
2351
|
+
type: "boolean",
|
|
2352
|
+
...getTinaFieldsFromName(forestryField2.name),
|
|
2212
2353
|
label: forestryField2.label
|
|
2213
|
-
}
|
|
2354
|
+
};
|
|
2214
2355
|
break;
|
|
2215
2356
|
case "color":
|
|
2216
|
-
field =
|
|
2217
|
-
type: "string"
|
|
2218
|
-
|
|
2357
|
+
field = {
|
|
2358
|
+
type: "string",
|
|
2359
|
+
...getTinaFieldsFromName(forestryField2.name),
|
|
2219
2360
|
label: forestryField2.label,
|
|
2220
2361
|
ui: {
|
|
2221
2362
|
component: "color"
|
|
2222
2363
|
}
|
|
2223
|
-
}
|
|
2364
|
+
};
|
|
2224
2365
|
break;
|
|
2225
2366
|
case "file":
|
|
2226
|
-
field =
|
|
2227
|
-
type: "image"
|
|
2228
|
-
|
|
2367
|
+
field = {
|
|
2368
|
+
type: "image",
|
|
2369
|
+
...getTinaFieldsFromName(forestryField2.name),
|
|
2229
2370
|
label: forestryField2.label
|
|
2230
|
-
}
|
|
2371
|
+
};
|
|
2231
2372
|
break;
|
|
2232
2373
|
case "select":
|
|
2233
2374
|
if ((_a = forestryField2.config) == null ? void 0 : _a.options) {
|
|
2234
|
-
field =
|
|
2235
|
-
type: "string"
|
|
2236
|
-
|
|
2375
|
+
field = {
|
|
2376
|
+
type: "string",
|
|
2377
|
+
...getTinaFieldsFromName(forestryField2.name),
|
|
2237
2378
|
label: forestryField2.label,
|
|
2238
2379
|
options: ((_b = forestryField2.config) == null ? void 0 : _b.options) || []
|
|
2239
|
-
}
|
|
2380
|
+
};
|
|
2240
2381
|
} else {
|
|
2241
|
-
logger.info(
|
|
2382
|
+
logger.info(
|
|
2383
|
+
warnText(
|
|
2384
|
+
`Warning in template ${template}.yaml . "select" field migration has only been implemented for simple select. Other versions of select have not been implemented yet. To make your \`${forestryField2.name}\` field work, you will need to manually add it to your schema.`
|
|
2385
|
+
)
|
|
2386
|
+
);
|
|
2242
2387
|
}
|
|
2243
2388
|
break;
|
|
2244
2389
|
case "list":
|
|
2245
|
-
field =
|
|
2246
|
-
type: "string"
|
|
2247
|
-
|
|
2390
|
+
field = {
|
|
2391
|
+
type: "string",
|
|
2392
|
+
...getTinaFieldsFromName(forestryField2.name),
|
|
2248
2393
|
label: forestryField2.label,
|
|
2249
2394
|
list: true
|
|
2250
|
-
}
|
|
2395
|
+
};
|
|
2251
2396
|
if ((_c = forestryField2.config) == null ? void 0 : _c.options) {
|
|
2252
2397
|
field.options = forestryField2.config.options;
|
|
2253
2398
|
}
|
|
2254
2399
|
break;
|
|
2255
2400
|
case "tag_list":
|
|
2256
|
-
field =
|
|
2257
|
-
type: "string"
|
|
2258
|
-
|
|
2401
|
+
field = {
|
|
2402
|
+
type: "string",
|
|
2403
|
+
...getTinaFieldsFromName(forestryField2.name),
|
|
2259
2404
|
label: forestryField2.label,
|
|
2260
2405
|
list: true,
|
|
2261
2406
|
ui: {
|
|
2262
2407
|
component: "tags"
|
|
2263
2408
|
}
|
|
2264
|
-
}
|
|
2409
|
+
};
|
|
2265
2410
|
break;
|
|
2266
2411
|
case "field_group":
|
|
2267
|
-
field =
|
|
2268
|
-
type: "object"
|
|
2269
|
-
|
|
2412
|
+
field = {
|
|
2413
|
+
type: "object",
|
|
2414
|
+
...getTinaFieldsFromName(forestryField2.name),
|
|
2270
2415
|
label: forestryField2.label,
|
|
2271
2416
|
fields: transformForestryFieldsToTinaFields({
|
|
2272
2417
|
fields: forestryField2.fields,
|
|
@@ -2274,12 +2419,12 @@ var transformForestryFieldsToTinaFields = ({
|
|
|
2274
2419
|
template,
|
|
2275
2420
|
skipBlocks
|
|
2276
2421
|
})
|
|
2277
|
-
}
|
|
2422
|
+
};
|
|
2278
2423
|
break;
|
|
2279
2424
|
case "field_group_list":
|
|
2280
|
-
field =
|
|
2281
|
-
type: "object"
|
|
2282
|
-
|
|
2425
|
+
field = {
|
|
2426
|
+
type: "object",
|
|
2427
|
+
...getTinaFieldsFromName(forestryField2.name),
|
|
2283
2428
|
label: forestryField2.label,
|
|
2284
2429
|
list: true,
|
|
2285
2430
|
fields: transformForestryFieldsToTinaFields({
|
|
@@ -2288,7 +2433,7 @@ var transformForestryFieldsToTinaFields = ({
|
|
|
2288
2433
|
rootPath: rootPath2,
|
|
2289
2434
|
skipBlocks
|
|
2290
2435
|
})
|
|
2291
|
-
}
|
|
2436
|
+
};
|
|
2292
2437
|
break;
|
|
2293
2438
|
case "blocks":
|
|
2294
2439
|
if (skipBlocks)
|
|
@@ -2307,24 +2452,32 @@ var transformForestryFieldsToTinaFields = ({
|
|
|
2307
2452
|
};
|
|
2308
2453
|
templates.push(t);
|
|
2309
2454
|
});
|
|
2310
|
-
field =
|
|
2455
|
+
field = {
|
|
2311
2456
|
type: "object",
|
|
2312
2457
|
list: true,
|
|
2313
|
-
label: forestryField2.label
|
|
2314
|
-
|
|
2458
|
+
label: forestryField2.label,
|
|
2459
|
+
...getTinaFieldsFromName(forestryField2.name),
|
|
2315
2460
|
templates
|
|
2316
|
-
}
|
|
2461
|
+
};
|
|
2317
2462
|
break;
|
|
2318
2463
|
case "image_gallery":
|
|
2319
2464
|
case "include":
|
|
2320
|
-
logger.info(
|
|
2465
|
+
logger.info(
|
|
2466
|
+
warnText(
|
|
2467
|
+
`Unsupported field type: ${forestryField2.type}, in forestry ${template}. This will not be added to the schema.`
|
|
2468
|
+
)
|
|
2469
|
+
);
|
|
2321
2470
|
break;
|
|
2322
2471
|
default:
|
|
2323
|
-
logger.info(
|
|
2472
|
+
logger.info(
|
|
2473
|
+
warnText(
|
|
2474
|
+
`Warning in template ${template}. "${forestryField2.type}" migration has not been implemented yet. To make your \`${forestryField2.name}\` field work, you will need to manually add it to your schema.`
|
|
2475
|
+
)
|
|
2476
|
+
);
|
|
2324
2477
|
}
|
|
2325
2478
|
if (field) {
|
|
2326
2479
|
if ((_d = forestryField2.config) == null ? void 0 : _d.required) {
|
|
2327
|
-
field =
|
|
2480
|
+
field = { ...field, required: true };
|
|
2328
2481
|
}
|
|
2329
2482
|
tinaFields.push(field);
|
|
2330
2483
|
}
|
|
@@ -2332,14 +2485,22 @@ var transformForestryFieldsToTinaFields = ({
|
|
|
2332
2485
|
return tinaFields;
|
|
2333
2486
|
};
|
|
2334
2487
|
var getFieldsFromTemplates = ({ tem, rootPath: rootPath2, skipBlocks = false }) => {
|
|
2335
|
-
const templatePath =
|
|
2488
|
+
const templatePath = import_path9.default.join(
|
|
2489
|
+
rootPath2,
|
|
2490
|
+
".forestry",
|
|
2491
|
+
"front_matter",
|
|
2492
|
+
"templates",
|
|
2493
|
+
`${tem}.yml`
|
|
2494
|
+
);
|
|
2336
2495
|
let templateString = "";
|
|
2337
2496
|
try {
|
|
2338
2497
|
templateString = import_fs_extra7.default.readFileSync(templatePath).toString();
|
|
2339
2498
|
} catch {
|
|
2340
|
-
throw new Error(
|
|
2499
|
+
throw new Error(
|
|
2500
|
+
`Could not find template ${tem} at ${templatePath}
|
|
2341
2501
|
|
|
2342
|
-
This will require manual migration.`
|
|
2502
|
+
This will require manual migration.`
|
|
2503
|
+
);
|
|
2343
2504
|
}
|
|
2344
2505
|
const templateObj = import_js_yaml.default.load(templateString);
|
|
2345
2506
|
const template = parseTemplates({ val: templateObj });
|
|
@@ -2356,7 +2517,7 @@ var parseTemplates = ({ val }) => {
|
|
|
2356
2517
|
return template;
|
|
2357
2518
|
};
|
|
2358
2519
|
var hasForestryConfig = async ({ rootPath: rootPath2 }) => {
|
|
2359
|
-
const forestryPath =
|
|
2520
|
+
const forestryPath = import_path9.default.join(rootPath2, ".forestry", "settings.yml");
|
|
2360
2521
|
const exists = await import_fs_extra7.default.pathExists(forestryPath);
|
|
2361
2522
|
return {
|
|
2362
2523
|
path: forestryPath,
|
|
@@ -2369,11 +2530,11 @@ var parseSections = ({ val }) => {
|
|
|
2369
2530
|
};
|
|
2370
2531
|
|
|
2371
2532
|
// src/cmds/forestry-migrate/index.ts
|
|
2372
|
-
var import_fs_extra8 =
|
|
2373
|
-
var
|
|
2374
|
-
var import_js_yaml2 =
|
|
2375
|
-
var import_minimatch =
|
|
2376
|
-
var import_graphql10 =
|
|
2533
|
+
var import_fs_extra8 = __toESM(require("fs-extra"));
|
|
2534
|
+
var import_path10 = __toESM(require("path"));
|
|
2535
|
+
var import_js_yaml2 = __toESM(require("js-yaml"));
|
|
2536
|
+
var import_minimatch = __toESM(require("minimatch"));
|
|
2537
|
+
var import_graphql10 = require("@tinacms/graphql");
|
|
2377
2538
|
var BODY_FIELD = {
|
|
2378
2539
|
type: "rich-text",
|
|
2379
2540
|
name: "body",
|
|
@@ -2387,8 +2548,10 @@ var stringifyLabel = (label) => {
|
|
|
2387
2548
|
var generateAllCollections = async ({
|
|
2388
2549
|
rootPath: rootPath2
|
|
2389
2550
|
}) => {
|
|
2390
|
-
const allTemplates = (await import_fs_extra8.default.readdir(
|
|
2391
|
-
|
|
2551
|
+
const allTemplates = (await import_fs_extra8.default.readdir(
|
|
2552
|
+
import_path10.default.join(rootPath2, ".forestry", "front_matter", "templates")
|
|
2553
|
+
)).map((tem) => import_path10.default.basename(tem, ".yml"));
|
|
2554
|
+
const templateMap = /* @__PURE__ */ new Map();
|
|
2392
2555
|
const proms = allTemplates.map(async (tem) => {
|
|
2393
2556
|
try {
|
|
2394
2557
|
const { fields, templateObj } = getFieldsFromTemplates({
|
|
@@ -2427,7 +2590,9 @@ var generateCollections = async ({
|
|
|
2427
2590
|
const { templateObj } = templateMap.get(templateKey);
|
|
2428
2591
|
const pages = templateObj == null ? void 0 : templateObj.pages;
|
|
2429
2592
|
if (pages) {
|
|
2430
|
-
if (pages.some(
|
|
2593
|
+
if (pages.some(
|
|
2594
|
+
(page) => (0, import_minimatch.default)(page, section.path + "/" + section.match)
|
|
2595
|
+
)) {
|
|
2431
2596
|
forestryTemplates.push(templateKey);
|
|
2432
2597
|
}
|
|
2433
2598
|
}
|
|
@@ -2446,14 +2611,22 @@ var generateCollections = async ({
|
|
|
2446
2611
|
});
|
|
2447
2612
|
(_a = templateObj == null ? void 0 : templateObj.pages) == null ? void 0 : _a.forEach((page) => {
|
|
2448
2613
|
try {
|
|
2449
|
-
const filePath =
|
|
2450
|
-
const
|
|
2614
|
+
const filePath = import_path10.default.join(rootPath2, page);
|
|
2615
|
+
const extname = import_path10.default.extname(filePath);
|
|
2451
2616
|
const fileContent = import_fs_extra8.default.readFileSync(filePath).toString();
|
|
2452
|
-
const content2 = (0, import_graphql10.parseFile)(
|
|
2453
|
-
|
|
2454
|
-
|
|
2455
|
-
|
|
2456
|
-
|
|
2617
|
+
const content2 = (0, import_graphql10.parseFile)(
|
|
2618
|
+
fileContent,
|
|
2619
|
+
extname,
|
|
2620
|
+
(yup) => yup.object({})
|
|
2621
|
+
);
|
|
2622
|
+
const newContent = {
|
|
2623
|
+
_template: stringifyLabel(tem),
|
|
2624
|
+
...content2
|
|
2625
|
+
};
|
|
2626
|
+
import_fs_extra8.default.writeFileSync(
|
|
2627
|
+
filePath,
|
|
2628
|
+
(0, import_graphql10.stringifyFile)(newContent, extname, true)
|
|
2629
|
+
);
|
|
2457
2630
|
} catch (error) {
|
|
2458
2631
|
console.log("Error updating file", page);
|
|
2459
2632
|
}
|
|
@@ -2470,11 +2643,12 @@ var generateCollections = async ({
|
|
|
2470
2643
|
templates
|
|
2471
2644
|
};
|
|
2472
2645
|
if ((section == null ? void 0 : section.create) === "none") {
|
|
2473
|
-
c.ui =
|
|
2646
|
+
c.ui = {
|
|
2647
|
+
...c.ui,
|
|
2474
2648
|
allowedActions: {
|
|
2475
2649
|
create: false
|
|
2476
2650
|
}
|
|
2477
|
-
}
|
|
2651
|
+
};
|
|
2478
2652
|
}
|
|
2479
2653
|
collections.push(c);
|
|
2480
2654
|
} else {
|
|
@@ -2486,14 +2660,22 @@ var generateCollections = async ({
|
|
|
2486
2660
|
fields.push(...additionalFields);
|
|
2487
2661
|
(_a = templateObj == null ? void 0 : templateObj.pages) == null ? void 0 : _a.forEach((page) => {
|
|
2488
2662
|
try {
|
|
2489
|
-
const filePath =
|
|
2490
|
-
const
|
|
2663
|
+
const filePath = import_path10.default.join(rootPath2, page);
|
|
2664
|
+
const extname = import_path10.default.extname(filePath);
|
|
2491
2665
|
const fileContent = import_fs_extra8.default.readFileSync(filePath).toString();
|
|
2492
|
-
const content2 = (0, import_graphql10.parseFile)(
|
|
2493
|
-
|
|
2494
|
-
|
|
2495
|
-
|
|
2496
|
-
|
|
2666
|
+
const content2 = (0, import_graphql10.parseFile)(
|
|
2667
|
+
fileContent,
|
|
2668
|
+
extname,
|
|
2669
|
+
(yup) => yup.object({})
|
|
2670
|
+
);
|
|
2671
|
+
const newContent = {
|
|
2672
|
+
_template: stringifyLabel(tem),
|
|
2673
|
+
...content2
|
|
2674
|
+
};
|
|
2675
|
+
import_fs_extra8.default.writeFileSync(
|
|
2676
|
+
filePath,
|
|
2677
|
+
(0, import_graphql10.stringifyFile)(newContent, extname, true)
|
|
2678
|
+
);
|
|
2497
2679
|
} catch (error) {
|
|
2498
2680
|
logger.log("Error updating file", page);
|
|
2499
2681
|
}
|
|
@@ -2510,17 +2692,22 @@ var generateCollections = async ({
|
|
|
2510
2692
|
fields
|
|
2511
2693
|
};
|
|
2512
2694
|
if ((section == null ? void 0 : section.create) === "none") {
|
|
2513
|
-
c.ui =
|
|
2695
|
+
c.ui = {
|
|
2696
|
+
...c.ui,
|
|
2514
2697
|
allowedActions: {
|
|
2515
2698
|
create: false
|
|
2516
2699
|
}
|
|
2517
|
-
}
|
|
2700
|
+
};
|
|
2518
2701
|
}
|
|
2519
2702
|
collections.push(c);
|
|
2520
2703
|
}
|
|
2521
2704
|
break;
|
|
2522
2705
|
case "document":
|
|
2523
|
-
console.log(
|
|
2706
|
+
console.log(
|
|
2707
|
+
warnText(
|
|
2708
|
+
`Single Document are not supported in TinaCMS yet. Skipping section ${section.label} (${section.path})`
|
|
2709
|
+
)
|
|
2710
|
+
);
|
|
2524
2711
|
break;
|
|
2525
2712
|
}
|
|
2526
2713
|
}
|
|
@@ -2595,7 +2782,9 @@ var chooseClientId = async () => {
|
|
|
2595
2782
|
name: "clientId",
|
|
2596
2783
|
type: "text",
|
|
2597
2784
|
message: `What is your Tina Cloud Client ID? (Hit enter to skip and set up yourself later)
|
|
2598
|
-
${logText(
|
|
2785
|
+
${logText(
|
|
2786
|
+
"Don't have a Client ID? Create one here: "
|
|
2787
|
+
)}${linkText("https://app.tina.io/projects/new")}`
|
|
2599
2788
|
});
|
|
2600
2789
|
return option["clientId"];
|
|
2601
2790
|
};
|
|
@@ -2604,7 +2793,9 @@ var chooseToken = async ({ clientId }) => {
|
|
|
2604
2793
|
name: "token",
|
|
2605
2794
|
type: "text",
|
|
2606
2795
|
message: `What is your Tina Cloud Read Only Token?
|
|
2607
|
-
${logText(
|
|
2796
|
+
${logText(
|
|
2797
|
+
"Don't have a Read Only Token? Create one here: "
|
|
2798
|
+
)}${linkText(`https://app.tina.io/projects/${clientId}/tokens`)}`
|
|
2608
2799
|
});
|
|
2609
2800
|
return option["token"];
|
|
2610
2801
|
};
|
|
@@ -2645,7 +2836,11 @@ var choosePublicFolder = async ({ framework }) => {
|
|
|
2645
2836
|
name: "selection",
|
|
2646
2837
|
type: "text",
|
|
2647
2838
|
message: `Where are public assets stored? (default: "${suggestion}")
|
|
2648
|
-
` + logText(
|
|
2839
|
+
` + logText(
|
|
2840
|
+
`Not sure what value to use? Refer to our "Frameworks" doc: ${linkText(
|
|
2841
|
+
"https://tina.io/docs/integration/frameworks/#configuring-tina-with-each-framework"
|
|
2842
|
+
)}`
|
|
2843
|
+
)
|
|
2649
2844
|
});
|
|
2650
2845
|
return option["selection"] || suggestion;
|
|
2651
2846
|
};
|
|
@@ -2670,15 +2865,25 @@ var forestryMigrate = async ({
|
|
|
2670
2865
|
forestryPath,
|
|
2671
2866
|
rootPath: rootPath2
|
|
2672
2867
|
}) => {
|
|
2673
|
-
logger.info(
|
|
2674
|
-
|
|
2868
|
+
logger.info(
|
|
2869
|
+
`It looks like you have a ${focusText(
|
|
2870
|
+
".forestry/settings.yml"
|
|
2871
|
+
)} file in your project.`
|
|
2872
|
+
);
|
|
2873
|
+
logger.info(
|
|
2874
|
+
`This migration will update some of your content to match tina. Please ${focusText(
|
|
2875
|
+
"save a backup of your content"
|
|
2876
|
+
)} before doing this migration. (This can be done with git)`
|
|
2877
|
+
);
|
|
2675
2878
|
const option = await (0, import_prompts2.default)({
|
|
2676
2879
|
name: "selection",
|
|
2677
2880
|
type: "confirm",
|
|
2678
2881
|
initial: true,
|
|
2679
2882
|
message: `Please note that this is a beta version and may contain some issues
|
|
2680
2883
|
Would you like to migrate your Forestry templates?
|
|
2681
|
-
${logText(
|
|
2884
|
+
${logText(
|
|
2885
|
+
"Note: This migration will not be perfect, but it will get you started."
|
|
2886
|
+
)}`
|
|
2682
2887
|
});
|
|
2683
2888
|
if (!option["selection"]) {
|
|
2684
2889
|
return null;
|
|
@@ -2721,22 +2926,22 @@ var createPackageJSON = async () => {
|
|
|
2721
2926
|
};
|
|
2722
2927
|
var createGitignore = async ({ baseDir }) => {
|
|
2723
2928
|
logger.info(logText("No .gitignore found, creating one"));
|
|
2724
|
-
await import_fs_extra9.default.outputFileSync(
|
|
2929
|
+
await import_fs_extra9.default.outputFileSync(import_path11.default.join(baseDir, ".gitignore"), "node_modules");
|
|
2725
2930
|
};
|
|
2726
2931
|
var checkGitignoreForNodeModules = async ({
|
|
2727
2932
|
baseDir
|
|
2728
2933
|
}) => {
|
|
2729
|
-
const gitignoreContent = await import_fs_extra9.default.readFileSync(
|
|
2934
|
+
const gitignoreContent = await import_fs_extra9.default.readFileSync(import_path11.default.join(baseDir, ".gitignore")).toString();
|
|
2730
2935
|
return gitignoreContent.split("\n").some((item) => item === "node_modules");
|
|
2731
2936
|
};
|
|
2732
2937
|
var addNodeModulesToGitignore = async ({ baseDir }) => {
|
|
2733
2938
|
logger.info(logText("Adding node_modules to .gitignore"));
|
|
2734
|
-
const gitignoreContent = await import_fs_extra9.default.readFileSync(
|
|
2939
|
+
const gitignoreContent = await import_fs_extra9.default.readFileSync(import_path11.default.join(baseDir, ".gitignore")).toString();
|
|
2735
2940
|
const newGitignoreContent = [
|
|
2736
2941
|
...gitignoreContent.split("\n"),
|
|
2737
2942
|
"node_modules"
|
|
2738
2943
|
].join("\n");
|
|
2739
|
-
await import_fs_extra9.default.writeFileSync(
|
|
2944
|
+
await import_fs_extra9.default.writeFileSync(import_path11.default.join(baseDir, ".gitignore"), newGitignoreContent);
|
|
2740
2945
|
};
|
|
2741
2946
|
var addDependencies = async (packageManager) => {
|
|
2742
2947
|
logger.info(logText("Adding dependencies, this might take a moment..."));
|
|
@@ -2751,8 +2956,11 @@ var addDependencies = async (packageManager) => {
|
|
|
2751
2956
|
};
|
|
2752
2957
|
var addConfigFile = async (args) => {
|
|
2753
2958
|
const { baseDir, usingTypescript } = args;
|
|
2754
|
-
const configPath =
|
|
2755
|
-
|
|
2959
|
+
const configPath = import_path11.default.join(
|
|
2960
|
+
".tina",
|
|
2961
|
+
`config.${usingTypescript ? "ts" : "js"}`
|
|
2962
|
+
);
|
|
2963
|
+
const fullConfigPath = import_path11.default.join(baseDir, configPath);
|
|
2756
2964
|
if (import_fs_extra9.default.pathExistsSync(fullConfigPath)) {
|
|
2757
2965
|
const override = await (0, import_prompts2.default)({
|
|
2758
2966
|
name: "selection",
|
|
@@ -2766,13 +2974,17 @@ var addConfigFile = async (args) => {
|
|
|
2766
2974
|
logger.info(logText(`Not overriding file at ${configPath}.`));
|
|
2767
2975
|
}
|
|
2768
2976
|
} else {
|
|
2769
|
-
logger.info(
|
|
2977
|
+
logger.info(
|
|
2978
|
+
logText(
|
|
2979
|
+
`Adding config file at .tina/config.${usingTypescript ? "ts" : "js"}`
|
|
2980
|
+
)
|
|
2981
|
+
);
|
|
2770
2982
|
await import_fs_extra9.default.outputFileSync(fullConfigPath, config(args));
|
|
2771
2983
|
}
|
|
2772
2984
|
};
|
|
2773
2985
|
var addContentFile = async ({ baseDir }) => {
|
|
2774
|
-
const contentPath =
|
|
2775
|
-
const fullContentPath =
|
|
2986
|
+
const contentPath = import_path11.default.join("content", "posts", "hello-world.md");
|
|
2987
|
+
const fullContentPath = import_path11.default.join(baseDir, contentPath);
|
|
2776
2988
|
if (import_fs_extra9.default.pathExistsSync(fullContentPath)) {
|
|
2777
2989
|
const override = await (0, import_prompts2.default)({
|
|
2778
2990
|
name: "selection",
|
|
@@ -2796,9 +3008,15 @@ var logNextSteps = ({
|
|
|
2796
3008
|
}) => {
|
|
2797
3009
|
logger.info(focusText(`
|
|
2798
3010
|
${titleText(" TinaCMS ")} has been initialized!`));
|
|
2799
|
-
logger.info(
|
|
2800
|
-
|
|
2801
|
-
|
|
3011
|
+
logger.info(
|
|
3012
|
+
"To get started run: " + cmdText(frameworkDevCmds[framework.name]({ packageManager }))
|
|
3013
|
+
);
|
|
3014
|
+
logger.info(
|
|
3015
|
+
`
|
|
3016
|
+
Once your site is running, access the CMS at ${linkText(
|
|
3017
|
+
"<YourDevURL>/admin/index.html"
|
|
3018
|
+
)}`
|
|
3019
|
+
);
|
|
2802
3020
|
};
|
|
2803
3021
|
var other2 = ({ packageManager }) => {
|
|
2804
3022
|
const packageManagers = {
|
|
@@ -2841,11 +3059,14 @@ var addReactiveFile = {
|
|
|
2841
3059
|
baseDir,
|
|
2842
3060
|
usingTypescript
|
|
2843
3061
|
}) => {
|
|
2844
|
-
const usingSrc = !import_fs_extra9.default.pathExistsSync(
|
|
2845
|
-
const pagesPath =
|
|
2846
|
-
const packageJSONPath =
|
|
2847
|
-
const tinaBlogPagePath =
|
|
2848
|
-
const tinaBlogPagePathFile =
|
|
3062
|
+
const usingSrc = !import_fs_extra9.default.pathExistsSync(import_path11.default.join(baseDir, "pages"));
|
|
3063
|
+
const pagesPath = import_path11.default.join(baseDir, usingSrc ? "src" : "", "pages");
|
|
3064
|
+
const packageJSONPath = import_path11.default.join(baseDir, "package.json");
|
|
3065
|
+
const tinaBlogPagePath = import_path11.default.join(pagesPath, "demo", "blog");
|
|
3066
|
+
const tinaBlogPagePathFile = import_path11.default.join(
|
|
3067
|
+
tinaBlogPagePath,
|
|
3068
|
+
`[filename].${usingTypescript ? "tsx" : "js"}`
|
|
3069
|
+
);
|
|
2849
3070
|
if (!import_fs_extra9.default.pathExistsSync(tinaBlogPagePathFile)) {
|
|
2850
3071
|
import_fs_extra9.default.mkdirpSync(tinaBlogPagePath);
|
|
2851
3072
|
import_fs_extra9.default.writeFileSync(tinaBlogPagePathFile, nextPostPage({ usingSrc }));
|
|
@@ -2853,9 +3074,14 @@ var addReactiveFile = {
|
|
|
2853
3074
|
logger.info("Adding a nextjs example... \u2705");
|
|
2854
3075
|
const pack = JSON.parse(import_fs_extra9.default.readFileSync(packageJSONPath).toString());
|
|
2855
3076
|
const oldScripts = pack.scripts || {};
|
|
2856
|
-
const newPack = JSON.stringify(
|
|
2857
|
-
|
|
2858
|
-
|
|
3077
|
+
const newPack = JSON.stringify(
|
|
3078
|
+
{
|
|
3079
|
+
...pack,
|
|
3080
|
+
scripts: extendNextScripts(oldScripts)
|
|
3081
|
+
},
|
|
3082
|
+
null,
|
|
3083
|
+
2
|
|
3084
|
+
);
|
|
2859
3085
|
import_fs_extra9.default.writeFileSync(packageJSONPath, newPack);
|
|
2860
3086
|
}
|
|
2861
3087
|
};
|
|
@@ -2872,25 +3098,27 @@ function execShellCommand(cmd) {
|
|
|
2872
3098
|
}
|
|
2873
3099
|
|
|
2874
3100
|
// src/buildTina/attachDatabase.ts
|
|
2875
|
-
var
|
|
2876
|
-
var import_datalayer2 =
|
|
2877
|
-
var import_graphql11 =
|
|
2878
|
-
var import_fs_extra11 =
|
|
3101
|
+
var path10 = __toESM(require("path"));
|
|
3102
|
+
var import_datalayer2 = require("@tinacms/datalayer");
|
|
3103
|
+
var import_graphql11 = require("@tinacms/graphql");
|
|
3104
|
+
var import_fs_extra11 = __toESM(require("fs-extra"));
|
|
2879
3105
|
|
|
2880
3106
|
// src/buildTina/git.ts
|
|
2881
|
-
var import_fs_extra10 =
|
|
2882
|
-
var import_ini =
|
|
2883
|
-
var import_os =
|
|
2884
|
-
var
|
|
3107
|
+
var import_fs_extra10 = __toESM(require("fs-extra"));
|
|
3108
|
+
var import_ini = __toESM(require("ini"));
|
|
3109
|
+
var import_os = __toESM(require("os"));
|
|
3110
|
+
var import_path12 = __toESM(require("path"));
|
|
2885
3111
|
var resolveGitRoot = async () => {
|
|
2886
|
-
const pathParts = process.cwd().split(
|
|
3112
|
+
const pathParts = process.cwd().split(import_path12.default.sep);
|
|
2887
3113
|
while (true) {
|
|
2888
|
-
const pathToGit = pathParts.join(
|
|
2889
|
-
if (await import_fs_extra10.default.pathExists(
|
|
3114
|
+
const pathToGit = pathParts.join(import_path12.default.sep);
|
|
3115
|
+
if (await import_fs_extra10.default.pathExists(import_path12.default.join(pathToGit, ".git"))) {
|
|
2890
3116
|
return pathToGit;
|
|
2891
3117
|
}
|
|
2892
3118
|
if (!pathParts.length) {
|
|
2893
|
-
throw new Error(
|
|
3119
|
+
throw new Error(
|
|
3120
|
+
"Unable to locate your .git folder (required for isomorphicGitBridge)"
|
|
3121
|
+
);
|
|
2894
3122
|
}
|
|
2895
3123
|
pathParts.pop();
|
|
2896
3124
|
}
|
|
@@ -2911,7 +3139,7 @@ async function makeIsomorphicOptions(fsBridge) {
|
|
|
2911
3139
|
await fsBridge.delete(filepath);
|
|
2912
3140
|
}
|
|
2913
3141
|
};
|
|
2914
|
-
const userGitConfig = `${import_os.default.homedir()}${
|
|
3142
|
+
const userGitConfig = `${import_os.default.homedir()}${import_path12.default.sep}.gitconfig`;
|
|
2915
3143
|
if (await import_fs_extra10.default.pathExists(userGitConfig)) {
|
|
2916
3144
|
const config2 = import_ini.default.parse(await import_fs_extra10.default.readFile(userGitConfig, "utf-8"));
|
|
2917
3145
|
if ((_a = config2["user"]) == null ? void 0 : _a["name"]) {
|
|
@@ -2923,12 +3151,16 @@ async function makeIsomorphicOptions(fsBridge) {
|
|
|
2923
3151
|
}
|
|
2924
3152
|
let repoGitConfig = void 0;
|
|
2925
3153
|
if (!options.author.name) {
|
|
2926
|
-
repoGitConfig = import_ini.default.parse(
|
|
3154
|
+
repoGitConfig = import_ini.default.parse(
|
|
3155
|
+
await import_fs_extra10.default.readFile(`${gitRoot}/.git/config`, "utf-8")
|
|
3156
|
+
);
|
|
2927
3157
|
if ((_c = repoGitConfig["user"]) == null ? void 0 : _c["name"]) {
|
|
2928
3158
|
options.author.name = repoGitConfig["user"]["name"];
|
|
2929
3159
|
}
|
|
2930
3160
|
if (!options.author.name) {
|
|
2931
|
-
throw new Error(
|
|
3161
|
+
throw new Error(
|
|
3162
|
+
'Unable to determine user.name from git config. Hint: `git config --global user.name "John Doe"`'
|
|
3163
|
+
);
|
|
2932
3164
|
}
|
|
2933
3165
|
}
|
|
2934
3166
|
if (!options.author.email) {
|
|
@@ -2937,34 +3169,38 @@ async function makeIsomorphicOptions(fsBridge) {
|
|
|
2937
3169
|
options.author.email = repoGitConfig["user"]["email"];
|
|
2938
3170
|
}
|
|
2939
3171
|
if (!options.author.email) {
|
|
2940
|
-
throw new Error(
|
|
3172
|
+
throw new Error(
|
|
3173
|
+
"Unable to determine user.email from git config. Hint: `git config --global user.email johndoe@example.com`"
|
|
3174
|
+
);
|
|
2941
3175
|
}
|
|
2942
3176
|
}
|
|
2943
3177
|
return options;
|
|
2944
3178
|
}
|
|
2945
3179
|
|
|
2946
3180
|
// src/buildTina/attachDatabase.ts
|
|
2947
|
-
var import_memory_level2 =
|
|
2948
|
-
var import_many_level =
|
|
2949
|
-
var import_readable_stream =
|
|
2950
|
-
var import_net =
|
|
3181
|
+
var import_memory_level2 = require("memory-level");
|
|
3182
|
+
var import_many_level = require("many-level");
|
|
3183
|
+
var import_readable_stream = require("readable-stream");
|
|
3184
|
+
var import_net = require("net");
|
|
2951
3185
|
var attachDatabase = async (ctx, next, _options) => {
|
|
2952
|
-
const tinaPath =
|
|
2953
|
-
const tinaGeneratedPath =
|
|
2954
|
-
const tinaTempPath =
|
|
3186
|
+
const tinaPath = path10.join(ctx.rootPath, ".tina");
|
|
3187
|
+
const tinaGeneratedPath = path10.join(tinaPath, "__generated__");
|
|
3188
|
+
const tinaTempPath = path10.join(tinaGeneratedPath, `temp_database`);
|
|
2955
3189
|
const define = {};
|
|
2956
3190
|
if (!process.env.NODE_ENV) {
|
|
2957
3191
|
define["process.env.NODE_ENV"] = _options.dev ? '"development"' : '"production"';
|
|
2958
3192
|
}
|
|
2959
3193
|
const inputFile = getPath({
|
|
2960
|
-
projectDir:
|
|
3194
|
+
projectDir: path10.join(ctx.rootPath, ".tina"),
|
|
2961
3195
|
filename: "database",
|
|
2962
3196
|
allowedTypes: ["js", "jsx", "tsx", "ts"]
|
|
2963
3197
|
});
|
|
2964
3198
|
const fsBridge = new import_datalayer2.FilesystemBridge(ctx.rootPath);
|
|
2965
|
-
const levelHost = new import_many_level.ManyLevelHost(
|
|
2966
|
-
|
|
2967
|
-
|
|
3199
|
+
const levelHost = new import_many_level.ManyLevelHost(
|
|
3200
|
+
new import_memory_level2.MemoryLevel({
|
|
3201
|
+
valueEncoding: "json"
|
|
3202
|
+
})
|
|
3203
|
+
);
|
|
2968
3204
|
const server = (0, import_net.createServer)(function(socket) {
|
|
2969
3205
|
(0, import_readable_stream.pipeline)(socket, levelHost.createRpcStream(), socket, () => {
|
|
2970
3206
|
});
|
|
@@ -2973,7 +3209,15 @@ var attachDatabase = async (ctx, next, _options) => {
|
|
|
2973
3209
|
ctx.dbServer = server;
|
|
2974
3210
|
if (inputFile) {
|
|
2975
3211
|
try {
|
|
2976
|
-
await transpile(
|
|
3212
|
+
await transpile(
|
|
3213
|
+
inputFile,
|
|
3214
|
+
"database.cjs",
|
|
3215
|
+
tinaTempPath,
|
|
3216
|
+
_options.verbose,
|
|
3217
|
+
define,
|
|
3218
|
+
path10.join(ctx.rootPath, "package.json"),
|
|
3219
|
+
"node"
|
|
3220
|
+
);
|
|
2977
3221
|
} catch (e) {
|
|
2978
3222
|
await import_fs_extra11.default.remove(tinaTempPath);
|
|
2979
3223
|
throw new BuildSchemaError(e);
|
|
@@ -2984,7 +3228,7 @@ var attachDatabase = async (ctx, next, _options) => {
|
|
|
2984
3228
|
}
|
|
2985
3229
|
});
|
|
2986
3230
|
try {
|
|
2987
|
-
const databaseFunc = require(
|
|
3231
|
+
const databaseFunc = require(path10.join(tinaTempPath, `database.cjs`));
|
|
2988
3232
|
ctx.database = databaseFunc.default;
|
|
2989
3233
|
ctx.database.bridge = fsBridge;
|
|
2990
3234
|
ctx.bridge = ctx.database.bridge;
|
|
@@ -2995,7 +3239,10 @@ var attachDatabase = async (ctx, next, _options) => {
|
|
|
2995
3239
|
throw e;
|
|
2996
3240
|
}
|
|
2997
3241
|
} else {
|
|
2998
|
-
const bridge = _options.isomorphicGitBridge ? new import_datalayer2.IsomorphicBridge(
|
|
3242
|
+
const bridge = _options.isomorphicGitBridge ? new import_datalayer2.IsomorphicBridge(
|
|
3243
|
+
ctx.rootPath,
|
|
3244
|
+
_options.isomorphicGitBridge && await makeIsomorphicOptions(fsBridge)
|
|
3245
|
+
) : fsBridge;
|
|
2999
3246
|
const level = new import_graphql11.TinaLevelClient();
|
|
3000
3247
|
level.openConnection();
|
|
3001
3248
|
ctx.database = await (0, import_graphql11.createDatabase)({ level, bridge });
|
|
@@ -3005,10 +3252,10 @@ var attachDatabase = async (ctx, next, _options) => {
|
|
|
3005
3252
|
};
|
|
3006
3253
|
|
|
3007
3254
|
// src/cmds/statusChecks/checkClientInformation.ts
|
|
3008
|
-
var import_progress2 =
|
|
3009
|
-
var import_graphql12 =
|
|
3010
|
-
var import_core2 =
|
|
3011
|
-
var import_schema_tools2 =
|
|
3255
|
+
var import_progress2 = __toESM(require("progress"));
|
|
3256
|
+
var import_graphql12 = require("graphql");
|
|
3257
|
+
var import_core2 = require("@graphql-inspector/core");
|
|
3258
|
+
var import_schema_tools2 = require("@tinacms/schema-tools");
|
|
3012
3259
|
async function request(args) {
|
|
3013
3260
|
const headers = new Headers();
|
|
3014
3261
|
if (args.token) {
|
|
@@ -3032,13 +3279,17 @@ async function request(args) {
|
|
|
3032
3279
|
|
|
3033
3280
|
Message from server: ${json.message}`;
|
|
3034
3281
|
}
|
|
3035
|
-
throw new Error(
|
|
3282
|
+
throw new Error(
|
|
3283
|
+
`Server responded with status code ${res.status}, ${res.statusText}. ${additionalInfo ? additionalInfo : ""} Please see our FAQ for more information: https://tina.io/docs/errors/faq/`
|
|
3284
|
+
);
|
|
3036
3285
|
}
|
|
3037
3286
|
if (json.errors) {
|
|
3038
|
-
throw new Error(
|
|
3287
|
+
throw new Error(
|
|
3288
|
+
`Unable to fetch, please see our FAQ for more information: https://tina.io/docs/errors/faq/
|
|
3039
3289
|
|
|
3040
3290
|
Errors:
|
|
3041
|
-
${json.errors.map((error) => error.message).join("\n")}`
|
|
3291
|
+
${json.errors.map((error) => error.message).join("\n")}`
|
|
3292
|
+
);
|
|
3042
3293
|
}
|
|
3043
3294
|
return {
|
|
3044
3295
|
status: json == null ? void 0 : json.status,
|
|
@@ -3067,15 +3318,21 @@ var checkClientInfo = async (ctx, next, _options) => {
|
|
|
3067
3318
|
bar.tick({
|
|
3068
3319
|
prog: "\u274C"
|
|
3069
3320
|
});
|
|
3070
|
-
console.warn(
|
|
3321
|
+
console.warn(
|
|
3322
|
+
`Error when checking client information. You provided
|
|
3071
3323
|
|
|
3072
|
-
${JSON.stringify(
|
|
3073
|
-
|
|
3074
|
-
|
|
3075
|
-
|
|
3076
|
-
|
|
3324
|
+
${JSON.stringify(
|
|
3325
|
+
{
|
|
3326
|
+
branch: config2 == null ? void 0 : config2.branch,
|
|
3327
|
+
clientId: config2 == null ? void 0 : config2.clientId,
|
|
3328
|
+
token: config2 == null ? void 0 : config2.token
|
|
3329
|
+
},
|
|
3330
|
+
null,
|
|
3331
|
+
2
|
|
3332
|
+
)}
|
|
3077
3333
|
|
|
3078
|
-
Please check you have the correct "clientId", "branch" and "token" configured. For more information see https://tina.io/docs/tina-cloud/connecting-site/`
|
|
3334
|
+
Please check you have the correct "clientId", "branch" and "token" configured. For more information see https://tina.io/docs/tina-cloud/connecting-site/`
|
|
3335
|
+
);
|
|
3079
3336
|
throw e;
|
|
3080
3337
|
}
|
|
3081
3338
|
next();
|
|
@@ -3100,7 +3357,10 @@ var fetchRemoteGraphqlSchema = async ({
|
|
|
3100
3357
|
};
|
|
3101
3358
|
var checkGraphqlSchema = async (ctx, next, _options) => {
|
|
3102
3359
|
var _a;
|
|
3103
|
-
const bar = new import_progress2.default(
|
|
3360
|
+
const bar = new import_progress2.default(
|
|
3361
|
+
"Checking local GraphQL Schema matches server. :prog",
|
|
3362
|
+
1
|
|
3363
|
+
);
|
|
3104
3364
|
const config2 = (_a = ctx.schema) == null ? void 0 : _a.config;
|
|
3105
3365
|
const token = config2.token;
|
|
3106
3366
|
const url = ctx.apiUrl;
|
|
@@ -3201,7 +3461,11 @@ var localOption = {
|
|
|
3201
3461
|
};
|
|
3202
3462
|
var checkOptions = async (_ctx, next, options) => {
|
|
3203
3463
|
if (options == null ? void 0 : options.experimentalData) {
|
|
3204
|
-
logger.warn(
|
|
3464
|
+
logger.warn(
|
|
3465
|
+
warnText(
|
|
3466
|
+
"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"
|
|
3467
|
+
)
|
|
3468
|
+
);
|
|
3205
3469
|
}
|
|
3206
3470
|
next();
|
|
3207
3471
|
};
|
|
@@ -3222,18 +3486,25 @@ var baseCmds = [
|
|
|
3222
3486
|
developmentOption,
|
|
3223
3487
|
localOption
|
|
3224
3488
|
],
|
|
3225
|
-
action: (options) => chain(
|
|
3226
|
-
|
|
3227
|
-
|
|
3228
|
-
|
|
3229
|
-
|
|
3230
|
-
|
|
3231
|
-
|
|
3232
|
-
|
|
3233
|
-
|
|
3234
|
-
|
|
3235
|
-
|
|
3236
|
-
|
|
3489
|
+
action: (options) => chain(
|
|
3490
|
+
[
|
|
3491
|
+
attachPath,
|
|
3492
|
+
attachDatabase,
|
|
3493
|
+
async (ctx, next, _2) => {
|
|
3494
|
+
logger.warn(
|
|
3495
|
+
warnText(
|
|
3496
|
+
"server:start will be deprecated in the future, please use `tinacms dev` instead"
|
|
3497
|
+
)
|
|
3498
|
+
);
|
|
3499
|
+
next();
|
|
3500
|
+
},
|
|
3501
|
+
checkOptions,
|
|
3502
|
+
buildSetupCmdServerStart,
|
|
3503
|
+
startServer,
|
|
3504
|
+
startSubprocess
|
|
3505
|
+
],
|
|
3506
|
+
options
|
|
3507
|
+
)
|
|
3237
3508
|
},
|
|
3238
3509
|
{
|
|
3239
3510
|
command: CMD_DEV,
|
|
@@ -3249,14 +3520,17 @@ var baseCmds = [
|
|
|
3249
3520
|
verboseOption,
|
|
3250
3521
|
rootPathOption
|
|
3251
3522
|
],
|
|
3252
|
-
action: (options) => chain(
|
|
3253
|
-
|
|
3254
|
-
|
|
3255
|
-
|
|
3256
|
-
|
|
3257
|
-
|
|
3258
|
-
|
|
3259
|
-
|
|
3523
|
+
action: (options) => chain(
|
|
3524
|
+
[
|
|
3525
|
+
attachPath,
|
|
3526
|
+
attachDatabase,
|
|
3527
|
+
checkOptions,
|
|
3528
|
+
buildSetupCmdServerStart,
|
|
3529
|
+
startServer,
|
|
3530
|
+
startSubprocess
|
|
3531
|
+
],
|
|
3532
|
+
options
|
|
3533
|
+
)
|
|
3260
3534
|
},
|
|
3261
3535
|
{
|
|
3262
3536
|
command: CMD_BUILD,
|
|
@@ -3271,17 +3545,20 @@ var baseCmds = [
|
|
|
3271
3545
|
localOption,
|
|
3272
3546
|
rootPathOption
|
|
3273
3547
|
],
|
|
3274
|
-
action: (options) => chain(
|
|
3275
|
-
|
|
3276
|
-
|
|
3277
|
-
|
|
3278
|
-
|
|
3279
|
-
|
|
3280
|
-
|
|
3281
|
-
|
|
3282
|
-
|
|
3283
|
-
|
|
3284
|
-
|
|
3548
|
+
action: (options) => chain(
|
|
3549
|
+
[
|
|
3550
|
+
attachPath,
|
|
3551
|
+
attachDatabase,
|
|
3552
|
+
checkOptions,
|
|
3553
|
+
buildSetupCmdBuild,
|
|
3554
|
+
buildCmdBuild,
|
|
3555
|
+
checkClientInfo,
|
|
3556
|
+
waitForDB,
|
|
3557
|
+
checkGraphqlSchema,
|
|
3558
|
+
indexIntoSelfHostedDatabase
|
|
3559
|
+
],
|
|
3560
|
+
options
|
|
3561
|
+
)
|
|
3285
3562
|
},
|
|
3286
3563
|
{
|
|
3287
3564
|
command: INIT,
|
|
@@ -3307,18 +3584,23 @@ var baseCmds = [
|
|
|
3307
3584
|
],
|
|
3308
3585
|
command: AUDIT,
|
|
3309
3586
|
description: "Audit your schema and the files to check for errors",
|
|
3310
|
-
action: (options) => chain(
|
|
3311
|
-
|
|
3312
|
-
|
|
3313
|
-
|
|
3314
|
-
|
|
3315
|
-
|
|
3316
|
-
|
|
3317
|
-
|
|
3318
|
-
|
|
3319
|
-
|
|
3320
|
-
|
|
3321
|
-
|
|
3587
|
+
action: (options) => chain(
|
|
3588
|
+
[
|
|
3589
|
+
attachPath,
|
|
3590
|
+
buildSetupCmdAudit,
|
|
3591
|
+
auditCmdBuild,
|
|
3592
|
+
async (_ctx, next) => {
|
|
3593
|
+
logger.level = "info";
|
|
3594
|
+
logger.info(
|
|
3595
|
+
import_chalk4.default.hex("#eb6337").bgWhite("Welcome to tina audit \u{1F999}")
|
|
3596
|
+
);
|
|
3597
|
+
next();
|
|
3598
|
+
},
|
|
3599
|
+
audit,
|
|
3600
|
+
printFinalMessage
|
|
3601
|
+
],
|
|
3602
|
+
options
|
|
3603
|
+
)
|
|
3322
3604
|
}
|
|
3323
3605
|
];
|
|
3324
3606
|
|
|
@@ -3344,7 +3626,9 @@ Examples:
|
|
|
3344
3626
|
command.subCommands.forEach((subcommand, i2) => {
|
|
3345
3627
|
const commandStr = `${subcommand.command}${(subcommand.options || []).length ? optionTag : ""}`;
|
|
3346
3628
|
const padLength = Math.max(...command.subCommands.map((sub) => sub.command.length)) + optionTag.length;
|
|
3347
|
-
logger.info(
|
|
3629
|
+
logger.info(
|
|
3630
|
+
`${commandStr.padEnd(padLength)} ${subcommand.description}`
|
|
3631
|
+
);
|
|
3348
3632
|
});
|
|
3349
3633
|
}
|
|
3350
3634
|
logger.info("");
|
|
@@ -3363,14 +3647,19 @@ async function init(args) {
|
|
|
3363
3647
|
registerCommands(commands);
|
|
3364
3648
|
program.usage("command [options]");
|
|
3365
3649
|
program.on("command:*", function() {
|
|
3366
|
-
logger.error(
|
|
3650
|
+
logger.error(
|
|
3651
|
+
"Invalid command: %s\nSee --help for a list of available commands.",
|
|
3652
|
+
args.join(" ")
|
|
3653
|
+
);
|
|
3367
3654
|
process.exit(1);
|
|
3368
3655
|
});
|
|
3369
3656
|
program.on("--help", function() {
|
|
3370
|
-
logger.info(
|
|
3657
|
+
logger.info(
|
|
3658
|
+
logText(`
|
|
3371
3659
|
You can get help on any command with "-h" or "--help".
|
|
3372
3660
|
e.g: "tinacms server:start --help"
|
|
3373
|
-
`)
|
|
3661
|
+
`)
|
|
3662
|
+
);
|
|
3374
3663
|
});
|
|
3375
3664
|
if (!process.argv.slice(2).length) {
|
|
3376
3665
|
program.help();
|