@tinacms/cli 0.0.0-b23aa0c-20251026220307 → 0.0.0-b24caa7-20251217050102
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/bin/tinacms +12 -6
- package/dist/cmds/forestry-migrate/util/index.d.ts +4 -4
- package/dist/index.js +874 -841
- package/dist/logger/index.d.ts +7 -2
- package/dist/next/codegen/index.d.ts +3 -9
- package/dist/utils/theme.d.ts +10 -30
- package/package.json +10 -12
package/dist/index.js
CHANGED
|
@@ -1,53 +1,20 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name2 in all)
|
|
9
|
-
__defProp(target, name2, { get: all[name2], enumerable: true });
|
|
10
|
-
};
|
|
11
|
-
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
-
for (let key of __getOwnPropNames(from))
|
|
14
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
-
}
|
|
17
|
-
return to;
|
|
18
|
-
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
-
mod
|
|
26
|
-
));
|
|
27
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
-
|
|
29
1
|
// src/index.ts
|
|
30
|
-
|
|
31
|
-
__export(index_exports, {
|
|
32
|
-
default: () => index_default
|
|
33
|
-
});
|
|
34
|
-
module.exports = __toCommonJS(index_exports);
|
|
35
|
-
var import_clipanion8 = require("clipanion");
|
|
2
|
+
import { Cli, Builtins } from "clipanion";
|
|
36
3
|
|
|
37
4
|
// package.json
|
|
38
|
-
var version = "
|
|
5
|
+
var version = "2.0.3";
|
|
39
6
|
|
|
40
7
|
// src/next/commands/dev-command/index.ts
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
8
|
+
import path8 from "path";
|
|
9
|
+
import { FilesystemBridge as FilesystemBridge2, buildSchema } from "@tinacms/graphql";
|
|
10
|
+
import { LocalSearchIndexClient, SearchIndexer } from "@tinacms/search";
|
|
11
|
+
import AsyncLock from "async-lock";
|
|
12
|
+
import chokidar from "chokidar";
|
|
13
|
+
import { Command as Command2, Option as Option2 } from "clipanion";
|
|
14
|
+
import fs7 from "fs-extra";
|
|
48
15
|
|
|
49
16
|
// src/logger/index.ts
|
|
50
|
-
|
|
17
|
+
import chalk from "chalk";
|
|
51
18
|
|
|
52
19
|
// src/logger/is-unicode-supported.ts
|
|
53
20
|
function isUnicodeSupported() {
|
|
@@ -61,15 +28,15 @@ function isUnicodeSupported() {
|
|
|
61
28
|
}
|
|
62
29
|
|
|
63
30
|
// src/logger/index.ts
|
|
64
|
-
var
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
}
|
|
72
|
-
|
|
31
|
+
var logger = {
|
|
32
|
+
level: "info",
|
|
33
|
+
info: (msg) => process.stdout.write(msg + "\n"),
|
|
34
|
+
warn: (msg) => process.stdout.write(msg + "\n"),
|
|
35
|
+
error: (msg) => process.stderr.write(msg + "\n"),
|
|
36
|
+
debug: (msg) => {
|
|
37
|
+
if (logger.level === "debug") process.stdout.write(msg + "\n");
|
|
38
|
+
}
|
|
39
|
+
};
|
|
73
40
|
function ansiRegex() {
|
|
74
41
|
const pattern = [
|
|
75
42
|
"[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)",
|
|
@@ -88,18 +55,18 @@ ${message}
|
|
|
88
55
|
return ln.length > sum ? ln.length : sum;
|
|
89
56
|
}, 0) + 2;
|
|
90
57
|
const msg = lines.map(
|
|
91
|
-
(ln) => `${
|
|
58
|
+
(ln) => `${chalk.gray(bar)} ${chalk.white(ln)}${" ".repeat(
|
|
92
59
|
len - strip(ln).length
|
|
93
|
-
)}${
|
|
60
|
+
)}${chalk.gray(bar)}`
|
|
94
61
|
).join("\n");
|
|
95
62
|
const underscoreLen = len - title.length - 1 > 0 ? len - title.length - 1 : 0;
|
|
96
63
|
process.stdout.write(
|
|
97
|
-
`${
|
|
98
|
-
${
|
|
64
|
+
`${chalk.gray(bar)}
|
|
65
|
+
${chalk.green("\u25CB")} ${chalk.reset(
|
|
99
66
|
title
|
|
100
|
-
)} ${
|
|
67
|
+
)} ${chalk.gray("\u2500".repeat(underscoreLen) + "\u256E")}
|
|
101
68
|
${msg}
|
|
102
|
-
${
|
|
69
|
+
${chalk.gray(
|
|
103
70
|
"\u251C" + "\u2500".repeat(len + 2) + "\u256F"
|
|
104
71
|
)}
|
|
105
72
|
`
|
|
@@ -116,11 +83,11 @@ var summary = (content) => {
|
|
|
116
83
|
});
|
|
117
84
|
});
|
|
118
85
|
content.items.forEach((item) => {
|
|
119
|
-
outString.push(`${item.emoji} ${
|
|
86
|
+
outString.push(`${item.emoji} ${chalk.cyan(item.heading)}`);
|
|
120
87
|
item.subItems.forEach((subItem) => {
|
|
121
88
|
const spaces = longestKey - subItem.key.length + 4;
|
|
122
89
|
outString.push(
|
|
123
|
-
` ${subItem.key}:${[...Array(spaces)].join(" ")}${
|
|
90
|
+
` ${subItem.key}:${[...Array(spaces)].join(" ")}${chalk.cyan(
|
|
124
91
|
subItem.value
|
|
125
92
|
)}`
|
|
126
93
|
);
|
|
@@ -158,12 +125,12 @@ var S_WARN = s("\u25B2", "!");
|
|
|
158
125
|
var S_ERROR = s("\u25A0", "x");
|
|
159
126
|
|
|
160
127
|
// src/utils/spinner.ts
|
|
161
|
-
|
|
128
|
+
import { Spinner } from "cli-spinner";
|
|
162
129
|
async function localSpin({
|
|
163
130
|
waitFor,
|
|
164
131
|
text
|
|
165
132
|
}) {
|
|
166
|
-
const spinner = new
|
|
133
|
+
const spinner = new Spinner({
|
|
167
134
|
text: `${text} %s`,
|
|
168
135
|
stream: process.stderr,
|
|
169
136
|
onTick: function(msg) {
|
|
@@ -194,32 +161,32 @@ function spin({
|
|
|
194
161
|
}
|
|
195
162
|
|
|
196
163
|
// src/utils/theme.ts
|
|
197
|
-
|
|
198
|
-
var successText =
|
|
199
|
-
var focusText =
|
|
200
|
-
var dangerText =
|
|
201
|
-
var neutralText =
|
|
202
|
-
var linkText =
|
|
203
|
-
var labelText =
|
|
204
|
-
var cmdText =
|
|
164
|
+
import chalk2 from "chalk";
|
|
165
|
+
var successText = chalk2.bold.green;
|
|
166
|
+
var focusText = chalk2.bold;
|
|
167
|
+
var dangerText = chalk2.bold.red;
|
|
168
|
+
var neutralText = chalk2.bold.cyan;
|
|
169
|
+
var linkText = chalk2.bold.cyan;
|
|
170
|
+
var labelText = chalk2.bold;
|
|
171
|
+
var cmdText = chalk2.inverse;
|
|
205
172
|
var indentedCmd = (str) => {
|
|
206
173
|
return ` \u2503 ` + str;
|
|
207
174
|
};
|
|
208
175
|
var indentText = (str) => {
|
|
209
176
|
return String(str).split("\n").map((line) => ` ${line}`).join("\n");
|
|
210
177
|
};
|
|
211
|
-
var logText =
|
|
212
|
-
var warnText =
|
|
213
|
-
var titleText =
|
|
214
|
-
var CONFIRMATION_TEXT =
|
|
178
|
+
var logText = chalk2.italic.gray;
|
|
179
|
+
var warnText = chalk2.yellowBright.bgBlack;
|
|
180
|
+
var titleText = chalk2.bgHex("d2f1f8").hex("ec4816");
|
|
181
|
+
var CONFIRMATION_TEXT = chalk2.dim("enter to confirm");
|
|
215
182
|
|
|
216
183
|
// src/next/codegen/index.ts
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
184
|
+
import fs from "fs-extra";
|
|
185
|
+
import path from "path";
|
|
186
|
+
import { buildASTSchema, printSchema as printSchema2 } from "graphql";
|
|
220
187
|
|
|
221
188
|
// src/next/codegen/codegen/index.ts
|
|
222
|
-
|
|
189
|
+
import { parse, printSchema } from "graphql";
|
|
223
190
|
|
|
224
191
|
// src/next/codegen/codegen/plugin.ts
|
|
225
192
|
var AddGeneratedClientFunc = (apiURL) => {
|
|
@@ -288,37 +255,44 @@ var AddGeneratedClient = (apiURL) => ({
|
|
|
288
255
|
});
|
|
289
256
|
|
|
290
257
|
// src/next/codegen/codegen/index.ts
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
258
|
+
import { GraphQLFileLoader } from "@graphql-tools/graphql-file-loader";
|
|
259
|
+
import { codegen } from "@graphql-codegen/core";
|
|
260
|
+
import { loadDocuments } from "@graphql-tools/load";
|
|
261
|
+
import { plugin as typescriptOperationsPlugin } from "@graphql-codegen/typescript-operations";
|
|
262
|
+
import { plugin as typescriptPlugin } from "@graphql-codegen/typescript";
|
|
296
263
|
|
|
297
264
|
// src/next/codegen/codegen/sdkPlugin/index.ts
|
|
298
|
-
|
|
299
|
-
|
|
265
|
+
import { visit } from "graphql";
|
|
266
|
+
import {
|
|
267
|
+
concatAST,
|
|
268
|
+
Kind as Kind2
|
|
269
|
+
} from "graphql";
|
|
300
270
|
|
|
301
271
|
// src/next/codegen/codegen/sdkPlugin/visitor.ts
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
272
|
+
import {
|
|
273
|
+
ClientSideBaseVisitor,
|
|
274
|
+
DocumentMode,
|
|
275
|
+
indentMultiline
|
|
276
|
+
} from "@graphql-codegen/visitor-plugin-common";
|
|
277
|
+
import autoBind from "auto-bind";
|
|
278
|
+
import { Kind, print } from "graphql";
|
|
279
|
+
var GenericSdkVisitor = class extends ClientSideBaseVisitor {
|
|
280
|
+
_operationsToInclude = [];
|
|
306
281
|
constructor(schema, fragments, rawConfig) {
|
|
307
282
|
super(schema, fragments, rawConfig, {
|
|
308
283
|
usingObservableFrom: rawConfig.usingObservableFrom
|
|
309
284
|
});
|
|
310
|
-
this
|
|
311
|
-
(0, import_auto_bind.default)(this);
|
|
285
|
+
autoBind(this);
|
|
312
286
|
if (this.config.usingObservableFrom) {
|
|
313
287
|
this._additionalImports.push(this.config.usingObservableFrom);
|
|
314
288
|
}
|
|
315
|
-
if (this.config.documentMode !==
|
|
289
|
+
if (this.config.documentMode !== DocumentMode.string) {
|
|
316
290
|
}
|
|
317
291
|
}
|
|
318
292
|
buildOperation(node, documentVariableName, operationType, operationResultType, operationVariablesTypes) {
|
|
319
293
|
if (node.name == null) {
|
|
320
294
|
throw new Error(
|
|
321
|
-
"Plugin 'generic-sdk' cannot generate SDK for unnamed operation.\n\n" +
|
|
295
|
+
"Plugin 'generic-sdk' cannot generate SDK for unnamed operation.\n\n" + print(node)
|
|
322
296
|
);
|
|
323
297
|
} else {
|
|
324
298
|
this._operationsToInclude.push({
|
|
@@ -336,14 +310,14 @@ var GenericSdkVisitor = class extends import_visitor_plugin_common.ClientSideBas
|
|
|
336
310
|
const usingObservable = !!this.config.usingObservableFrom;
|
|
337
311
|
const allPossibleActions = this._operationsToInclude.map((o) => {
|
|
338
312
|
const optionalVariables = !o.node.variableDefinitions || o.node.variableDefinitions.length === 0 || o.node.variableDefinitions.every(
|
|
339
|
-
(v) => v.type.kind !==
|
|
313
|
+
(v) => v.type.kind !== Kind.NON_NULL_TYPE || v.defaultValue
|
|
340
314
|
);
|
|
341
315
|
const returnType = usingObservable && o.operationType === "Subscription" ? "Observable" : "Promise";
|
|
342
316
|
return `${o.node.name.value}(variables${optionalVariables ? "?" : ""}: ${o.operationVariablesTypes}, options?: C): ${returnType}<${o.operationResultType}> {
|
|
343
317
|
return requester<${o.operationResultType}, ${o.operationVariablesTypes}>(${o.documentVariableName}, variables, options);
|
|
344
318
|
}`;
|
|
345
|
-
}).map((s2) =>
|
|
346
|
-
return `export type Requester<C= {}> = <R, V>(doc: ${this.config.documentMode ===
|
|
319
|
+
}).map((s2) => indentMultiline(s2, 2));
|
|
320
|
+
return `export type Requester<C= {}> = <R, V>(doc: ${this.config.documentMode === DocumentMode.string ? "string" : "DocumentNode"}, vars?: V, options?: C) => ${usingObservable ? "Promise<R> & Observable<R>" : "Promise<R>"}
|
|
347
321
|
export function getSdk<C>(requester: Requester<C>) {
|
|
348
322
|
return {
|
|
349
323
|
${allPossibleActions.join(",\n")}
|
|
@@ -355,14 +329,14 @@ var GenericSdkVisitor = class extends import_visitor_plugin_common.ClientSideBas
|
|
|
355
329
|
|
|
356
330
|
// src/next/codegen/codegen/sdkPlugin/index.ts
|
|
357
331
|
var plugin = (schema, documents, config2) => {
|
|
358
|
-
const allAst =
|
|
332
|
+
const allAst = concatAST(
|
|
359
333
|
documents.reduce((prev, v) => {
|
|
360
334
|
return [...prev, v.document];
|
|
361
335
|
}, [])
|
|
362
336
|
);
|
|
363
337
|
const allFragments = [
|
|
364
338
|
...allAst.definitions.filter(
|
|
365
|
-
(d) => d.kind ===
|
|
339
|
+
(d) => d.kind === Kind2.FRAGMENT_DEFINITION
|
|
366
340
|
).map((fragmentDef) => ({
|
|
367
341
|
node: fragmentDef,
|
|
368
342
|
name: fragmentDef.name.value,
|
|
@@ -372,7 +346,7 @@ var plugin = (schema, documents, config2) => {
|
|
|
372
346
|
...config2.externalFragments || []
|
|
373
347
|
];
|
|
374
348
|
const visitor = new GenericSdkVisitor(schema, allFragments, config2);
|
|
375
|
-
const visitorResult =
|
|
349
|
+
const visitorResult = visit(allAst, { leave: visitor });
|
|
376
350
|
return {
|
|
377
351
|
// We will take care of imports
|
|
378
352
|
// prepend: visitor.getImports(),
|
|
@@ -390,10 +364,10 @@ var generateTypes = async (schema, queryPathGlob = process.cwd(), fragDocPath =
|
|
|
390
364
|
let fragDocs = [];
|
|
391
365
|
docs = await loadGraphQLDocuments(queryPathGlob);
|
|
392
366
|
fragDocs = await loadGraphQLDocuments(fragDocPath);
|
|
393
|
-
const res = await
|
|
367
|
+
const res = await codegen({
|
|
394
368
|
// Filename is not used. This is because the typescript plugin returns a string instead of writing to a file.
|
|
395
369
|
filename: process.cwd(),
|
|
396
|
-
schema:
|
|
370
|
+
schema: parse(printSchema(schema)),
|
|
397
371
|
documents: [...docs, ...fragDocs],
|
|
398
372
|
config: {},
|
|
399
373
|
plugins: [
|
|
@@ -406,10 +380,10 @@ var generateTypes = async (schema, queryPathGlob = process.cwd(), fragDocPath =
|
|
|
406
380
|
],
|
|
407
381
|
pluginMap: {
|
|
408
382
|
typescript: {
|
|
409
|
-
plugin:
|
|
383
|
+
plugin: typescriptPlugin
|
|
410
384
|
},
|
|
411
385
|
typescriptOperations: {
|
|
412
|
-
plugin:
|
|
386
|
+
plugin: typescriptOperationsPlugin
|
|
413
387
|
},
|
|
414
388
|
typescriptSdk: {
|
|
415
389
|
plugin
|
|
@@ -422,8 +396,8 @@ var generateTypes = async (schema, queryPathGlob = process.cwd(), fragDocPath =
|
|
|
422
396
|
var loadGraphQLDocuments = async (globPath) => {
|
|
423
397
|
let result = [];
|
|
424
398
|
try {
|
|
425
|
-
result = await
|
|
426
|
-
loaders: [new
|
|
399
|
+
result = await loadDocuments(globPath, {
|
|
400
|
+
loaders: [new GraphQLFileLoader()]
|
|
427
401
|
});
|
|
428
402
|
} catch (e) {
|
|
429
403
|
if (
|
|
@@ -440,11 +414,27 @@ var loadGraphQLDocuments = async (globPath) => {
|
|
|
440
414
|
};
|
|
441
415
|
|
|
442
416
|
// src/next/codegen/index.ts
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
417
|
+
import { transform } from "esbuild";
|
|
418
|
+
import { mapUserFields } from "@tinacms/graphql";
|
|
419
|
+
import normalizePath from "normalize-path";
|
|
446
420
|
var TINA_HOST = "content.tinajs.io";
|
|
447
421
|
var Codegen = class {
|
|
422
|
+
configManager;
|
|
423
|
+
port;
|
|
424
|
+
schema;
|
|
425
|
+
queryDoc;
|
|
426
|
+
fragDoc;
|
|
427
|
+
isLocal;
|
|
428
|
+
// The API url used in the client
|
|
429
|
+
apiURL;
|
|
430
|
+
// This is always the local URL.
|
|
431
|
+
localUrl;
|
|
432
|
+
// production url
|
|
433
|
+
productionUrl;
|
|
434
|
+
graphqlSchemaDoc;
|
|
435
|
+
tinaSchema;
|
|
436
|
+
lookup;
|
|
437
|
+
noClientBuildCache;
|
|
448
438
|
constructor({
|
|
449
439
|
configManager,
|
|
450
440
|
port,
|
|
@@ -460,7 +450,7 @@ var Codegen = class {
|
|
|
460
450
|
this.graphqlSchemaDoc = graphqlSchemaDoc;
|
|
461
451
|
this.configManager = configManager;
|
|
462
452
|
this.port = port;
|
|
463
|
-
this.schema =
|
|
453
|
+
this.schema = buildASTSchema(graphqlSchemaDoc);
|
|
464
454
|
this.tinaSchema = tinaSchema;
|
|
465
455
|
this.queryDoc = queryDoc;
|
|
466
456
|
this.fragDoc = fragDoc;
|
|
@@ -468,19 +458,19 @@ var Codegen = class {
|
|
|
468
458
|
this.noClientBuildCache = noClientBuildCache;
|
|
469
459
|
}
|
|
470
460
|
async writeConfigFile(fileName, data) {
|
|
471
|
-
const filePath =
|
|
461
|
+
const filePath = path.join(
|
|
472
462
|
this.configManager.generatedFolderPath,
|
|
473
463
|
fileName
|
|
474
464
|
);
|
|
475
|
-
await
|
|
476
|
-
await
|
|
465
|
+
await fs.ensureFile(filePath);
|
|
466
|
+
await fs.outputFile(filePath, data);
|
|
477
467
|
if (this.configManager.hasSeparateContentRoot()) {
|
|
478
|
-
const filePath2 =
|
|
468
|
+
const filePath2 = path.join(
|
|
479
469
|
this.configManager.generatedFolderPathContentRepo,
|
|
480
470
|
fileName
|
|
481
471
|
);
|
|
482
|
-
await
|
|
483
|
-
await
|
|
472
|
+
await fs.ensureFile(filePath2);
|
|
473
|
+
await fs.outputFile(filePath2, data);
|
|
484
474
|
}
|
|
485
475
|
}
|
|
486
476
|
async removeGeneratedFilesIfExists() {
|
|
@@ -512,11 +502,11 @@ var Codegen = class {
|
|
|
512
502
|
await this.removeGeneratedFilesIfExists();
|
|
513
503
|
return apiURL;
|
|
514
504
|
}
|
|
515
|
-
await
|
|
505
|
+
await fs.outputFile(
|
|
516
506
|
this.configManager.generatedQueriesFilePath,
|
|
517
507
|
this.queryDoc
|
|
518
508
|
);
|
|
519
|
-
await
|
|
509
|
+
await fs.outputFile(
|
|
520
510
|
this.configManager.generatedFragmentsFilePath,
|
|
521
511
|
this.fragDoc
|
|
522
512
|
);
|
|
@@ -524,21 +514,21 @@ var Codegen = class {
|
|
|
524
514
|
const { clientString } = await this.genClient();
|
|
525
515
|
const databaseClientString = this.configManager.hasSelfHostedConfig() ? await this.genDatabaseClient() : "";
|
|
526
516
|
const { codeString, schemaString } = await this.genTypes();
|
|
527
|
-
await
|
|
517
|
+
await fs.outputFile(
|
|
528
518
|
this.configManager.generatedGraphQLGQLPath,
|
|
529
519
|
schemaString
|
|
530
520
|
);
|
|
531
521
|
if (this.configManager.isUsingTs()) {
|
|
532
|
-
await
|
|
522
|
+
await fs.outputFile(
|
|
533
523
|
this.configManager.generatedTypesTSFilePath,
|
|
534
524
|
codeString
|
|
535
525
|
);
|
|
536
|
-
await
|
|
526
|
+
await fs.outputFile(
|
|
537
527
|
this.configManager.generatedClientTSFilePath,
|
|
538
528
|
clientString
|
|
539
529
|
);
|
|
540
530
|
if (this.configManager.hasSelfHostedConfig()) {
|
|
541
|
-
await
|
|
531
|
+
await fs.outputFile(
|
|
542
532
|
this.configManager.generatedDatabaseClientTSFilePath,
|
|
543
533
|
databaseClientString
|
|
544
534
|
);
|
|
@@ -547,35 +537,35 @@ var Codegen = class {
|
|
|
547
537
|
await unlinkIfExists(this.configManager.generatedTypesDFilePath);
|
|
548
538
|
await unlinkIfExists(this.configManager.generatedTypesJSFilePath);
|
|
549
539
|
} else {
|
|
550
|
-
await
|
|
540
|
+
await fs.outputFile(
|
|
551
541
|
this.configManager.generatedTypesDFilePath,
|
|
552
542
|
codeString
|
|
553
543
|
);
|
|
554
|
-
const jsTypes = await
|
|
555
|
-
await
|
|
544
|
+
const jsTypes = await transform(codeString, { loader: "ts" });
|
|
545
|
+
await fs.outputFile(
|
|
556
546
|
this.configManager.generatedTypesJSFilePath,
|
|
557
547
|
jsTypes.code
|
|
558
548
|
);
|
|
559
|
-
await
|
|
549
|
+
await fs.outputFile(
|
|
560
550
|
this.configManager.generatedClientDFilePath,
|
|
561
551
|
clientString
|
|
562
552
|
);
|
|
563
|
-
const jsClient = await
|
|
564
|
-
await
|
|
553
|
+
const jsClient = await transform(clientString, { loader: "ts" });
|
|
554
|
+
await fs.outputFile(
|
|
565
555
|
this.configManager.generatedClientJSFilePath,
|
|
566
556
|
jsClient.code
|
|
567
557
|
);
|
|
568
558
|
await unlinkIfExists(this.configManager.generatedTypesTSFilePath);
|
|
569
559
|
await unlinkIfExists(this.configManager.generatedClientTSFilePath);
|
|
570
560
|
if (this.configManager.hasSelfHostedConfig()) {
|
|
571
|
-
const jsDatabaseClient = await
|
|
561
|
+
const jsDatabaseClient = await transform(databaseClientString, {
|
|
572
562
|
loader: "ts"
|
|
573
563
|
});
|
|
574
|
-
await
|
|
564
|
+
await fs.outputFile(
|
|
575
565
|
this.configManager.generatedDatabaseClientJSFilePath,
|
|
576
566
|
jsDatabaseClient.code
|
|
577
567
|
);
|
|
578
|
-
await
|
|
568
|
+
await fs.outputFile(
|
|
579
569
|
this.configManager.generatedDatabaseClientDFilePath,
|
|
580
570
|
databaseClientString
|
|
581
571
|
);
|
|
@@ -623,7 +613,7 @@ var Codegen = class {
|
|
|
623
613
|
const authCollection = this.tinaSchema.getCollections().find((c) => c.isAuthCollection);
|
|
624
614
|
let authFields = [];
|
|
625
615
|
if (authCollection) {
|
|
626
|
-
const usersFields =
|
|
616
|
+
const usersFields = mapUserFields(authCollection, []);
|
|
627
617
|
if (usersFields.length === 0) {
|
|
628
618
|
throw new Error("No user field found");
|
|
629
619
|
}
|
|
@@ -713,7 +703,7 @@ export default databaseClient;
|
|
|
713
703
|
const apiURL = this.getApiURL();
|
|
714
704
|
const clientString = `import { createClient } from "tinacms/dist/client";
|
|
715
705
|
import { queries } from "./types";
|
|
716
|
-
export const client = createClient({ ${this.noClientBuildCache === false ? `cacheDir: '${(
|
|
706
|
+
export const client = createClient({ ${this.noClientBuildCache === false ? `cacheDir: '${normalizePath(
|
|
717
707
|
this.configManager.generatedCachePath
|
|
718
708
|
)}', ` : ""}url: '${apiURL}', token: '${token}', queries, ${errorPolicy ? `errorPolicy: '${errorPolicy}'` : ""} });
|
|
719
709
|
export default client;
|
|
@@ -739,7 +729,7 @@ export default client;
|
|
|
739
729
|
${typescriptTypes}
|
|
740
730
|
`;
|
|
741
731
|
const schemaString = `# DO NOT MODIFY THIS FILE. This file is automatically generated by Tina
|
|
742
|
-
${(
|
|
732
|
+
${printSchema2(this.schema)}
|
|
743
733
|
schema {
|
|
744
734
|
query: Query
|
|
745
735
|
mutation: Mutation
|
|
@@ -751,7 +741,7 @@ schema {
|
|
|
751
741
|
var maybeWarnFragmentSize = async (filepath) => {
|
|
752
742
|
if (
|
|
753
743
|
// is the file bigger than 100kb?
|
|
754
|
-
(await
|
|
744
|
+
(await fs.stat(filepath)).size > // convert to 100 kb to bytes
|
|
755
745
|
100 * 1024
|
|
756
746
|
) {
|
|
757
747
|
console.warn(
|
|
@@ -768,26 +758,28 @@ var maybeWarnFragmentSize = async (filepath) => {
|
|
|
768
758
|
}
|
|
769
759
|
};
|
|
770
760
|
var unlinkIfExists = async (filepath) => {
|
|
771
|
-
if (
|
|
772
|
-
|
|
761
|
+
if (fs.existsSync(filepath)) {
|
|
762
|
+
fs.unlinkSync(filepath);
|
|
773
763
|
}
|
|
774
764
|
};
|
|
775
765
|
|
|
776
766
|
// src/next/config-manager.ts
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
767
|
+
import fs2 from "fs-extra";
|
|
768
|
+
import path3 from "path";
|
|
769
|
+
import os from "os";
|
|
770
|
+
import { pathToFileURL } from "url";
|
|
771
|
+
import * as esbuild from "esbuild";
|
|
772
|
+
import * as dotenv from "dotenv";
|
|
773
|
+
import normalizePath2 from "normalize-path";
|
|
774
|
+
import chalk3 from "chalk";
|
|
775
|
+
import { createRequire } from "module";
|
|
784
776
|
|
|
785
777
|
// src/utils/path.ts
|
|
786
|
-
|
|
778
|
+
import path2 from "path";
|
|
787
779
|
function stripNativeTrailingSlash(p) {
|
|
788
|
-
const { root } =
|
|
780
|
+
const { root } = path2.parse(p);
|
|
789
781
|
let str = p;
|
|
790
|
-
while (str.length > root.length && str.endsWith(
|
|
782
|
+
while (str.length > root.length && str.endsWith(path2.sep)) {
|
|
791
783
|
str = str.slice(0, -1);
|
|
792
784
|
}
|
|
793
785
|
return str;
|
|
@@ -802,17 +794,57 @@ var GRAPHQL_GQL_FILE = "schema.gql";
|
|
|
802
794
|
var SCHEMA_JSON_FILE = "_schema.json";
|
|
803
795
|
var LOOKUP_JSON_FILE = "_lookup.json";
|
|
804
796
|
var ConfigManager = class {
|
|
797
|
+
config;
|
|
798
|
+
rootPath;
|
|
799
|
+
tinaFolderPath;
|
|
800
|
+
isUsingLegacyFolder;
|
|
801
|
+
tinaConfigFilePath;
|
|
802
|
+
tinaSpaPackagePath;
|
|
803
|
+
contentRootPath;
|
|
804
|
+
envFilePath;
|
|
805
|
+
generatedCachePath;
|
|
806
|
+
generatedFolderPath;
|
|
807
|
+
generatedFolderPathContentRepo;
|
|
808
|
+
generatedGraphQLGQLPath;
|
|
809
|
+
generatedGraphQLJSONPath;
|
|
810
|
+
generatedSchemaJSONPath;
|
|
811
|
+
generatedLookupJSONPath;
|
|
812
|
+
generatedTypesTSFilePath;
|
|
813
|
+
generatedTypesJSFilePath;
|
|
814
|
+
generatedTypesDFilePath;
|
|
815
|
+
generatedClientTSFilePath;
|
|
816
|
+
generatedClientJSFilePath;
|
|
817
|
+
generatedClientDFilePath;
|
|
818
|
+
generatedDatabaseClientJSFilePath;
|
|
819
|
+
generatedDatabaseClientTSFilePath;
|
|
820
|
+
generatedDatabaseClientDFilePath;
|
|
821
|
+
generatedQueriesFilePath;
|
|
822
|
+
generatedFragmentsFilePath;
|
|
823
|
+
generatedQueriesAndFragmentsGlob;
|
|
824
|
+
userQueriesAndFragmentsGlob;
|
|
825
|
+
publicFolderPath;
|
|
826
|
+
outputFolderPath;
|
|
827
|
+
outputHTMLFilePath;
|
|
828
|
+
outputGitignorePath;
|
|
829
|
+
selfHostedDatabaseFilePath;
|
|
830
|
+
prebuildFilePath;
|
|
831
|
+
spaRootPath;
|
|
832
|
+
spaMainPath;
|
|
833
|
+
spaHTMLPath;
|
|
834
|
+
tinaGraphQLVersionFromCLI;
|
|
835
|
+
legacyNoSDK;
|
|
836
|
+
watchList;
|
|
805
837
|
constructor({
|
|
806
838
|
rootPath = process.cwd(),
|
|
807
839
|
tinaGraphQLVersion,
|
|
808
840
|
legacyNoSDK
|
|
809
841
|
}) {
|
|
810
|
-
this.rootPath = (
|
|
842
|
+
this.rootPath = normalizePath2(rootPath);
|
|
811
843
|
this.tinaGraphQLVersionFromCLI = tinaGraphQLVersion;
|
|
812
844
|
this.legacyNoSDK = legacyNoSDK;
|
|
813
845
|
}
|
|
814
846
|
isUsingTs() {
|
|
815
|
-
return [".ts", ".tsx"].includes(
|
|
847
|
+
return [".ts", ".tsx"].includes(path3.extname(this.tinaConfigFilePath));
|
|
816
848
|
}
|
|
817
849
|
hasSelfHostedConfig() {
|
|
818
850
|
return !!this.selfHostedDatabaseFilePath;
|
|
@@ -827,13 +859,14 @@ var ConfigManager = class {
|
|
|
827
859
|
return this.config.client?.skip || false;
|
|
828
860
|
}
|
|
829
861
|
async processConfig() {
|
|
862
|
+
const require2 = createRequire(import.meta.url);
|
|
830
863
|
this.tinaFolderPath = await this.getTinaFolderPath(this.rootPath);
|
|
831
|
-
this.envFilePath =
|
|
832
|
-
|
|
864
|
+
this.envFilePath = path3.resolve(
|
|
865
|
+
path3.join(this.tinaFolderPath, "..", ".env")
|
|
833
866
|
);
|
|
834
867
|
dotenv.config({ path: this.envFilePath });
|
|
835
868
|
this.tinaConfigFilePath = await this.getPathWithExtension(
|
|
836
|
-
|
|
869
|
+
path3.join(this.tinaFolderPath, "config")
|
|
837
870
|
);
|
|
838
871
|
if (!this.tinaConfigFilePath) {
|
|
839
872
|
throw new Error(
|
|
@@ -841,89 +874,89 @@ var ConfigManager = class {
|
|
|
841
874
|
);
|
|
842
875
|
}
|
|
843
876
|
this.selfHostedDatabaseFilePath = await this.getPathWithExtension(
|
|
844
|
-
|
|
877
|
+
path3.join(this.tinaFolderPath, "database")
|
|
845
878
|
);
|
|
846
|
-
this.generatedFolderPath =
|
|
847
|
-
this.generatedCachePath =
|
|
879
|
+
this.generatedFolderPath = path3.join(this.tinaFolderPath, GENERATED_FOLDER);
|
|
880
|
+
this.generatedCachePath = path3.join(
|
|
848
881
|
this.generatedFolderPath,
|
|
849
882
|
".cache",
|
|
850
883
|
String((/* @__PURE__ */ new Date()).getTime())
|
|
851
884
|
);
|
|
852
|
-
this.generatedGraphQLGQLPath =
|
|
885
|
+
this.generatedGraphQLGQLPath = path3.join(
|
|
853
886
|
this.generatedFolderPath,
|
|
854
887
|
GRAPHQL_GQL_FILE
|
|
855
888
|
);
|
|
856
|
-
this.generatedGraphQLJSONPath =
|
|
889
|
+
this.generatedGraphQLJSONPath = path3.join(
|
|
857
890
|
this.generatedFolderPath,
|
|
858
891
|
GRAPHQL_JSON_FILE
|
|
859
892
|
);
|
|
860
|
-
this.generatedSchemaJSONPath =
|
|
893
|
+
this.generatedSchemaJSONPath = path3.join(
|
|
861
894
|
this.generatedFolderPath,
|
|
862
895
|
SCHEMA_JSON_FILE
|
|
863
896
|
);
|
|
864
|
-
this.generatedLookupJSONPath =
|
|
897
|
+
this.generatedLookupJSONPath = path3.join(
|
|
865
898
|
this.generatedFolderPath,
|
|
866
899
|
LOOKUP_JSON_FILE
|
|
867
900
|
);
|
|
868
|
-
this.generatedQueriesFilePath =
|
|
901
|
+
this.generatedQueriesFilePath = path3.join(
|
|
869
902
|
this.generatedFolderPath,
|
|
870
903
|
"queries.gql"
|
|
871
904
|
);
|
|
872
|
-
this.generatedFragmentsFilePath =
|
|
905
|
+
this.generatedFragmentsFilePath = path3.join(
|
|
873
906
|
this.generatedFolderPath,
|
|
874
907
|
"frags.gql"
|
|
875
908
|
);
|
|
876
|
-
this.generatedTypesTSFilePath =
|
|
909
|
+
this.generatedTypesTSFilePath = path3.join(
|
|
877
910
|
this.generatedFolderPath,
|
|
878
911
|
"types.ts"
|
|
879
912
|
);
|
|
880
|
-
this.generatedTypesJSFilePath =
|
|
913
|
+
this.generatedTypesJSFilePath = path3.join(
|
|
881
914
|
this.generatedFolderPath,
|
|
882
915
|
"types.js"
|
|
883
916
|
);
|
|
884
|
-
this.generatedTypesDFilePath =
|
|
917
|
+
this.generatedTypesDFilePath = path3.join(
|
|
885
918
|
this.generatedFolderPath,
|
|
886
919
|
"types.d.ts"
|
|
887
920
|
);
|
|
888
|
-
this.userQueriesAndFragmentsGlob =
|
|
921
|
+
this.userQueriesAndFragmentsGlob = path3.join(
|
|
889
922
|
this.tinaFolderPath,
|
|
890
923
|
"queries/**/*.{graphql,gql}"
|
|
891
924
|
);
|
|
892
|
-
this.generatedQueriesAndFragmentsGlob =
|
|
925
|
+
this.generatedQueriesAndFragmentsGlob = path3.join(
|
|
893
926
|
this.generatedFolderPath,
|
|
894
927
|
"*.{graphql,gql}"
|
|
895
928
|
);
|
|
896
|
-
this.generatedClientTSFilePath =
|
|
929
|
+
this.generatedClientTSFilePath = path3.join(
|
|
897
930
|
this.generatedFolderPath,
|
|
898
931
|
"client.ts"
|
|
899
932
|
);
|
|
900
|
-
this.generatedClientJSFilePath =
|
|
933
|
+
this.generatedClientJSFilePath = path3.join(
|
|
901
934
|
this.generatedFolderPath,
|
|
902
935
|
"client.js"
|
|
903
936
|
);
|
|
904
|
-
this.generatedClientDFilePath =
|
|
937
|
+
this.generatedClientDFilePath = path3.join(
|
|
905
938
|
this.generatedFolderPath,
|
|
906
939
|
"client.d.ts"
|
|
907
940
|
);
|
|
908
|
-
this.generatedDatabaseClientDFilePath =
|
|
941
|
+
this.generatedDatabaseClientDFilePath = path3.join(
|
|
909
942
|
this.generatedFolderPath,
|
|
910
943
|
"databaseClient.d.ts"
|
|
911
944
|
);
|
|
912
|
-
this.generatedDatabaseClientTSFilePath =
|
|
945
|
+
this.generatedDatabaseClientTSFilePath = path3.join(
|
|
913
946
|
this.generatedFolderPath,
|
|
914
947
|
"databaseClient.ts"
|
|
915
948
|
);
|
|
916
|
-
this.generatedDatabaseClientJSFilePath =
|
|
949
|
+
this.generatedDatabaseClientJSFilePath = path3.join(
|
|
917
950
|
this.generatedFolderPath,
|
|
918
951
|
"databaseClient.js"
|
|
919
952
|
);
|
|
920
|
-
const clientExists = this.isUsingTs() ? await
|
|
953
|
+
const clientExists = this.isUsingTs() ? await fs2.pathExists(this.generatedClientTSFilePath) : await fs2.pathExists(this.generatedClientJSFilePath);
|
|
921
954
|
if (!clientExists) {
|
|
922
955
|
const file = "export default ()=>({})\nexport const client = ()=>({})";
|
|
923
956
|
if (this.isUsingTs()) {
|
|
924
|
-
await
|
|
957
|
+
await fs2.outputFile(this.generatedClientTSFilePath, file);
|
|
925
958
|
} else {
|
|
926
|
-
await
|
|
959
|
+
await fs2.outputFile(this.generatedClientJSFilePath, file);
|
|
927
960
|
}
|
|
928
961
|
}
|
|
929
962
|
const { config: config2, prebuildPath, watchList } = await this.loadConfigFile(
|
|
@@ -933,29 +966,29 @@ var ConfigManager = class {
|
|
|
933
966
|
this.watchList = watchList;
|
|
934
967
|
this.config = config2;
|
|
935
968
|
this.prebuildFilePath = prebuildPath;
|
|
936
|
-
this.publicFolderPath =
|
|
969
|
+
this.publicFolderPath = path3.join(
|
|
937
970
|
this.rootPath,
|
|
938
971
|
this.config.build.publicFolder
|
|
939
972
|
);
|
|
940
|
-
this.outputFolderPath =
|
|
973
|
+
this.outputFolderPath = path3.join(
|
|
941
974
|
this.publicFolderPath,
|
|
942
975
|
this.config.build.outputFolder
|
|
943
976
|
);
|
|
944
|
-
this.outputHTMLFilePath =
|
|
945
|
-
this.outputGitignorePath =
|
|
977
|
+
this.outputHTMLFilePath = path3.join(this.outputFolderPath, "index.html");
|
|
978
|
+
this.outputGitignorePath = path3.join(this.outputFolderPath, ".gitignore");
|
|
946
979
|
const fullLocalContentPath = stripNativeTrailingSlash(
|
|
947
|
-
|
|
980
|
+
path3.join(this.tinaFolderPath, this.config.localContentPath || "")
|
|
948
981
|
);
|
|
949
982
|
if (this.config.localContentPath) {
|
|
950
|
-
const localContentPathExists = await
|
|
983
|
+
const localContentPathExists = await fs2.pathExists(fullLocalContentPath);
|
|
951
984
|
if (localContentPathExists) {
|
|
952
985
|
logger.info(`Using separate content repo at ${fullLocalContentPath}`);
|
|
953
986
|
this.contentRootPath = fullLocalContentPath;
|
|
954
987
|
} else {
|
|
955
988
|
logger.warn(
|
|
956
|
-
`${
|
|
989
|
+
`${chalk3.yellow("Warning:")} The localContentPath ${chalk3.cyan(
|
|
957
990
|
fullLocalContentPath
|
|
958
|
-
)} does not exist. Please create it or remove the localContentPath from your config file at ${
|
|
991
|
+
)} does not exist. Please create it or remove the localContentPath from your config file at ${chalk3.cyan(
|
|
959
992
|
this.tinaConfigFilePath
|
|
960
993
|
)}`
|
|
961
994
|
);
|
|
@@ -964,22 +997,22 @@ var ConfigManager = class {
|
|
|
964
997
|
if (!this.contentRootPath) {
|
|
965
998
|
this.contentRootPath = this.rootPath;
|
|
966
999
|
}
|
|
967
|
-
this.generatedFolderPathContentRepo =
|
|
1000
|
+
this.generatedFolderPathContentRepo = path3.join(
|
|
968
1001
|
await this.getTinaFolderPath(this.contentRootPath),
|
|
969
1002
|
GENERATED_FOLDER
|
|
970
1003
|
);
|
|
971
|
-
this.spaMainPath =
|
|
972
|
-
this.spaRootPath =
|
|
1004
|
+
this.spaMainPath = require2.resolve("@tinacms/app");
|
|
1005
|
+
this.spaRootPath = path3.join(this.spaMainPath, "..", "..");
|
|
973
1006
|
}
|
|
974
1007
|
async getTinaFolderPath(rootPath) {
|
|
975
|
-
const tinaFolderPath =
|
|
976
|
-
const tinaFolderExists = await
|
|
1008
|
+
const tinaFolderPath = path3.join(rootPath, TINA_FOLDER);
|
|
1009
|
+
const tinaFolderExists = await fs2.pathExists(tinaFolderPath);
|
|
977
1010
|
if (tinaFolderExists) {
|
|
978
1011
|
this.isUsingLegacyFolder = false;
|
|
979
1012
|
return tinaFolderPath;
|
|
980
1013
|
}
|
|
981
|
-
const legacyFolderPath =
|
|
982
|
-
const legacyFolderExists = await
|
|
1014
|
+
const legacyFolderPath = path3.join(rootPath, LEGACY_TINA_FOLDER);
|
|
1015
|
+
const legacyFolderExists = await fs2.pathExists(legacyFolderPath);
|
|
983
1016
|
if (legacyFolderExists) {
|
|
984
1017
|
this.isUsingLegacyFolder = true;
|
|
985
1018
|
return legacyFolderPath;
|
|
@@ -998,7 +1031,7 @@ var ConfigManager = class {
|
|
|
998
1031
|
patch: version2[2] || "x"
|
|
999
1032
|
};
|
|
1000
1033
|
}
|
|
1001
|
-
const generatedSchema =
|
|
1034
|
+
const generatedSchema = fs2.readJSONSync(this.generatedSchemaJSONPath);
|
|
1002
1035
|
if (!generatedSchema || !(typeof generatedSchema?.version !== "undefined")) {
|
|
1003
1036
|
throw new Error(
|
|
1004
1037
|
`Can not find Tina GraphQL version in ${this.generatedSchemaJSONPath}`
|
|
@@ -1045,7 +1078,7 @@ var ConfigManager = class {
|
|
|
1045
1078
|
return;
|
|
1046
1079
|
}
|
|
1047
1080
|
const filepathWithExtension = `${filepath}.${ext}`;
|
|
1048
|
-
const exists =
|
|
1081
|
+
const exists = fs2.existsSync(filepathWithExtension);
|
|
1049
1082
|
if (exists) {
|
|
1050
1083
|
result = filepathWithExtension;
|
|
1051
1084
|
}
|
|
@@ -1054,33 +1087,45 @@ var ConfigManager = class {
|
|
|
1054
1087
|
return result;
|
|
1055
1088
|
}
|
|
1056
1089
|
async loadDatabaseFile() {
|
|
1057
|
-
const tmpdir =
|
|
1058
|
-
const outfile =
|
|
1090
|
+
const tmpdir = path3.join(os.tmpdir(), Date.now().toString());
|
|
1091
|
+
const outfile = path3.join(tmpdir, "database.build.mjs");
|
|
1059
1092
|
await esbuild.build({
|
|
1060
1093
|
entryPoints: [this.selfHostedDatabaseFilePath],
|
|
1061
1094
|
bundle: true,
|
|
1062
1095
|
platform: "node",
|
|
1096
|
+
format: "esm",
|
|
1063
1097
|
outfile,
|
|
1064
|
-
loader: loaders
|
|
1098
|
+
loader: loaders,
|
|
1099
|
+
// Provide a require() polyfill for ESM bundles containing CommonJS packages.
|
|
1100
|
+
// Some bundled packages (e.g., 'scmp' used by 'mongodb-level') use require('crypto').
|
|
1101
|
+
// When esbuild inlines these CommonJS packages, it keeps the require() calls,
|
|
1102
|
+
// but ESM doesn't have a global require. This banner creates one using Node.js's
|
|
1103
|
+
// official createRequire API, allowing the bundled CommonJS code to work in ESM.
|
|
1104
|
+
banner: {
|
|
1105
|
+
js: `import { createRequire } from 'module';const require = createRequire(import.meta.url);`
|
|
1106
|
+
}
|
|
1065
1107
|
});
|
|
1066
|
-
const result =
|
|
1067
|
-
|
|
1108
|
+
const result = await import(pathToFileURL(outfile).href);
|
|
1109
|
+
fs2.removeSync(outfile);
|
|
1068
1110
|
return result.default;
|
|
1069
1111
|
}
|
|
1070
1112
|
async loadConfigFile(generatedFolderPath, configFilePath) {
|
|
1071
|
-
const tmpdir =
|
|
1072
|
-
const preBuildConfigPath =
|
|
1113
|
+
const tmpdir = path3.join(os.tmpdir(), Date.now().toString());
|
|
1114
|
+
const preBuildConfigPath = path3.join(
|
|
1073
1115
|
this.generatedFolderPath,
|
|
1074
1116
|
"config.prebuild.jsx"
|
|
1075
1117
|
);
|
|
1076
|
-
const outfile =
|
|
1077
|
-
const outfile2 =
|
|
1078
|
-
const tempTSConfigFile =
|
|
1079
|
-
|
|
1118
|
+
const outfile = path3.join(tmpdir, "config.build.jsx");
|
|
1119
|
+
const outfile2 = path3.join(tmpdir, "config.build.mjs");
|
|
1120
|
+
const tempTSConfigFile = path3.join(tmpdir, "tsconfig.json");
|
|
1121
|
+
const esmRequireBanner = {
|
|
1122
|
+
js: `import { createRequire } from 'module';const require = createRequire(import.meta.url);`
|
|
1123
|
+
};
|
|
1124
|
+
fs2.outputFileSync(tempTSConfigFile, "{}");
|
|
1080
1125
|
const result2 = await esbuild.build({
|
|
1081
1126
|
entryPoints: [configFilePath],
|
|
1082
1127
|
bundle: true,
|
|
1083
|
-
target: ["
|
|
1128
|
+
target: ["esnext"],
|
|
1084
1129
|
platform: "browser",
|
|
1085
1130
|
format: "esm",
|
|
1086
1131
|
logLevel: "silent",
|
|
@@ -1100,31 +1145,34 @@ var ConfigManager = class {
|
|
|
1100
1145
|
await esbuild.build({
|
|
1101
1146
|
entryPoints: [configFilePath],
|
|
1102
1147
|
bundle: true,
|
|
1103
|
-
target: ["
|
|
1148
|
+
target: ["esnext"],
|
|
1104
1149
|
logLevel: "silent",
|
|
1105
1150
|
platform: "node",
|
|
1151
|
+
format: "esm",
|
|
1106
1152
|
outfile,
|
|
1107
|
-
loader: loaders
|
|
1153
|
+
loader: loaders,
|
|
1154
|
+
banner: esmRequireBanner
|
|
1108
1155
|
});
|
|
1109
1156
|
await esbuild.build({
|
|
1110
1157
|
entryPoints: [outfile],
|
|
1111
1158
|
bundle: true,
|
|
1112
|
-
// Suppress warning about comparison with -0 from client module
|
|
1113
1159
|
logLevel: "silent",
|
|
1114
1160
|
platform: "node",
|
|
1161
|
+
target: ["esnext"],
|
|
1162
|
+
format: "esm",
|
|
1115
1163
|
outfile: outfile2,
|
|
1116
1164
|
loader: loaders
|
|
1117
1165
|
});
|
|
1118
1166
|
let result;
|
|
1119
1167
|
try {
|
|
1120
|
-
result =
|
|
1168
|
+
result = await import(pathToFileURL(outfile2).href);
|
|
1121
1169
|
} catch (e) {
|
|
1122
1170
|
console.error("Unexpected error loading config");
|
|
1123
1171
|
console.error(e);
|
|
1124
1172
|
throw e;
|
|
1125
1173
|
}
|
|
1126
|
-
|
|
1127
|
-
|
|
1174
|
+
fs2.removeSync(outfile);
|
|
1175
|
+
fs2.removeSync(outfile2);
|
|
1128
1176
|
return {
|
|
1129
1177
|
config: result.default,
|
|
1130
1178
|
prebuildPath: preBuildConfigPath,
|
|
@@ -1159,20 +1207,24 @@ var loaders = {
|
|
|
1159
1207
|
};
|
|
1160
1208
|
|
|
1161
1209
|
// src/next/database.ts
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1210
|
+
import {
|
|
1211
|
+
createDatabaseInternal,
|
|
1212
|
+
FilesystemBridge,
|
|
1213
|
+
TinaLevelClient
|
|
1214
|
+
} from "@tinacms/graphql";
|
|
1215
|
+
import { pipeline } from "readable-stream";
|
|
1216
|
+
import { createServer } from "net";
|
|
1217
|
+
import { ManyLevelHost } from "many-level";
|
|
1218
|
+
import { MemoryLevel } from "memory-level";
|
|
1167
1219
|
var createDBServer = (port) => {
|
|
1168
|
-
const levelHost = new
|
|
1220
|
+
const levelHost = new ManyLevelHost(
|
|
1169
1221
|
// @ts-ignore
|
|
1170
|
-
new
|
|
1222
|
+
new MemoryLevel({
|
|
1171
1223
|
valueEncoding: "json"
|
|
1172
1224
|
})
|
|
1173
1225
|
);
|
|
1174
|
-
const dbServer =
|
|
1175
|
-
return
|
|
1226
|
+
const dbServer = createServer(function(socket) {
|
|
1227
|
+
return pipeline(socket, levelHost.createRpcStream(), socket, () => {
|
|
1176
1228
|
});
|
|
1177
1229
|
});
|
|
1178
1230
|
dbServer.once("error", (err) => {
|
|
@@ -1186,7 +1238,7 @@ var createDBServer = (port) => {
|
|
|
1186
1238
|
};
|
|
1187
1239
|
async function createAndInitializeDatabase(configManager, datalayerPort, bridgeOverride) {
|
|
1188
1240
|
let database;
|
|
1189
|
-
const bridge = bridgeOverride || new
|
|
1241
|
+
const bridge = bridgeOverride || new FilesystemBridge(configManager.rootPath, configManager.contentRootPath);
|
|
1190
1242
|
if (configManager.hasSelfHostedConfig() && configManager.config.contentApiUrlOverride) {
|
|
1191
1243
|
database = await configManager.loadDatabaseFile();
|
|
1192
1244
|
database.bridge = bridge;
|
|
@@ -1198,9 +1250,9 @@ async function createAndInitializeDatabase(configManager, datalayerPort, bridgeO
|
|
|
1198
1250
|
)} but there was no "contentApiUrlOverride" set. Falling back to built-in datalayer`
|
|
1199
1251
|
);
|
|
1200
1252
|
}
|
|
1201
|
-
const level = new
|
|
1253
|
+
const level = new TinaLevelClient(datalayerPort);
|
|
1202
1254
|
level.openConnection();
|
|
1203
|
-
database =
|
|
1255
|
+
database = createDatabaseInternal({
|
|
1204
1256
|
bridge,
|
|
1205
1257
|
level,
|
|
1206
1258
|
tinaDirectory: configManager.isUsingLegacyFolder ? LEGACY_TINA_FOLDER : TINA_FOLDER
|
|
@@ -1210,17 +1262,17 @@ async function createAndInitializeDatabase(configManager, datalayerPort, bridgeO
|
|
|
1210
1262
|
}
|
|
1211
1263
|
|
|
1212
1264
|
// src/next/commands/baseCommands.ts
|
|
1213
|
-
|
|
1214
|
-
|
|
1265
|
+
import { Command, Option } from "clipanion";
|
|
1266
|
+
import chalk4 from "chalk";
|
|
1215
1267
|
|
|
1216
1268
|
// src/utils/start-subprocess.ts
|
|
1217
|
-
|
|
1269
|
+
import childProcess from "child_process";
|
|
1218
1270
|
var startSubprocess2 = async ({ command: command2 }) => {
|
|
1219
1271
|
if (typeof command2 === "string") {
|
|
1220
1272
|
const commands = command2.split(" ");
|
|
1221
1273
|
const firstCommand = commands[0];
|
|
1222
1274
|
const args = commands.slice(1) || [];
|
|
1223
|
-
const ps =
|
|
1275
|
+
const ps = childProcess.spawn(firstCommand, args, {
|
|
1224
1276
|
stdio: "inherit",
|
|
1225
1277
|
shell: true
|
|
1226
1278
|
});
|
|
@@ -1244,45 +1296,42 @@ stack: ${code.stack || "No stack was provided"}`);
|
|
|
1244
1296
|
};
|
|
1245
1297
|
|
|
1246
1298
|
// src/next/commands/baseCommands.ts
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
var BaseCommand = class extends
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
description: "Disable anonymous telemetry that is collected"
|
|
1278
|
-
});
|
|
1279
|
-
}
|
|
1299
|
+
import { getChangedFiles, getSha, shaExists } from "@tinacms/graphql";
|
|
1300
|
+
import fs3 from "fs-extra";
|
|
1301
|
+
var BaseCommand = class extends Command {
|
|
1302
|
+
experimentalDataLayer = Option.Boolean("--experimentalData", {
|
|
1303
|
+
description: "DEPRECATED - Build the server with additional data querying capabilities"
|
|
1304
|
+
});
|
|
1305
|
+
isomorphicGitBridge = Option.Boolean("--isomorphicGitBridge", {
|
|
1306
|
+
description: "DEPRECATED - Enable Isomorphic Git Bridge Implementation"
|
|
1307
|
+
});
|
|
1308
|
+
port = Option.String("-p,--port", "4001", {
|
|
1309
|
+
description: "Specify a port to run the server on. (default 4001)"
|
|
1310
|
+
});
|
|
1311
|
+
datalayerPort = Option.String("--datalayer-port", "9000", {
|
|
1312
|
+
description: "Specify a port to run the datalayer server on. (default 9000)"
|
|
1313
|
+
});
|
|
1314
|
+
subCommand = Option.String("-c,--command", {
|
|
1315
|
+
description: "The sub-command to run"
|
|
1316
|
+
});
|
|
1317
|
+
rootPath = Option.String("--rootPath", {
|
|
1318
|
+
description: "Specify the root directory to run the CLI from (defaults to current working directory)"
|
|
1319
|
+
});
|
|
1320
|
+
verbose = Option.Boolean("-v,--verbose", false, {
|
|
1321
|
+
description: "increase verbosity of logged output"
|
|
1322
|
+
});
|
|
1323
|
+
noSDK = Option.Boolean("--noSDK", false, {
|
|
1324
|
+
description: "DEPRECATED - This should now be set in the config at client.skip = true'. Don't generate the generated client SDK"
|
|
1325
|
+
});
|
|
1326
|
+
noTelemetry = Option.Boolean("--noTelemetry", false, {
|
|
1327
|
+
description: "Disable anonymous telemetry that is collected"
|
|
1328
|
+
});
|
|
1280
1329
|
async startSubCommand() {
|
|
1281
1330
|
let subProc;
|
|
1282
1331
|
if (this.subCommand) {
|
|
1283
1332
|
subProc = await startSubprocess2({ command: this.subCommand });
|
|
1284
1333
|
logger.info(
|
|
1285
|
-
`Running web application with command: ${
|
|
1334
|
+
`Running web application with command: ${chalk4.cyan(this.subCommand)}`
|
|
1286
1335
|
);
|
|
1287
1336
|
}
|
|
1288
1337
|
function exitHandler(options, exitCode) {
|
|
@@ -1330,7 +1379,7 @@ var BaseCommand = class extends import_clipanion.Command {
|
|
|
1330
1379
|
const rootPath = configManager.rootPath;
|
|
1331
1380
|
let sha;
|
|
1332
1381
|
try {
|
|
1333
|
-
sha = await
|
|
1382
|
+
sha = await getSha({ fs: fs3, dir: rootPath });
|
|
1334
1383
|
} catch (e) {
|
|
1335
1384
|
if (partialReindex) {
|
|
1336
1385
|
console.error(
|
|
@@ -1340,7 +1389,7 @@ var BaseCommand = class extends import_clipanion.Command {
|
|
|
1340
1389
|
}
|
|
1341
1390
|
}
|
|
1342
1391
|
const lastSha = await database.getMetadata("lastSha");
|
|
1343
|
-
const exists = lastSha && await
|
|
1392
|
+
const exists = lastSha && await shaExists({ fs: fs3, dir: rootPath, sha: lastSha });
|
|
1344
1393
|
let res;
|
|
1345
1394
|
if (partialReindex && lastSha && exists && sha) {
|
|
1346
1395
|
const pathFilter = {};
|
|
@@ -1354,8 +1403,8 @@ var BaseCommand = class extends import_clipanion.Command {
|
|
|
1354
1403
|
matches: collection.match?.exclude || collection.match?.include ? tinaSchema.getMatches({ collection }) : void 0
|
|
1355
1404
|
};
|
|
1356
1405
|
}
|
|
1357
|
-
const { added, modified, deleted } = await
|
|
1358
|
-
fs:
|
|
1406
|
+
const { added, modified, deleted } = await getChangedFiles({
|
|
1407
|
+
fs: fs3,
|
|
1359
1408
|
dir: rootPath,
|
|
1360
1409
|
from: lastSha,
|
|
1361
1410
|
to: sha,
|
|
@@ -1478,34 +1527,38 @@ var devHTML = (port) => `<!DOCTYPE html>
|
|
|
1478
1527
|
</html>`;
|
|
1479
1528
|
|
|
1480
1529
|
// src/next/commands/dev-command/server/index.ts
|
|
1481
|
-
|
|
1530
|
+
import { createServer as createViteServer } from "vite";
|
|
1482
1531
|
|
|
1483
1532
|
// src/next/vite/index.ts
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1533
|
+
import path5 from "node:path";
|
|
1534
|
+
import react from "@vitejs/plugin-react";
|
|
1535
|
+
import fs4 from "fs-extra";
|
|
1536
|
+
import normalizePath3 from "normalize-path";
|
|
1537
|
+
import {
|
|
1538
|
+
splitVendorChunkPlugin
|
|
1539
|
+
} from "vite";
|
|
1489
1540
|
|
|
1490
1541
|
// src/next/vite/tailwind.ts
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1542
|
+
import path4 from "node:path";
|
|
1543
|
+
import aspectRatio from "@tailwindcss/aspect-ratio";
|
|
1544
|
+
import containerQueries from "@tailwindcss/container-queries";
|
|
1545
|
+
import twTypography from "@tailwindcss/typography";
|
|
1546
|
+
import tailwind from "tailwindcss";
|
|
1547
|
+
import defaultTheme from "tailwindcss/defaultTheme.js";
|
|
1548
|
+
import { createRequire as createRequire2 } from "module";
|
|
1497
1549
|
var tinaTailwind = (spaPath, prebuildFilePath) => {
|
|
1498
1550
|
return {
|
|
1499
1551
|
name: "vite-plugin-tina",
|
|
1500
1552
|
// @ts-ignore
|
|
1501
1553
|
config: (viteConfig) => {
|
|
1554
|
+
const require2 = createRequire2(import.meta.url);
|
|
1502
1555
|
const plugins = [];
|
|
1503
1556
|
const content = [
|
|
1504
|
-
|
|
1557
|
+
path4.join(spaPath, "src/**/*.{vue,js,ts,jsx,tsx,svelte}"),
|
|
1505
1558
|
prebuildFilePath,
|
|
1506
|
-
|
|
1559
|
+
require2.resolve("tinacms")
|
|
1507
1560
|
];
|
|
1508
|
-
const tw = (
|
|
1561
|
+
const tw = tailwind({
|
|
1509
1562
|
theme: {
|
|
1510
1563
|
columns: {
|
|
1511
1564
|
auto: "auto",
|
|
@@ -1694,6 +1747,8 @@ var tinaTailwind = (spaPath, prebuildFilePath) => {
|
|
|
1694
1747
|
600: "#DC4419"
|
|
1695
1748
|
},
|
|
1696
1749
|
"tina-orange": "#EC4815",
|
|
1750
|
+
"tina-orange-dark": "#C2410C",
|
|
1751
|
+
"tina-orange-light": "#FFF7ED",
|
|
1697
1752
|
background: "#FFFFFF",
|
|
1698
1753
|
foreground: "#0A0A0A",
|
|
1699
1754
|
muted: "#F5F5F5",
|
|
@@ -1715,7 +1770,7 @@ var tinaTailwind = (spaPath, prebuildFilePath) => {
|
|
|
1715
1770
|
ring: "#0A0A0A"
|
|
1716
1771
|
},
|
|
1717
1772
|
fontFamily: {
|
|
1718
|
-
sans: ["Inter", ...
|
|
1773
|
+
sans: ["Inter", ...defaultTheme.fontFamily.sans]
|
|
1719
1774
|
},
|
|
1720
1775
|
lineHeight: {
|
|
1721
1776
|
3: "12px",
|
|
@@ -1740,9 +1795,9 @@ var tinaTailwind = (spaPath, prebuildFilePath) => {
|
|
|
1740
1795
|
},
|
|
1741
1796
|
content,
|
|
1742
1797
|
plugins: [
|
|
1743
|
-
(
|
|
1744
|
-
|
|
1745
|
-
|
|
1798
|
+
twTypography({ className: "tina-prose" }),
|
|
1799
|
+
aspectRatio,
|
|
1800
|
+
containerQueries
|
|
1746
1801
|
]
|
|
1747
1802
|
});
|
|
1748
1803
|
plugins.push(tw);
|
|
@@ -1763,35 +1818,35 @@ async function listFilesRecursively({
|
|
|
1763
1818
|
config: config2,
|
|
1764
1819
|
roothPath
|
|
1765
1820
|
}) {
|
|
1766
|
-
const fullDirectoryPath =
|
|
1821
|
+
const fullDirectoryPath = path5.join(
|
|
1767
1822
|
roothPath,
|
|
1768
1823
|
config2.publicFolder,
|
|
1769
1824
|
directoryPath
|
|
1770
1825
|
);
|
|
1771
|
-
const exists = await
|
|
1826
|
+
const exists = await fs4.pathExists(fullDirectoryPath);
|
|
1772
1827
|
if (!exists) {
|
|
1773
1828
|
return { "0": [] };
|
|
1774
1829
|
}
|
|
1775
|
-
const items = await
|
|
1830
|
+
const items = await fs4.readdir(fullDirectoryPath);
|
|
1776
1831
|
const staticMediaItems = [];
|
|
1777
1832
|
for (const item of items) {
|
|
1778
|
-
const itemPath =
|
|
1779
|
-
const stats = await
|
|
1833
|
+
const itemPath = path5.join(fullDirectoryPath, item);
|
|
1834
|
+
const stats = await fs4.promises.lstat(itemPath);
|
|
1780
1835
|
const staticMediaItem = {
|
|
1781
1836
|
id: item,
|
|
1782
1837
|
filename: item,
|
|
1783
1838
|
type: stats.isDirectory() ? "dir" : "file",
|
|
1784
1839
|
directory: `${directoryPath.replace(config2.mediaRoot, "")}`,
|
|
1785
|
-
src: `/${
|
|
1840
|
+
src: `/${path5.join(directoryPath, item)}`,
|
|
1786
1841
|
thumbnails: {
|
|
1787
|
-
"75x75": `/${
|
|
1788
|
-
"400x400": `/${
|
|
1789
|
-
"1000x1000": `/${
|
|
1842
|
+
"75x75": `/${path5.join(directoryPath, item)}`,
|
|
1843
|
+
"400x400": `/${path5.join(directoryPath, item)}`,
|
|
1844
|
+
"1000x1000": `/${path5.join(directoryPath, item)}`
|
|
1790
1845
|
}
|
|
1791
1846
|
};
|
|
1792
1847
|
if (stats.isDirectory()) {
|
|
1793
1848
|
staticMediaItem.children = await listFilesRecursively({
|
|
1794
|
-
directoryPath:
|
|
1849
|
+
directoryPath: path5.join(directoryPath, item),
|
|
1795
1850
|
config: config2,
|
|
1796
1851
|
roothPath
|
|
1797
1852
|
});
|
|
@@ -1832,7 +1887,7 @@ var createConfig = async ({
|
|
|
1832
1887
|
}
|
|
1833
1888
|
}
|
|
1834
1889
|
});
|
|
1835
|
-
const staticMediaPath =
|
|
1890
|
+
const staticMediaPath = path5.join(
|
|
1836
1891
|
configManager.generatedFolderPath,
|
|
1837
1892
|
"static-media.json"
|
|
1838
1893
|
);
|
|
@@ -1842,21 +1897,21 @@ var createConfig = async ({
|
|
|
1842
1897
|
config: configManager.config.media.tina,
|
|
1843
1898
|
roothPath: configManager.rootPath
|
|
1844
1899
|
});
|
|
1845
|
-
await
|
|
1900
|
+
await fs4.outputFile(staticMediaPath, JSON.stringify(staticMedia, null, 2));
|
|
1846
1901
|
} else {
|
|
1847
|
-
await
|
|
1902
|
+
await fs4.outputFile(staticMediaPath, `[]`);
|
|
1848
1903
|
}
|
|
1849
1904
|
const alias = {
|
|
1850
1905
|
TINA_IMPORT: configManager.prebuildFilePath,
|
|
1851
1906
|
SCHEMA_IMPORT: configManager.generatedGraphQLJSONPath,
|
|
1852
1907
|
STATIC_MEDIA_IMPORT: staticMediaPath,
|
|
1853
|
-
crypto:
|
|
1854
|
-
fs:
|
|
1855
|
-
os:
|
|
1856
|
-
path:
|
|
1908
|
+
crypto: path5.join(configManager.spaRootPath, "src", "dummy-client.ts"),
|
|
1909
|
+
fs: path5.join(configManager.spaRootPath, "src", "dummy-client.ts"),
|
|
1910
|
+
os: path5.join(configManager.spaRootPath, "src", "dummy-client.ts"),
|
|
1911
|
+
path: path5.join(configManager.spaRootPath, "src", "dummy-client.ts")
|
|
1857
1912
|
};
|
|
1858
1913
|
if (configManager.shouldSkipSDK()) {
|
|
1859
|
-
alias["CLIENT_IMPORT"] =
|
|
1914
|
+
alias["CLIENT_IMPORT"] = path5.join(
|
|
1860
1915
|
configManager.spaRootPath,
|
|
1861
1916
|
"src",
|
|
1862
1917
|
"dummy-client.ts"
|
|
@@ -1872,7 +1927,7 @@ var createConfig = async ({
|
|
|
1872
1927
|
const version2 = `${fullVersion.major}.${fullVersion.minor}`;
|
|
1873
1928
|
const config2 = {
|
|
1874
1929
|
root: configManager.spaRootPath,
|
|
1875
|
-
base: `/${basePath ? `${(
|
|
1930
|
+
base: `/${basePath ? `${normalizePath3(basePath)}/` : ""}${normalizePath3(
|
|
1876
1931
|
configManager.config.build.outputFolder
|
|
1877
1932
|
)}/`,
|
|
1878
1933
|
appType: "spa",
|
|
@@ -1935,14 +1990,14 @@ var createConfig = async ({
|
|
|
1935
1990
|
* `splitVendorChunkPlugin` is needed because `tinacms` is quite large,
|
|
1936
1991
|
* Vite's chunking strategy chokes on memory issues for smaller machines (ie. on CI).
|
|
1937
1992
|
*/
|
|
1938
|
-
(
|
|
1993
|
+
react({
|
|
1939
1994
|
babel: {
|
|
1940
1995
|
// Supresses the warning [NOTE] babel The code generator has deoptimised the styling of
|
|
1941
1996
|
compact: true
|
|
1942
1997
|
},
|
|
1943
1998
|
fastRefresh: false
|
|
1944
1999
|
}),
|
|
1945
|
-
|
|
2000
|
+
splitVendorChunkPlugin(),
|
|
1946
2001
|
tinaTailwind(configManager.spaRootPath, configManager.prebuildFilePath),
|
|
1947
2002
|
...plugins
|
|
1948
2003
|
]
|
|
@@ -1951,21 +2006,21 @@ var createConfig = async ({
|
|
|
1951
2006
|
};
|
|
1952
2007
|
|
|
1953
2008
|
// src/next/vite/plugins.ts
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
2009
|
+
import { createFilter } from "@rollup/pluginutils";
|
|
2010
|
+
import fs6 from "fs";
|
|
2011
|
+
import { transformWithEsbuild } from "vite";
|
|
2012
|
+
import { transform as esbuildTransform } from "esbuild";
|
|
2013
|
+
import path7 from "path";
|
|
2014
|
+
import bodyParser from "body-parser";
|
|
2015
|
+
import cors from "cors";
|
|
2016
|
+
import { resolve as gqlResolve } from "@tinacms/graphql";
|
|
1962
2017
|
|
|
1963
2018
|
// src/next/commands/dev-command/server/media.ts
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
2019
|
+
import fs5 from "fs-extra";
|
|
2020
|
+
import path6, { join } from "path";
|
|
2021
|
+
import busboy from "busboy";
|
|
1967
2022
|
var createMediaRouter = (config2) => {
|
|
1968
|
-
const mediaFolder =
|
|
2023
|
+
const mediaFolder = path6.join(
|
|
1969
2024
|
config2.rootPath,
|
|
1970
2025
|
config2.publicFolder,
|
|
1971
2026
|
config2.mediaRoot
|
|
@@ -1989,12 +2044,12 @@ var createMediaRouter = (config2) => {
|
|
|
1989
2044
|
res.end(JSON.stringify(didDelete));
|
|
1990
2045
|
};
|
|
1991
2046
|
const handlePost = async function(req, res) {
|
|
1992
|
-
const bb = (
|
|
2047
|
+
const bb = busboy({ headers: req.headers });
|
|
1993
2048
|
bb.on("file", async (_name, file, _info) => {
|
|
1994
2049
|
const fullPath = decodeURI(req.url?.slice("/media/upload/".length));
|
|
1995
|
-
const saveTo =
|
|
1996
|
-
await
|
|
1997
|
-
file.pipe(
|
|
2050
|
+
const saveTo = path6.join(mediaFolder, ...fullPath.split("/"));
|
|
2051
|
+
await fs5.ensureDir(path6.dirname(saveTo));
|
|
2052
|
+
file.pipe(fs5.createWriteStream(saveTo));
|
|
1998
2053
|
});
|
|
1999
2054
|
bb.on("error", (error) => {
|
|
2000
2055
|
res.statusCode = 500;
|
|
@@ -2020,6 +2075,9 @@ var parseMediaFolder = (str) => {
|
|
|
2020
2075
|
return returnString;
|
|
2021
2076
|
};
|
|
2022
2077
|
var MediaModel = class {
|
|
2078
|
+
rootPath;
|
|
2079
|
+
publicFolder;
|
|
2080
|
+
mediaRoot;
|
|
2023
2081
|
constructor({ rootPath, publicFolder, mediaRoot }) {
|
|
2024
2082
|
this.rootPath = rootPath;
|
|
2025
2083
|
this.mediaRoot = mediaRoot;
|
|
@@ -2027,23 +2085,23 @@ var MediaModel = class {
|
|
|
2027
2085
|
}
|
|
2028
2086
|
async listMedia(args) {
|
|
2029
2087
|
try {
|
|
2030
|
-
const folderPath =
|
|
2088
|
+
const folderPath = join(
|
|
2031
2089
|
this.rootPath,
|
|
2032
2090
|
this.publicFolder,
|
|
2033
2091
|
this.mediaRoot,
|
|
2034
2092
|
decodeURIComponent(args.searchPath)
|
|
2035
2093
|
);
|
|
2036
2094
|
const searchPath = parseMediaFolder(args.searchPath);
|
|
2037
|
-
if (!await
|
|
2095
|
+
if (!await fs5.pathExists(folderPath)) {
|
|
2038
2096
|
return {
|
|
2039
2097
|
files: [],
|
|
2040
2098
|
directories: []
|
|
2041
2099
|
};
|
|
2042
2100
|
}
|
|
2043
|
-
const filesStr = await
|
|
2101
|
+
const filesStr = await fs5.readdir(folderPath);
|
|
2044
2102
|
const filesProm = filesStr.map(async (file) => {
|
|
2045
|
-
const filePath =
|
|
2046
|
-
const stat = await
|
|
2103
|
+
const filePath = join(folderPath, file);
|
|
2104
|
+
const stat = await fs5.stat(filePath);
|
|
2047
2105
|
let src = `/${file}`;
|
|
2048
2106
|
const isFile = stat.isFile();
|
|
2049
2107
|
if (!isFile) {
|
|
@@ -2099,14 +2157,14 @@ var MediaModel = class {
|
|
|
2099
2157
|
}
|
|
2100
2158
|
async deleteMedia(args) {
|
|
2101
2159
|
try {
|
|
2102
|
-
const file =
|
|
2160
|
+
const file = join(
|
|
2103
2161
|
this.rootPath,
|
|
2104
2162
|
this.publicFolder,
|
|
2105
2163
|
this.mediaRoot,
|
|
2106
2164
|
decodeURIComponent(args.searchPath)
|
|
2107
2165
|
);
|
|
2108
|
-
await
|
|
2109
|
-
await
|
|
2166
|
+
await fs5.stat(file);
|
|
2167
|
+
await fs5.remove(file);
|
|
2110
2168
|
return { ok: true };
|
|
2111
2169
|
} catch (error) {
|
|
2112
2170
|
console.error(error);
|
|
@@ -2164,9 +2222,9 @@ var transformTsxPlugin = ({
|
|
|
2164
2222
|
const plug = {
|
|
2165
2223
|
name: "transform-tsx",
|
|
2166
2224
|
async transform(code, id) {
|
|
2167
|
-
const extName =
|
|
2225
|
+
const extName = path7.extname(id);
|
|
2168
2226
|
if (extName.startsWith(".tsx") || extName.startsWith(".ts")) {
|
|
2169
|
-
const result = await (
|
|
2227
|
+
const result = await esbuildTransform(code, { loader: "tsx" });
|
|
2170
2228
|
return {
|
|
2171
2229
|
code: result.code
|
|
2172
2230
|
};
|
|
@@ -2185,8 +2243,8 @@ var devServerEndPointsPlugin = ({
|
|
|
2185
2243
|
const plug = {
|
|
2186
2244
|
name: "graphql-endpoints",
|
|
2187
2245
|
configureServer(server) {
|
|
2188
|
-
server.middlewares.use((
|
|
2189
|
-
server.middlewares.use(
|
|
2246
|
+
server.middlewares.use(cors());
|
|
2247
|
+
server.middlewares.use(bodyParser.json({ limit: "5mb" }));
|
|
2190
2248
|
server.middlewares.use(async (req, res, next) => {
|
|
2191
2249
|
const mediaPaths = configManager.config.media?.tina;
|
|
2192
2250
|
const mediaRouter = createMediaRouter({
|
|
@@ -2225,7 +2283,7 @@ var devServerEndPointsPlugin = ({
|
|
|
2225
2283
|
const { query, variables } = req.body;
|
|
2226
2284
|
let result;
|
|
2227
2285
|
await databaseLock(async () => {
|
|
2228
|
-
result = await (
|
|
2286
|
+
result = await gqlResolve({
|
|
2229
2287
|
config: {
|
|
2230
2288
|
useRelativeMedia: true
|
|
2231
2289
|
},
|
|
@@ -2261,13 +2319,13 @@ function viteTransformExtension({
|
|
|
2261
2319
|
include = "**/*.svg",
|
|
2262
2320
|
exclude
|
|
2263
2321
|
} = {}) {
|
|
2264
|
-
const filter =
|
|
2322
|
+
const filter = createFilter(include, exclude);
|
|
2265
2323
|
return {
|
|
2266
2324
|
name: "vite-plugin-svgr",
|
|
2267
2325
|
async transform(code, id) {
|
|
2268
2326
|
if (filter(id)) {
|
|
2269
2327
|
const { transform: transform2 } = await import("@svgr/core");
|
|
2270
|
-
const svgCode = await
|
|
2328
|
+
const svgCode = await fs6.promises.readFile(
|
|
2271
2329
|
id.replace(/\?.*$/, ""),
|
|
2272
2330
|
"utf8"
|
|
2273
2331
|
);
|
|
@@ -2277,7 +2335,7 @@ function viteTransformExtension({
|
|
|
2277
2335
|
previousExport: exportAsDefault ? null : code
|
|
2278
2336
|
}
|
|
2279
2337
|
});
|
|
2280
|
-
const res = await
|
|
2338
|
+
const res = await transformWithEsbuild(componentCode, id, {
|
|
2281
2339
|
loader: "jsx",
|
|
2282
2340
|
...esbuildOptions
|
|
2283
2341
|
});
|
|
@@ -2304,7 +2362,7 @@ var createDevServer = async (configManager, database, searchIndex, apiURL, noWat
|
|
|
2304
2362
|
}),
|
|
2305
2363
|
viteTransformExtension()
|
|
2306
2364
|
];
|
|
2307
|
-
return (
|
|
2365
|
+
return createViteServer(
|
|
2308
2366
|
await createConfig({
|
|
2309
2367
|
configManager,
|
|
2310
2368
|
database,
|
|
@@ -2334,37 +2392,30 @@ var createDevServer = async (configManager, database, searchIndex, apiURL, noWat
|
|
|
2334
2392
|
|
|
2335
2393
|
// src/next/commands/dev-command/index.ts
|
|
2336
2394
|
var DevCommand = class extends BaseCommand {
|
|
2337
|
-
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
this
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
-
|
|
2344
|
-
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
|
|
2348
|
-
|
|
2349
|
-
|
|
2350
|
-
|
|
2351
|
-
|
|
2352
|
-
|
|
2353
|
-
|
|
2354
|
-
|
|
2355
|
-
|
|
2356
|
-
|
|
2357
|
-
|
|
2358
|
-
|
|
2359
|
-
|
|
2360
|
-
|
|
2361
|
-
description: `Builds Tina and starts the dev server`,
|
|
2362
|
-
examples: [
|
|
2363
|
-
[`A basic example`, `$0 dev`],
|
|
2364
|
-
[`A second example`, `$0 dev --rootPath`]
|
|
2365
|
-
]
|
|
2366
|
-
});
|
|
2367
|
-
}
|
|
2395
|
+
static paths = [["dev"], ["server:start"]];
|
|
2396
|
+
// NOTE: camelCase commands for string options don't work if there's an `=` used https://github.com/arcanis/clipanion/issues/141
|
|
2397
|
+
watchFolders = Option2.String("-w,--watchFolders", {
|
|
2398
|
+
description: "DEPRECATED - a list of folders (relative to where this is being run) that the cli will watch for changes"
|
|
2399
|
+
});
|
|
2400
|
+
noWatch = Option2.Boolean("--noWatch", false, {
|
|
2401
|
+
description: "Don't regenerate config on file changes"
|
|
2402
|
+
});
|
|
2403
|
+
outputSearchIndexPath = Option2.String("--outputSearchIndexPath", {
|
|
2404
|
+
description: "Path to write the search index to"
|
|
2405
|
+
});
|
|
2406
|
+
noServer = Option2.Boolean("--no-server", false, {
|
|
2407
|
+
description: "Do not start the dev server"
|
|
2408
|
+
});
|
|
2409
|
+
indexingLock = new AsyncLock();
|
|
2410
|
+
// Prevent indexes and reads occurring at once
|
|
2411
|
+
static usage = Command2.Usage({
|
|
2412
|
+
category: `Commands`,
|
|
2413
|
+
description: `Builds Tina and starts the dev server`,
|
|
2414
|
+
examples: [
|
|
2415
|
+
[`A basic example`, `$0 dev`],
|
|
2416
|
+
[`A second example`, `$0 dev --rootPath`]
|
|
2417
|
+
]
|
|
2418
|
+
});
|
|
2368
2419
|
async catch(error) {
|
|
2369
2420
|
logger.error("Error occured during tinacms dev");
|
|
2370
2421
|
console.error(error);
|
|
@@ -2401,7 +2452,7 @@ var DevCommand = class extends BaseCommand {
|
|
|
2401
2452
|
} else {
|
|
2402
2453
|
database.clearCache();
|
|
2403
2454
|
}
|
|
2404
|
-
const { tinaSchema: tinaSchema2, graphQLSchema: graphQLSchema2, lookup, queryDoc, fragDoc } = await
|
|
2455
|
+
const { tinaSchema: tinaSchema2, graphQLSchema: graphQLSchema2, lookup, queryDoc, fragDoc } = await buildSchema(configManager.config);
|
|
2405
2456
|
const codegen2 = new Codegen({
|
|
2406
2457
|
isLocal: true,
|
|
2407
2458
|
configManager,
|
|
@@ -2415,29 +2466,32 @@ var DevCommand = class extends BaseCommand {
|
|
|
2415
2466
|
});
|
|
2416
2467
|
const apiURL2 = await codegen2.execute();
|
|
2417
2468
|
if (!configManager.isUsingLegacyFolder) {
|
|
2418
|
-
|
|
2419
|
-
|
|
2420
|
-
|
|
2421
|
-
const
|
|
2422
|
-
|
|
2423
|
-
|
|
2469
|
+
const schemaObject = await fs7.readJSON(
|
|
2470
|
+
configManager.generatedSchemaJSONPath
|
|
2471
|
+
);
|
|
2472
|
+
const lookupObject = await fs7.readJSON(
|
|
2473
|
+
configManager.generatedLookupJSONPath
|
|
2474
|
+
);
|
|
2475
|
+
const graphqlSchemaObject = await fs7.readJSON(
|
|
2476
|
+
configManager.generatedGraphQLJSONPath
|
|
2477
|
+
);
|
|
2424
2478
|
const tinaLockFilename = "tina-lock.json";
|
|
2425
2479
|
const tinaLockContent = JSON.stringify({
|
|
2426
2480
|
schema: schemaObject,
|
|
2427
2481
|
lookup: lookupObject,
|
|
2428
2482
|
graphql: graphqlSchemaObject
|
|
2429
2483
|
});
|
|
2430
|
-
|
|
2431
|
-
|
|
2484
|
+
fs7.writeFileSync(
|
|
2485
|
+
path8.join(configManager.tinaFolderPath, tinaLockFilename),
|
|
2432
2486
|
tinaLockContent
|
|
2433
2487
|
);
|
|
2434
2488
|
if (configManager.hasSeparateContentRoot()) {
|
|
2435
2489
|
const rootPath = await configManager.getTinaFolderPath(
|
|
2436
2490
|
configManager.contentRootPath
|
|
2437
2491
|
);
|
|
2438
|
-
const filePath =
|
|
2439
|
-
await
|
|
2440
|
-
await
|
|
2492
|
+
const filePath = path8.join(rootPath, tinaLockFilename);
|
|
2493
|
+
await fs7.ensureFile(filePath);
|
|
2494
|
+
await fs7.outputFile(filePath, tinaLockContent);
|
|
2441
2495
|
}
|
|
2442
2496
|
}
|
|
2443
2497
|
await this.indexContentWithSpinner({
|
|
@@ -2480,19 +2534,19 @@ ${dangerText(e.message)}
|
|
|
2480
2534
|
const { apiURL, graphQLSchema, tinaSchema } = await setup({
|
|
2481
2535
|
firstTime: true
|
|
2482
2536
|
});
|
|
2483
|
-
await
|
|
2484
|
-
await
|
|
2537
|
+
await fs7.outputFile(configManager.outputHTMLFilePath, devHTML(this.port));
|
|
2538
|
+
await fs7.outputFile(
|
|
2485
2539
|
configManager.outputGitignorePath,
|
|
2486
2540
|
"index.html\nassets/"
|
|
2487
2541
|
);
|
|
2488
|
-
const searchIndexClient = new
|
|
2542
|
+
const searchIndexClient = new LocalSearchIndexClient({
|
|
2489
2543
|
stopwordLanguages: configManager.config.search?.tina?.stopwordLanguages,
|
|
2490
2544
|
tokenSplitRegex: configManager.config.search?.tina?.tokenSplitRegex
|
|
2491
2545
|
});
|
|
2492
2546
|
await searchIndexClient.onStartIndexing();
|
|
2493
|
-
const searchIndexer = new
|
|
2547
|
+
const searchIndexer = new SearchIndexer({
|
|
2494
2548
|
batchSize: configManager.config.search?.indexBatchSize || 100,
|
|
2495
|
-
bridge: new
|
|
2549
|
+
bridge: new FilesystemBridge2(
|
|
2496
2550
|
configManager.rootPath,
|
|
2497
2551
|
configManager.contentRootPath
|
|
2498
2552
|
),
|
|
@@ -2533,7 +2587,7 @@ ${dangerText(e.message)}
|
|
|
2533
2587
|
);
|
|
2534
2588
|
await server.listen(Number(this.port));
|
|
2535
2589
|
if (!this.noWatch) {
|
|
2536
|
-
|
|
2590
|
+
chokidar.watch(configManager.watchList).on("change", async () => {
|
|
2537
2591
|
await dbLock(async () => {
|
|
2538
2592
|
logger.info(`Tina config change detected, rebuilding`);
|
|
2539
2593
|
await setup({ firstTime: false });
|
|
@@ -2610,14 +2664,14 @@ ${dangerText(e.message)}
|
|
|
2610
2664
|
watchContentFiles(configManager, database, databaseLock, searchIndexer) {
|
|
2611
2665
|
const collectionContentFiles = [];
|
|
2612
2666
|
configManager.config.schema.collections.forEach((collection) => {
|
|
2613
|
-
const collectionGlob = `${
|
|
2667
|
+
const collectionGlob = `${path8.join(
|
|
2614
2668
|
configManager.contentRootPath,
|
|
2615
2669
|
collection.path
|
|
2616
2670
|
)}/**/*.${collection.format || "md"}`;
|
|
2617
2671
|
collectionContentFiles.push(collectionGlob);
|
|
2618
2672
|
});
|
|
2619
2673
|
let ready = false;
|
|
2620
|
-
|
|
2674
|
+
chokidar.watch(collectionContentFiles).on("ready", () => {
|
|
2621
2675
|
ready = true;
|
|
2622
2676
|
}).on("add", async (addedFile) => {
|
|
2623
2677
|
if (!ready) {
|
|
@@ -2654,27 +2708,34 @@ ${dangerText(e.message)}
|
|
|
2654
2708
|
await callback();
|
|
2655
2709
|
});
|
|
2656
2710
|
};
|
|
2657
|
-
|
|
2711
|
+
chokidar.watch(configManager.userQueriesAndFragmentsGlob).on("add", executeCallback).on("change", executeCallback).on("unlink", executeCallback);
|
|
2658
2712
|
}
|
|
2659
2713
|
};
|
|
2660
2714
|
|
|
2661
2715
|
// src/next/commands/build-command/index.ts
|
|
2662
|
-
|
|
2663
|
-
|
|
2664
|
-
|
|
2665
|
-
|
|
2666
|
-
|
|
2667
|
-
|
|
2668
|
-
|
|
2669
|
-
|
|
2670
|
-
|
|
2671
|
-
|
|
2716
|
+
import crypto from "crypto";
|
|
2717
|
+
import path9 from "path";
|
|
2718
|
+
import { diff } from "@graphql-inspector/core";
|
|
2719
|
+
import { FilesystemBridge as FilesystemBridge3, buildSchema as buildSchema2 } from "@tinacms/graphql";
|
|
2720
|
+
import { parseURL as parseURL2 } from "@tinacms/schema-tools";
|
|
2721
|
+
import {
|
|
2722
|
+
SearchIndexer as SearchIndexer2,
|
|
2723
|
+
TinaCMSSearchIndexClient
|
|
2724
|
+
} from "@tinacms/search";
|
|
2725
|
+
import { Command as Command3, Option as Option3 } from "clipanion";
|
|
2726
|
+
import fs8 from "fs-extra";
|
|
2727
|
+
import {
|
|
2728
|
+
buildASTSchema as buildASTSchema2,
|
|
2729
|
+
buildClientSchema,
|
|
2730
|
+
getIntrospectionQuery
|
|
2731
|
+
} from "graphql";
|
|
2732
|
+
import Progress2 from "progress";
|
|
2672
2733
|
|
|
2673
2734
|
// src/utils/index.ts
|
|
2674
|
-
|
|
2735
|
+
import { ChangeType } from "@graphql-inspector/core";
|
|
2675
2736
|
var getFaqLink = (type) => {
|
|
2676
2737
|
switch (type) {
|
|
2677
|
-
case
|
|
2738
|
+
case ChangeType.FieldRemoved: {
|
|
2678
2739
|
return "https://tina.io/docs/r/FAQ/#2-how-do-i-resolve-the-local-graphql-schema-doesnt-match-the-remote-graphql-schema-error";
|
|
2679
2740
|
}
|
|
2680
2741
|
default:
|
|
@@ -2696,7 +2757,7 @@ async function sleepAndCallFunc({
|
|
|
2696
2757
|
}
|
|
2697
2758
|
|
|
2698
2759
|
// src/next/commands/build-command/server.ts
|
|
2699
|
-
|
|
2760
|
+
import { build as build2 } from "vite";
|
|
2700
2761
|
var buildProductionSpa = async (configManager, database, apiURL) => {
|
|
2701
2762
|
const publicEnv = {};
|
|
2702
2763
|
Object.keys(process.env).forEach((key) => {
|
|
@@ -2730,12 +2791,12 @@ var buildProductionSpa = async (configManager, database, apiURL) => {
|
|
|
2730
2791
|
}
|
|
2731
2792
|
}
|
|
2732
2793
|
});
|
|
2733
|
-
return (
|
|
2794
|
+
return build2(config2);
|
|
2734
2795
|
};
|
|
2735
2796
|
|
|
2736
2797
|
// src/next/commands/build-command/waitForDB.ts
|
|
2737
|
-
|
|
2738
|
-
|
|
2798
|
+
import { parseURL } from "@tinacms/schema-tools";
|
|
2799
|
+
import Progress from "progress";
|
|
2739
2800
|
var POLLING_INTERVAL = 5e3;
|
|
2740
2801
|
var STATUS_INPROGRESS = "inprogress";
|
|
2741
2802
|
var STATUS_COMPLETE = "complete";
|
|
@@ -2748,14 +2809,14 @@ var IndexFailedError = class extends Error {
|
|
|
2748
2809
|
};
|
|
2749
2810
|
var waitForDB = async (config2, apiUrl, previewName, verbose) => {
|
|
2750
2811
|
const token = config2.token;
|
|
2751
|
-
const { clientId, branch, isLocalClient, host } =
|
|
2812
|
+
const { clientId, branch, isLocalClient, host } = parseURL(apiUrl);
|
|
2752
2813
|
if (isLocalClient || !host || !clientId || !branch) {
|
|
2753
2814
|
if (verbose) {
|
|
2754
2815
|
logger.info(logText("Not using TinaCloud, skipping DB check"));
|
|
2755
2816
|
}
|
|
2756
2817
|
return;
|
|
2757
2818
|
}
|
|
2758
|
-
const bar2 = new
|
|
2819
|
+
const bar2 = new Progress(
|
|
2759
2820
|
"Checking indexing process in TinaCloud... :prog",
|
|
2760
2821
|
1
|
|
2761
2822
|
);
|
|
@@ -2818,51 +2879,44 @@ var waitForDB = async (config2, apiUrl, previewName, verbose) => {
|
|
|
2818
2879
|
|
|
2819
2880
|
// src/next/commands/build-command/index.ts
|
|
2820
2881
|
var BuildCommand = class extends BaseCommand {
|
|
2821
|
-
|
|
2822
|
-
|
|
2823
|
-
|
|
2824
|
-
|
|
2825
|
-
|
|
2826
|
-
|
|
2827
|
-
|
|
2828
|
-
|
|
2829
|
-
|
|
2830
|
-
|
|
2831
|
-
|
|
2832
|
-
|
|
2833
|
-
|
|
2834
|
-
|
|
2835
|
-
|
|
2836
|
-
|
|
2837
|
-
|
|
2838
|
-
|
|
2839
|
-
|
|
2840
|
-
|
|
2841
|
-
|
|
2842
|
-
|
|
2843
|
-
|
|
2844
|
-
|
|
2845
|
-
|
|
2846
|
-
|
|
2847
|
-
|
|
2848
|
-
|
|
2849
|
-
|
|
2850
|
-
|
|
2851
|
-
|
|
2852
|
-
|
|
2853
|
-
|
|
2854
|
-
|
|
2855
|
-
|
|
2856
|
-
|
|
2857
|
-
|
|
2858
|
-
|
|
2859
|
-
}
|
|
2860
|
-
static {
|
|
2861
|
-
this.usage = import_clipanion3.Command.Usage({
|
|
2862
|
-
category: `Commands`,
|
|
2863
|
-
description: `Build the CMS and autogenerated modules for usage with TinaCloud`
|
|
2864
|
-
});
|
|
2865
|
-
}
|
|
2882
|
+
static paths = [["build"]];
|
|
2883
|
+
localOption = Option3.Boolean("--local", {
|
|
2884
|
+
description: "Starts local Graphql server and builds the local client instead of production client"
|
|
2885
|
+
});
|
|
2886
|
+
skipIndexing = Option3.Boolean("--skip-indexing", false, {
|
|
2887
|
+
description: "Skips indexing the content. This can be used for building the site without indexing the content (defaults to false)"
|
|
2888
|
+
});
|
|
2889
|
+
partialReindex = Option3.Boolean("--partial-reindex", false, {
|
|
2890
|
+
description: "Re-indexes only the content that has changed since the last build (defaults to false). Not currently supported for separate content repos."
|
|
2891
|
+
});
|
|
2892
|
+
tinaGraphQLVersion = Option3.String("--tina-graphql-version", {
|
|
2893
|
+
description: "Specify the version of @tinacms/graphql to use (defaults to latest)"
|
|
2894
|
+
});
|
|
2895
|
+
/**
|
|
2896
|
+
* This option allows the user to skip the TinaCloud checks if they want to. This could be useful for mismatched GraphQL versions or if they want to build only using the local client and never connect to TinaCloud
|
|
2897
|
+
*/
|
|
2898
|
+
skipCloudChecks = Option3.Boolean("--skip-cloud-checks", false, {
|
|
2899
|
+
description: "Skips checking the provided cloud config."
|
|
2900
|
+
});
|
|
2901
|
+
skipSearchIndex = Option3.Boolean("--skip-search-index", false, {
|
|
2902
|
+
description: "Skip indexing the site for search"
|
|
2903
|
+
});
|
|
2904
|
+
upstreamBranch = Option3.String("--upstream-branch", {
|
|
2905
|
+
description: "Optional upstream branch with the schema. If not specified, default will be used."
|
|
2906
|
+
});
|
|
2907
|
+
previewBaseBranch = Option3.String("--preview-base-branch", {
|
|
2908
|
+
description: "The base branch for the preview"
|
|
2909
|
+
});
|
|
2910
|
+
previewName = Option3.String("--preview-name", {
|
|
2911
|
+
description: "The name of the preview branch"
|
|
2912
|
+
});
|
|
2913
|
+
noClientBuildCache = Option3.Boolean("--no-client-build-cache", false, {
|
|
2914
|
+
description: "Disables the client build cache"
|
|
2915
|
+
});
|
|
2916
|
+
static usage = Command3.Usage({
|
|
2917
|
+
category: `Commands`,
|
|
2918
|
+
description: `Build the CMS and autogenerated modules for usage with TinaCloud`
|
|
2919
|
+
});
|
|
2866
2920
|
async catch(error) {
|
|
2867
2921
|
console.error(error);
|
|
2868
2922
|
process.exit(1);
|
|
@@ -2907,7 +2961,7 @@ ${dangerText(e.message)}`);
|
|
|
2907
2961
|
configManager,
|
|
2908
2962
|
Number(this.datalayerPort)
|
|
2909
2963
|
);
|
|
2910
|
-
const { queryDoc, fragDoc, graphQLSchema, tinaSchema, lookup } = await (
|
|
2964
|
+
const { queryDoc, fragDoc, graphQLSchema, tinaSchema, lookup } = await buildSchema2(configManager.config);
|
|
2911
2965
|
const codegen2 = new Codegen({
|
|
2912
2966
|
configManager,
|
|
2913
2967
|
port: this.localOption ? Number(this.port) : void 0,
|
|
@@ -3015,7 +3069,7 @@ ${dangerText(e.message)}
|
|
|
3015
3069
|
}
|
|
3016
3070
|
}
|
|
3017
3071
|
await buildProductionSpa(configManager, database, codegen2.productionUrl);
|
|
3018
|
-
await
|
|
3072
|
+
await fs8.outputFile(
|
|
3019
3073
|
configManager.outputGitignorePath,
|
|
3020
3074
|
"index.html\nassets/"
|
|
3021
3075
|
);
|
|
@@ -3047,7 +3101,7 @@ ${dangerText(e.message)}
|
|
|
3047
3101
|
"indexerToken not configured in tina search configuration."
|
|
3048
3102
|
);
|
|
3049
3103
|
}
|
|
3050
|
-
client = new
|
|
3104
|
+
client = new TinaCMSSearchIndexClient({
|
|
3051
3105
|
apiUrl: `${configManager.config.tinaioConfig?.contentApiUrlOverride || "https://content.tinajs.io"}/searchIndex/${configManager.config?.clientId}`,
|
|
3052
3106
|
branch: configManager.config?.branch,
|
|
3053
3107
|
indexerToken: configManager.config?.search?.tina?.indexerToken,
|
|
@@ -3056,9 +3110,9 @@ ${dangerText(e.message)}
|
|
|
3056
3110
|
} else {
|
|
3057
3111
|
client = configManager.config?.search?.searchClient;
|
|
3058
3112
|
}
|
|
3059
|
-
const searchIndexer = new
|
|
3113
|
+
const searchIndexer = new SearchIndexer2({
|
|
3060
3114
|
batchSize: configManager.config.search?.indexBatchSize || 100,
|
|
3061
|
-
bridge: new
|
|
3115
|
+
bridge: new FilesystemBridge3(
|
|
3062
3116
|
configManager.rootPath,
|
|
3063
3117
|
configManager.contentRootPath
|
|
3064
3118
|
),
|
|
@@ -3128,8 +3182,8 @@ ${dangerText(e.message)}
|
|
|
3128
3182
|
const MAX_RETRIES = 5;
|
|
3129
3183
|
const { config: config2 } = configManager;
|
|
3130
3184
|
const token = config2.token;
|
|
3131
|
-
const { clientId, branch, host } = (
|
|
3132
|
-
const bar2 = new
|
|
3185
|
+
const { clientId, branch, host } = parseURL2(apiURL);
|
|
3186
|
+
const bar2 = new Progress2("Checking clientId and token. :prog", 1);
|
|
3133
3187
|
const getBranchInfo = async () => {
|
|
3134
3188
|
const url = `https://${host}/db/${clientId}/status/${previewBaseBranch || branch}`;
|
|
3135
3189
|
const branchInfo2 = {
|
|
@@ -3183,7 +3237,7 @@ ${dangerText(e.message)}
|
|
|
3183
3237
|
bar2.tick({
|
|
3184
3238
|
prog: "\u2705"
|
|
3185
3239
|
});
|
|
3186
|
-
const branchBar = new
|
|
3240
|
+
const branchBar = new Progress2(
|
|
3187
3241
|
`Checking branch '${config2.branch}' is on TinaCloud. :prog`,
|
|
3188
3242
|
1
|
|
3189
3243
|
);
|
|
@@ -3223,7 +3277,7 @@ ${dangerText(e.message)}
|
|
|
3223
3277
|
async syncProject(configManager, apiURL, options) {
|
|
3224
3278
|
const { config: config2 } = configManager;
|
|
3225
3279
|
const token = config2.token;
|
|
3226
|
-
const { clientId, branch, host } = (
|
|
3280
|
+
const { clientId, branch, host } = parseURL2(apiURL);
|
|
3227
3281
|
const { previewName, previewBaseBranch, upstreamBranch } = options || {};
|
|
3228
3282
|
let url = `https://${host}/db/${clientId}/reset/${branch}?refreshSchema=true&skipIfSchemaCurrent=true`;
|
|
3229
3283
|
if (upstreamBranch && previewBaseBranch && previewName) {
|
|
@@ -3233,7 +3287,7 @@ ${dangerText(e.message)}
|
|
|
3233
3287
|
} else if (upstreamBranch && !previewBaseBranch && !previewName) {
|
|
3234
3288
|
url = `https://${host}/db/${clientId}/reset/${branch}?refreshSchema=true&skipIfSchemaCurrent=true&upstreamBranch=${upstreamBranch}`;
|
|
3235
3289
|
}
|
|
3236
|
-
const bar2 = new
|
|
3290
|
+
const bar2 = new Progress2("Syncing Project. :prog", 1);
|
|
3237
3291
|
try {
|
|
3238
3292
|
const res = await request({
|
|
3239
3293
|
token,
|
|
@@ -3274,7 +3328,7 @@ ${dangerText(e.message)}
|
|
|
3274
3328
|
}
|
|
3275
3329
|
}
|
|
3276
3330
|
async checkGraphqlSchema(configManager, database, apiURL, timestamp) {
|
|
3277
|
-
const bar2 = new
|
|
3331
|
+
const bar2 = new Progress2(
|
|
3278
3332
|
"Checking local GraphQL Schema matches server. :prog",
|
|
3279
3333
|
1
|
|
3280
3334
|
);
|
|
@@ -3296,11 +3350,11 @@ Additional info: Branch: ${config2.branch}, Client ID: ${config2.clientId} `;
|
|
|
3296
3350
|
}
|
|
3297
3351
|
throw new Error(errorMessage);
|
|
3298
3352
|
}
|
|
3299
|
-
const remoteGqlSchema =
|
|
3353
|
+
const remoteGqlSchema = buildClientSchema(remoteSchema);
|
|
3300
3354
|
const localSchemaDocument = await database.getGraphQLSchemaFromBridge();
|
|
3301
|
-
const localGraphqlSchema = (
|
|
3355
|
+
const localGraphqlSchema = buildASTSchema2(localSchemaDocument);
|
|
3302
3356
|
try {
|
|
3303
|
-
const diffResult = await
|
|
3357
|
+
const diffResult = await diff(remoteGqlSchema, localGraphqlSchema);
|
|
3304
3358
|
if (diffResult.length === 0) {
|
|
3305
3359
|
bar2.tick({
|
|
3306
3360
|
prog: "\u2705"
|
|
@@ -3348,13 +3402,13 @@ Additional info:
|
|
|
3348
3402
|
}
|
|
3349
3403
|
}
|
|
3350
3404
|
async checkTinaSchema(configManager, database, apiURL, previewName, verbose, timestamp) {
|
|
3351
|
-
const bar2 = new
|
|
3405
|
+
const bar2 = new Progress2(
|
|
3352
3406
|
"Checking local Tina Schema matches server. :prog",
|
|
3353
3407
|
1
|
|
3354
3408
|
);
|
|
3355
3409
|
const { config: config2 } = configManager;
|
|
3356
3410
|
const token = config2.token;
|
|
3357
|
-
const { clientId, branch, isLocalClient, host } = (
|
|
3411
|
+
const { clientId, branch, isLocalClient, host } = parseURL2(apiURL);
|
|
3358
3412
|
if (isLocalClient || !host || !clientId || !branch) {
|
|
3359
3413
|
if (verbose) {
|
|
3360
3414
|
logger.info(logText("Not using TinaCloud, skipping Tina Schema check"));
|
|
@@ -3382,11 +3436,11 @@ Additional info: Branch: ${config2.branch}, Client ID: ${config2.clientId} `;
|
|
|
3382
3436
|
}
|
|
3383
3437
|
const localTinaSchema = JSON.parse(
|
|
3384
3438
|
await database.bridge.get(
|
|
3385
|
-
|
|
3439
|
+
path9.join(database.tinaDirectory, "__generated__", "_schema.json")
|
|
3386
3440
|
)
|
|
3387
3441
|
);
|
|
3388
3442
|
localTinaSchema.version = void 0;
|
|
3389
|
-
const localTinaSchemaSha =
|
|
3443
|
+
const localTinaSchemaSha = crypto.createHash("sha256").update(JSON.stringify(localTinaSchema)).digest("hex");
|
|
3390
3444
|
if (localTinaSchemaSha === remoteTinaSchemaSha) {
|
|
3391
3445
|
bar2.tick({
|
|
3392
3446
|
prog: "\u2705"
|
|
@@ -3464,7 +3518,7 @@ var fetchRemoteGraphqlSchema = async ({
|
|
|
3464
3518
|
headers.append("X-API-KEY", token);
|
|
3465
3519
|
}
|
|
3466
3520
|
const body = JSON.stringify({
|
|
3467
|
-
query:
|
|
3521
|
+
query: getIntrospectionQuery(),
|
|
3468
3522
|
variables: {}
|
|
3469
3523
|
});
|
|
3470
3524
|
headers.append("Content-Type", "application/json");
|
|
@@ -3497,14 +3551,14 @@ var fetchSchemaSha = async ({
|
|
|
3497
3551
|
};
|
|
3498
3552
|
|
|
3499
3553
|
// src/next/commands/audit-command/index.ts
|
|
3500
|
-
|
|
3501
|
-
|
|
3554
|
+
import { Command as Command4, Option as Option4 } from "clipanion";
|
|
3555
|
+
import { buildSchema as buildSchema3 } from "@tinacms/graphql";
|
|
3502
3556
|
|
|
3503
3557
|
// src/next/commands/audit-command/audit.ts
|
|
3504
|
-
|
|
3505
|
-
|
|
3506
|
-
|
|
3507
|
-
|
|
3558
|
+
import prompts from "prompts";
|
|
3559
|
+
import { Telemetry } from "@tinacms/metrics";
|
|
3560
|
+
import { resolve } from "@tinacms/graphql";
|
|
3561
|
+
import chalk5 from "chalk";
|
|
3508
3562
|
var audit = async ({
|
|
3509
3563
|
database,
|
|
3510
3564
|
clean,
|
|
@@ -3512,7 +3566,7 @@ var audit = async ({
|
|
|
3512
3566
|
noTelemetry,
|
|
3513
3567
|
verbose
|
|
3514
3568
|
}) => {
|
|
3515
|
-
const telemetry = new
|
|
3569
|
+
const telemetry = new Telemetry({ disabled: noTelemetry });
|
|
3516
3570
|
await telemetry.submitRecord({
|
|
3517
3571
|
event: {
|
|
3518
3572
|
name: "tinacms:cli:audit:invoke",
|
|
@@ -3522,25 +3576,25 @@ var audit = async ({
|
|
|
3522
3576
|
});
|
|
3523
3577
|
if (clean) {
|
|
3524
3578
|
logger.info(
|
|
3525
|
-
`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 ${
|
|
3579
|
+
`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 ${chalk5.bold(
|
|
3526
3580
|
"clean git tree"
|
|
3527
3581
|
)} so unwanted changes can be undone.
|
|
3528
3582
|
|
|
3529
3583
|
`
|
|
3530
3584
|
);
|
|
3531
|
-
const res = await (
|
|
3585
|
+
const res = await prompts({
|
|
3532
3586
|
name: "useClean",
|
|
3533
3587
|
type: "confirm",
|
|
3534
3588
|
message: `Do you want to continue?`
|
|
3535
3589
|
});
|
|
3536
3590
|
if (!res.useClean) {
|
|
3537
|
-
logger.warn(
|
|
3591
|
+
logger.warn(chalk5.yellowBright("\u26A0\uFE0F Audit not complete"));
|
|
3538
3592
|
process.exit(0);
|
|
3539
3593
|
}
|
|
3540
3594
|
}
|
|
3541
3595
|
if (useDefaultValues && !clean) {
|
|
3542
3596
|
logger.warn(
|
|
3543
|
-
|
|
3597
|
+
chalk5.yellowBright(
|
|
3544
3598
|
"WARNING: using the `--useDefaultValues` without the `--clean` flag has no effect. Please re-run audit and add the `--clean` flag"
|
|
3545
3599
|
)
|
|
3546
3600
|
);
|
|
@@ -3568,10 +3622,10 @@ var audit = async ({
|
|
|
3568
3622
|
}
|
|
3569
3623
|
if (error) {
|
|
3570
3624
|
logger.error(
|
|
3571
|
-
|
|
3625
|
+
chalk5.redBright(`\u203C\uFE0F Audit ${chalk5.bold("failed")} with errors`)
|
|
3572
3626
|
);
|
|
3573
3627
|
} else {
|
|
3574
|
-
logger.info(
|
|
3628
|
+
logger.info(chalk5.greenBright("\u2705 Audit passed"));
|
|
3575
3629
|
}
|
|
3576
3630
|
};
|
|
3577
3631
|
var auditDocuments = async (args) => {
|
|
@@ -3588,7 +3642,7 @@ var auditDocuments = async (args) => {
|
|
|
3588
3642
|
}
|
|
3589
3643
|
}
|
|
3590
3644
|
}`;
|
|
3591
|
-
const docResult = await
|
|
3645
|
+
const docResult = await resolve({
|
|
3592
3646
|
database,
|
|
3593
3647
|
query: documentQuery,
|
|
3594
3648
|
variables: {},
|
|
@@ -3599,11 +3653,11 @@ var auditDocuments = async (args) => {
|
|
|
3599
3653
|
if (docResult.errors) {
|
|
3600
3654
|
error = true;
|
|
3601
3655
|
docResult.errors.forEach((err) => {
|
|
3602
|
-
logger.error(
|
|
3656
|
+
logger.error(chalk5.red(err.message));
|
|
3603
3657
|
if (err.originalError.originalError) {
|
|
3604
3658
|
logger.error(
|
|
3605
3659
|
// @ts-ignore FIXME: this doesn't seem right
|
|
3606
|
-
|
|
3660
|
+
chalk5.red(` ${err.originalError.originalError.message}`)
|
|
3607
3661
|
);
|
|
3608
3662
|
}
|
|
3609
3663
|
});
|
|
@@ -3630,7 +3684,7 @@ var auditDocuments = async (args) => {
|
|
|
3630
3684
|
params: $params
|
|
3631
3685
|
){__typename}
|
|
3632
3686
|
}`;
|
|
3633
|
-
const mutationRes = await
|
|
3687
|
+
const mutationRes = await resolve({
|
|
3634
3688
|
database,
|
|
3635
3689
|
query: mutation,
|
|
3636
3690
|
variables: {
|
|
@@ -3645,7 +3699,7 @@ var auditDocuments = async (args) => {
|
|
|
3645
3699
|
if (mutationRes.errors) {
|
|
3646
3700
|
mutationRes.errors.forEach((err) => {
|
|
3647
3701
|
error = true;
|
|
3648
|
-
logger.error(
|
|
3702
|
+
logger.error(chalk5.red(err.message));
|
|
3649
3703
|
});
|
|
3650
3704
|
}
|
|
3651
3705
|
}
|
|
@@ -3662,38 +3716,31 @@ function filterObject(obj) {
|
|
|
3662
3716
|
}
|
|
3663
3717
|
|
|
3664
3718
|
// src/next/commands/audit-command/index.ts
|
|
3665
|
-
|
|
3666
|
-
var AuditCommand = class extends
|
|
3667
|
-
|
|
3668
|
-
|
|
3669
|
-
|
|
3670
|
-
|
|
3671
|
-
|
|
3672
|
-
|
|
3673
|
-
|
|
3674
|
-
|
|
3675
|
-
|
|
3676
|
-
|
|
3677
|
-
|
|
3678
|
-
|
|
3679
|
-
|
|
3680
|
-
|
|
3681
|
-
|
|
3682
|
-
|
|
3683
|
-
|
|
3684
|
-
|
|
3685
|
-
|
|
3686
|
-
|
|
3687
|
-
|
|
3688
|
-
|
|
3689
|
-
|
|
3690
|
-
}
|
|
3691
|
-
static {
|
|
3692
|
-
this.usage = import_clipanion4.Command.Usage({
|
|
3693
|
-
category: `Commands`,
|
|
3694
|
-
description: `Audit config and content files`
|
|
3695
|
-
});
|
|
3696
|
-
}
|
|
3719
|
+
import { AuditFileSystemBridge } from "@tinacms/graphql";
|
|
3720
|
+
var AuditCommand = class extends Command4 {
|
|
3721
|
+
static paths = [["audit"]];
|
|
3722
|
+
rootPath = Option4.String("--rootPath", {
|
|
3723
|
+
description: "Specify the root directory to run the CLI from"
|
|
3724
|
+
});
|
|
3725
|
+
verbose = Option4.Boolean("-v,--verbose", false, {
|
|
3726
|
+
description: "increase verbosity of logged output"
|
|
3727
|
+
});
|
|
3728
|
+
clean = Option4.Boolean("--clean", false, {
|
|
3729
|
+
description: "Clean the output"
|
|
3730
|
+
});
|
|
3731
|
+
useDefaultValues = Option4.Boolean("--useDefaultValues", false, {
|
|
3732
|
+
description: "When cleaning the output, use defaults on the config"
|
|
3733
|
+
});
|
|
3734
|
+
noTelemetry = Option4.Boolean("--noTelemetry", false, {
|
|
3735
|
+
description: "Disable anonymous telemetry that is collected"
|
|
3736
|
+
});
|
|
3737
|
+
datalayerPort = Option4.String("--datalayer-port", "9000", {
|
|
3738
|
+
description: "Specify a port to run the datalayer server on. (default 9000)"
|
|
3739
|
+
});
|
|
3740
|
+
static usage = Command4.Usage({
|
|
3741
|
+
category: `Commands`,
|
|
3742
|
+
description: `Audit config and content files`
|
|
3743
|
+
});
|
|
3697
3744
|
async catch(error) {
|
|
3698
3745
|
logger.error("Error occured during tinacms audit");
|
|
3699
3746
|
if (this.verbose) {
|
|
@@ -3714,9 +3761,9 @@ var AuditCommand = class extends import_clipanion4.Command {
|
|
|
3714
3761
|
const database = await createAndInitializeDatabase(
|
|
3715
3762
|
configManager,
|
|
3716
3763
|
Number(this.datalayerPort),
|
|
3717
|
-
this.clean ? void 0 : new
|
|
3764
|
+
this.clean ? void 0 : new AuditFileSystemBridge(configManager.rootPath)
|
|
3718
3765
|
);
|
|
3719
|
-
const { tinaSchema, graphQLSchema, lookup } = await (
|
|
3766
|
+
const { tinaSchema, graphQLSchema, lookup } = await buildSchema3(
|
|
3720
3767
|
configManager.config
|
|
3721
3768
|
);
|
|
3722
3769
|
const warnings = [];
|
|
@@ -3749,29 +3796,29 @@ var AuditCommand = class extends import_clipanion4.Command {
|
|
|
3749
3796
|
};
|
|
3750
3797
|
|
|
3751
3798
|
// src/next/commands/init-command/index.ts
|
|
3752
|
-
|
|
3799
|
+
import { Command as Command6, Option as Option6 } from "clipanion";
|
|
3753
3800
|
|
|
3754
3801
|
// src/cmds/init/detectEnvironment.ts
|
|
3755
|
-
|
|
3756
|
-
|
|
3802
|
+
import fs9 from "fs-extra";
|
|
3803
|
+
import path10 from "path";
|
|
3757
3804
|
var checkGitignoreForItem = async ({
|
|
3758
3805
|
baseDir,
|
|
3759
3806
|
line
|
|
3760
3807
|
}) => {
|
|
3761
|
-
const gitignoreContent =
|
|
3808
|
+
const gitignoreContent = fs9.readFileSync(path10.join(baseDir, ".gitignore")).toString();
|
|
3762
3809
|
return gitignoreContent.split("\n").some((item) => item === line);
|
|
3763
3810
|
};
|
|
3764
3811
|
var makeGeneratedFile = async (name2, generatedFileType, parentPath, opts) => {
|
|
3765
3812
|
const result = {
|
|
3766
|
-
fullPathTS:
|
|
3813
|
+
fullPathTS: path10.join(
|
|
3767
3814
|
parentPath,
|
|
3768
3815
|
`${name2}.${opts?.typescriptSuffix || opts?.extensionOverride || "ts"}`
|
|
3769
3816
|
),
|
|
3770
|
-
fullPathJS:
|
|
3817
|
+
fullPathJS: path10.join(
|
|
3771
3818
|
parentPath,
|
|
3772
3819
|
`${name2}.${opts?.extensionOverride || "js"}`
|
|
3773
3820
|
),
|
|
3774
|
-
fullPathOverride: opts?.extensionOverride ?
|
|
3821
|
+
fullPathOverride: opts?.extensionOverride ? path10.join(parentPath, `${name2}.${opts?.extensionOverride}`) : "",
|
|
3775
3822
|
generatedFileType,
|
|
3776
3823
|
name: name2,
|
|
3777
3824
|
parentPath,
|
|
@@ -3789,8 +3836,8 @@ var makeGeneratedFile = async (name2, generatedFileType, parentPath, opts) => {
|
|
|
3789
3836
|
};
|
|
3790
3837
|
}
|
|
3791
3838
|
};
|
|
3792
|
-
result.typescriptExists = await
|
|
3793
|
-
result.javascriptExists = await
|
|
3839
|
+
result.typescriptExists = await fs9.pathExists(result.fullPathTS);
|
|
3840
|
+
result.javascriptExists = await fs9.pathExists(result.fullPathJS);
|
|
3794
3841
|
return result;
|
|
3795
3842
|
};
|
|
3796
3843
|
var detectEnvironment = async ({
|
|
@@ -3799,21 +3846,21 @@ var detectEnvironment = async ({
|
|
|
3799
3846
|
rootPath,
|
|
3800
3847
|
debug = false
|
|
3801
3848
|
}) => {
|
|
3802
|
-
const hasForestryConfig = await
|
|
3803
|
-
|
|
3849
|
+
const hasForestryConfig = await fs9.pathExists(
|
|
3850
|
+
path10.join(pathToForestryConfig, ".forestry", "settings.yml")
|
|
3804
3851
|
);
|
|
3805
|
-
const sampleContentPath =
|
|
3852
|
+
const sampleContentPath = path10.join(
|
|
3806
3853
|
baseDir,
|
|
3807
3854
|
"content",
|
|
3808
3855
|
"posts",
|
|
3809
3856
|
"hello-world.md"
|
|
3810
3857
|
);
|
|
3811
|
-
const usingSrc =
|
|
3812
|
-
const tinaFolder =
|
|
3858
|
+
const usingSrc = fs9.pathExistsSync(path10.join(baseDir, "src")) && (fs9.pathExistsSync(path10.join(baseDir, "src", "app")) || fs9.pathExistsSync(path10.join(baseDir, "src", "pages")));
|
|
3859
|
+
const tinaFolder = path10.join(baseDir, "tina");
|
|
3813
3860
|
const tinaConfigExists = Boolean(
|
|
3814
3861
|
// Does the tina folder exist?
|
|
3815
|
-
await
|
|
3816
|
-
(await
|
|
3862
|
+
await fs9.pathExists(tinaFolder) && // Does the tina folder contain a config file?
|
|
3863
|
+
(await fs9.readdir(tinaFolder)).find((x) => x.includes("config"))
|
|
3817
3864
|
);
|
|
3818
3865
|
const pagesDir = [baseDir, usingSrc ? "src" : false, "pages"].filter(
|
|
3819
3866
|
Boolean
|
|
@@ -3825,12 +3872,12 @@ var detectEnvironment = async ({
|
|
|
3825
3872
|
"next-api-handler": await makeGeneratedFile(
|
|
3826
3873
|
"[...routes]",
|
|
3827
3874
|
"next-api-handler",
|
|
3828
|
-
|
|
3875
|
+
path10.join(...pagesDir, "api", "tina")
|
|
3829
3876
|
),
|
|
3830
3877
|
"reactive-example": await makeGeneratedFile(
|
|
3831
3878
|
"[filename]",
|
|
3832
3879
|
"reactive-example",
|
|
3833
|
-
|
|
3880
|
+
path10.join(...pagesDir, "demo", "blog"),
|
|
3834
3881
|
{
|
|
3835
3882
|
typescriptSuffix: "tsx"
|
|
3836
3883
|
}
|
|
@@ -3838,22 +3885,22 @@ var detectEnvironment = async ({
|
|
|
3838
3885
|
"users-json": await makeGeneratedFile(
|
|
3839
3886
|
"index",
|
|
3840
3887
|
"users-json",
|
|
3841
|
-
|
|
3888
|
+
path10.join(baseDir, "content", "users"),
|
|
3842
3889
|
{ extensionOverride: "json" }
|
|
3843
3890
|
),
|
|
3844
3891
|
"sample-content": await makeGeneratedFile(
|
|
3845
3892
|
"hello-world",
|
|
3846
3893
|
"sample-content",
|
|
3847
|
-
|
|
3894
|
+
path10.join(baseDir, "content", "posts"),
|
|
3848
3895
|
{ extensionOverride: "md" }
|
|
3849
3896
|
)
|
|
3850
3897
|
};
|
|
3851
|
-
const hasSampleContent = await
|
|
3852
|
-
const hasPackageJSON = await
|
|
3898
|
+
const hasSampleContent = await fs9.pathExists(sampleContentPath);
|
|
3899
|
+
const hasPackageJSON = await fs9.pathExists("package.json");
|
|
3853
3900
|
let hasTinaDeps = false;
|
|
3854
3901
|
if (hasPackageJSON) {
|
|
3855
3902
|
try {
|
|
3856
|
-
const packageJSON = await
|
|
3903
|
+
const packageJSON = await fs9.readJSON("package.json");
|
|
3857
3904
|
const deps = [];
|
|
3858
3905
|
if (packageJSON?.dependencies) {
|
|
3859
3906
|
deps.push(...Object.keys(packageJSON.dependencies));
|
|
@@ -3870,15 +3917,15 @@ var detectEnvironment = async ({
|
|
|
3870
3917
|
);
|
|
3871
3918
|
}
|
|
3872
3919
|
}
|
|
3873
|
-
const hasGitIgnore = await
|
|
3920
|
+
const hasGitIgnore = await fs9.pathExists(path10.join(".gitignore"));
|
|
3874
3921
|
const hasGitIgnoreNodeModules = hasGitIgnore && await checkGitignoreForItem({ baseDir, line: "node_modules" });
|
|
3875
3922
|
const hasEnvTina = hasGitIgnore && await checkGitignoreForItem({ baseDir, line: ".env.tina" });
|
|
3876
3923
|
const hasGitIgnoreEnv = hasGitIgnore && await checkGitignoreForItem({ baseDir, line: ".env" });
|
|
3877
3924
|
let frontMatterFormat;
|
|
3878
3925
|
if (hasForestryConfig) {
|
|
3879
|
-
const hugoConfigPath =
|
|
3880
|
-
if (await
|
|
3881
|
-
const hugoConfig = await
|
|
3926
|
+
const hugoConfigPath = path10.join(rootPath, "config.toml");
|
|
3927
|
+
if (await fs9.pathExists(hugoConfigPath)) {
|
|
3928
|
+
const hugoConfig = await fs9.readFile(hugoConfigPath, "utf8");
|
|
3882
3929
|
const metaDataFormat = hugoConfig.toString().match(/metaDataFormat = "(.*)"/)?.[1];
|
|
3883
3930
|
if (metaDataFormat && (metaDataFormat === "yaml" || metaDataFormat === "toml" || metaDataFormat === "json")) {
|
|
3884
3931
|
frontMatterFormat = metaDataFormat;
|
|
@@ -3909,10 +3956,10 @@ var detectEnvironment = async ({
|
|
|
3909
3956
|
var detectEnvironment_default = detectEnvironment;
|
|
3910
3957
|
|
|
3911
3958
|
// src/cmds/init/prompts/index.ts
|
|
3912
|
-
|
|
3959
|
+
import prompts6 from "prompts";
|
|
3913
3960
|
|
|
3914
3961
|
// src/cmds/init/prompts/askTinaCloudSetup.ts
|
|
3915
|
-
|
|
3962
|
+
import prompts2 from "prompts";
|
|
3916
3963
|
var tinaCloudSetupQuestions = [
|
|
3917
3964
|
{
|
|
3918
3965
|
name: "clientId",
|
|
@@ -3934,7 +3981,7 @@ ${logText(
|
|
|
3934
3981
|
}
|
|
3935
3982
|
];
|
|
3936
3983
|
var askTinaCloudSetup = async ({ config: config2 }) => {
|
|
3937
|
-
const { clientId, token } = await (
|
|
3984
|
+
const { clientId, token } = await prompts2(tinaCloudSetupQuestions);
|
|
3938
3985
|
config2.envVars.push(
|
|
3939
3986
|
{
|
|
3940
3987
|
key: "NEXT_PUBLIC_TINA_CLIENT_ID",
|
|
@@ -3948,7 +3995,7 @@ var askTinaCloudSetup = async ({ config: config2 }) => {
|
|
|
3948
3995
|
};
|
|
3949
3996
|
|
|
3950
3997
|
// src/cmds/init/prompts/gitProvider.ts
|
|
3951
|
-
|
|
3998
|
+
import prompts3 from "prompts";
|
|
3952
3999
|
var supportedGitProviders = {
|
|
3953
4000
|
github: {
|
|
3954
4001
|
imports: [
|
|
@@ -3970,7 +4017,7 @@ var supportedGitProviders = {
|
|
|
3970
4017
|
}
|
|
3971
4018
|
};
|
|
3972
4019
|
var chooseGitProvider = async ({ config: config2 }) => {
|
|
3973
|
-
const result = await (
|
|
4020
|
+
const result = await prompts3([
|
|
3974
4021
|
{
|
|
3975
4022
|
name: "githubToken",
|
|
3976
4023
|
type: "text",
|
|
@@ -4015,7 +4062,7 @@ ${logText(
|
|
|
4015
4062
|
};
|
|
4016
4063
|
|
|
4017
4064
|
// src/cmds/init/prompts/databaseAdapter.ts
|
|
4018
|
-
|
|
4065
|
+
import prompts4 from "prompts";
|
|
4019
4066
|
var supportedDatabaseAdapters = {
|
|
4020
4067
|
["upstash-redis"]: {
|
|
4021
4068
|
databaseAdapterClassText: `new RedisLevel({
|
|
@@ -4061,7 +4108,7 @@ var databaseAdapterUpdateConfig = {
|
|
|
4061
4108
|
other: async (_args) => {
|
|
4062
4109
|
},
|
|
4063
4110
|
mongodb: async ({ config: config2 }) => {
|
|
4064
|
-
const result = await (
|
|
4111
|
+
const result = await prompts4([
|
|
4065
4112
|
{
|
|
4066
4113
|
name: "mongoDBUri",
|
|
4067
4114
|
type: "text",
|
|
@@ -4076,7 +4123,7 @@ var databaseAdapterUpdateConfig = {
|
|
|
4076
4123
|
});
|
|
4077
4124
|
},
|
|
4078
4125
|
"upstash-redis": async ({ config: config2 }) => {
|
|
4079
|
-
const result = await (
|
|
4126
|
+
const result = await prompts4([
|
|
4080
4127
|
{
|
|
4081
4128
|
name: "kvRestApiUrl",
|
|
4082
4129
|
type: "text",
|
|
@@ -4107,7 +4154,7 @@ var chooseDatabaseAdapter = async ({
|
|
|
4107
4154
|
framework,
|
|
4108
4155
|
config: config2
|
|
4109
4156
|
}) => {
|
|
4110
|
-
const answers = await (
|
|
4157
|
+
const answers = await prompts4([
|
|
4111
4158
|
{
|
|
4112
4159
|
name: "dataLayerAdapter",
|
|
4113
4160
|
message: "Select a self-hosted Database Adapter",
|
|
@@ -4137,8 +4184,8 @@ var chooseDatabaseAdapter = async ({
|
|
|
4137
4184
|
};
|
|
4138
4185
|
|
|
4139
4186
|
// src/cmds/init/prompts/authProvider.ts
|
|
4140
|
-
|
|
4141
|
-
|
|
4187
|
+
import crypto2 from "crypto-js";
|
|
4188
|
+
import prompts5 from "prompts";
|
|
4142
4189
|
var supportedAuthProviders = {
|
|
4143
4190
|
other: {
|
|
4144
4191
|
name: "other"
|
|
@@ -4187,12 +4234,12 @@ var authProviderUpdateConfig = {
|
|
|
4187
4234
|
},
|
|
4188
4235
|
"tina-cloud": askTinaCloudSetup,
|
|
4189
4236
|
"next-auth": async ({ config: config2 }) => {
|
|
4190
|
-
const result = await (
|
|
4237
|
+
const result = await prompts5([
|
|
4191
4238
|
{
|
|
4192
4239
|
name: "nextAuthSecret",
|
|
4193
4240
|
type: "text",
|
|
4194
4241
|
message: `What is the NextAuth.js Secret? (Hit enter to use a randomly generated secret)`,
|
|
4195
|
-
initial: process.env.NEXTAUTH_SECRET ||
|
|
4242
|
+
initial: process.env.NEXTAUTH_SECRET || crypto2.lib.WordArray.random(16).toString()
|
|
4196
4243
|
}
|
|
4197
4244
|
]);
|
|
4198
4245
|
config2.envVars.push({
|
|
@@ -4217,7 +4264,7 @@ var forestryDisclaimer = logText(
|
|
|
4217
4264
|
`Note: This migration will update some of your content to match tina. Please save a backup of your content before doing this migration. (This can be done with git)`
|
|
4218
4265
|
);
|
|
4219
4266
|
var askCommonSetUp = async () => {
|
|
4220
|
-
const answers = await (
|
|
4267
|
+
const answers = await prompts6([
|
|
4221
4268
|
{
|
|
4222
4269
|
name: "framework",
|
|
4223
4270
|
type: "select",
|
|
@@ -4281,7 +4328,7 @@ ${forestryDisclaimer}`
|
|
|
4281
4328
|
message: `What format are you using in your frontmatter?`
|
|
4282
4329
|
});
|
|
4283
4330
|
}
|
|
4284
|
-
const answers = await (
|
|
4331
|
+
const answers = await prompts6(questions);
|
|
4285
4332
|
return answers;
|
|
4286
4333
|
};
|
|
4287
4334
|
var askTinaSetupPrompts = async (params) => {
|
|
@@ -4306,11 +4353,11 @@ var askTinaSetupPrompts = async (params) => {
|
|
|
4306
4353
|
)
|
|
4307
4354
|
});
|
|
4308
4355
|
}
|
|
4309
|
-
const answers = await (
|
|
4356
|
+
const answers = await prompts6(questions);
|
|
4310
4357
|
return answers;
|
|
4311
4358
|
};
|
|
4312
4359
|
var askIfUsingSelfHosted = async () => {
|
|
4313
|
-
const answers = await (
|
|
4360
|
+
const answers = await prompts6([
|
|
4314
4361
|
{
|
|
4315
4362
|
name: "hosting",
|
|
4316
4363
|
type: "select",
|
|
@@ -4343,20 +4390,20 @@ var makeImportString = (imports) => {
|
|
|
4343
4390
|
};
|
|
4344
4391
|
|
|
4345
4392
|
// src/cmds/init/prompts/generatedFiles.ts
|
|
4346
|
-
|
|
4393
|
+
import prompts7 from "prompts";
|
|
4347
4394
|
var askIfOverride = async ({
|
|
4348
4395
|
generatedFile,
|
|
4349
4396
|
usingTypescript
|
|
4350
4397
|
}) => {
|
|
4351
4398
|
if (usingTypescript) {
|
|
4352
|
-
const result = await (
|
|
4399
|
+
const result = await prompts7({
|
|
4353
4400
|
name: `override`,
|
|
4354
4401
|
type: "confirm",
|
|
4355
4402
|
message: `Found existing file at ${generatedFile.fullPathTS}. Would you like to overwrite?`
|
|
4356
4403
|
});
|
|
4357
4404
|
return Boolean(result.override);
|
|
4358
4405
|
} else {
|
|
4359
|
-
const result = await (
|
|
4406
|
+
const result = await prompts7({
|
|
4360
4407
|
name: `override`,
|
|
4361
4408
|
type: "confirm",
|
|
4362
4409
|
message: `Found existing file at ${generatedFile.fullPathJS}. Would you like to overwrite?`
|
|
@@ -4491,24 +4538,25 @@ var CLICommand = class {
|
|
|
4491
4538
|
};
|
|
4492
4539
|
|
|
4493
4540
|
// src/cmds/init/apply.ts
|
|
4494
|
-
|
|
4541
|
+
import path14 from "path";
|
|
4495
4542
|
|
|
4496
4543
|
// src/cmds/forestry-migrate/index.ts
|
|
4497
|
-
|
|
4498
|
-
|
|
4499
|
-
|
|
4500
|
-
|
|
4501
|
-
|
|
4502
|
-
|
|
4544
|
+
import fs11 from "fs-extra";
|
|
4545
|
+
import path12 from "path";
|
|
4546
|
+
import yaml2 from "js-yaml";
|
|
4547
|
+
import pkg from "minimatch";
|
|
4548
|
+
import { parseFile, stringifyFile } from "@tinacms/graphql";
|
|
4549
|
+
import { CONTENT_FORMATS } from "@tinacms/schema-tools";
|
|
4503
4550
|
|
|
4504
4551
|
// src/cmds/forestry-migrate/util/index.ts
|
|
4505
|
-
|
|
4506
|
-
|
|
4507
|
-
|
|
4508
|
-
|
|
4552
|
+
import fs10 from "fs-extra";
|
|
4553
|
+
import path11 from "path";
|
|
4554
|
+
import yaml from "js-yaml";
|
|
4555
|
+
import z from "zod";
|
|
4509
4556
|
|
|
4510
4557
|
// src/cmds/forestry-migrate/util/errorSingleton.ts
|
|
4511
4558
|
var ErrorSingleton = class _ErrorSingleton {
|
|
4559
|
+
static instance;
|
|
4512
4560
|
/**
|
|
4513
4561
|
* The Singleton's constructor should always be private to prevent direct
|
|
4514
4562
|
* construction calls with the `new` operator.
|
|
@@ -4528,6 +4576,7 @@ var ErrorSingleton = class _ErrorSingleton {
|
|
|
4528
4576
|
}
|
|
4529
4577
|
return _ErrorSingleton.instance;
|
|
4530
4578
|
}
|
|
4579
|
+
collectionNameErrors;
|
|
4531
4580
|
addErrorName(error) {
|
|
4532
4581
|
this.collectionNameErrors.push(error);
|
|
4533
4582
|
}
|
|
@@ -4550,8 +4599,8 @@ var ErrorSingleton = class _ErrorSingleton {
|
|
|
4550
4599
|
};
|
|
4551
4600
|
|
|
4552
4601
|
// src/cmds/forestry-migrate/util/codeTransformer.ts
|
|
4553
|
-
|
|
4554
|
-
|
|
4602
|
+
import { format } from "prettier";
|
|
4603
|
+
import TsParser from "prettier/parser-typescript.js";
|
|
4555
4604
|
var addVariablesToCode = (codeWithTinaPrefix) => {
|
|
4556
4605
|
const code = codeWithTinaPrefix.replace(
|
|
4557
4606
|
/"__TINA_INTERNAL__:::(.*?):::"/g,
|
|
@@ -4588,7 +4637,7 @@ var makeTemplateFile = async ({
|
|
|
4588
4637
|
`export function ${stringifyLabelWithField(
|
|
4589
4638
|
template.templateObj.label
|
|
4590
4639
|
)} (){
|
|
4591
|
-
return ${addVariablesToCode(JSON.stringify(template.fields, null, 2)).code} ${usingTypescript ? "as TinaField[]" : ""}
|
|
4640
|
+
return ${addVariablesToCode(JSON.stringify(template.fields, null, 2)).code} ${usingTypescript ? "as TinaField[]" : ""}
|
|
4592
4641
|
} `
|
|
4593
4642
|
);
|
|
4594
4643
|
}
|
|
@@ -4596,9 +4645,9 @@ var makeTemplateFile = async ({
|
|
|
4596
4645
|
${usingTypescript ? "import type { TinaField } from 'tinacms'" : ""}
|
|
4597
4646
|
${templateCodeText.join("\n")}
|
|
4598
4647
|
`;
|
|
4599
|
-
const formattedCode =
|
|
4648
|
+
const formattedCode = format(templateCode, {
|
|
4600
4649
|
parser: "typescript",
|
|
4601
|
-
plugins: [
|
|
4650
|
+
plugins: [TsParser]
|
|
4602
4651
|
});
|
|
4603
4652
|
return { importStatements, templateCodeText: formattedCode };
|
|
4604
4653
|
};
|
|
@@ -4630,82 +4679,82 @@ var stringifyTemplateName = (name2, template) => {
|
|
|
4630
4679
|
return newName;
|
|
4631
4680
|
}
|
|
4632
4681
|
};
|
|
4633
|
-
var forestryConfigSchema =
|
|
4634
|
-
sections:
|
|
4635
|
-
|
|
4636
|
-
type:
|
|
4637
|
-
|
|
4638
|
-
|
|
4639
|
-
|
|
4640
|
-
|
|
4641
|
-
|
|
4682
|
+
var forestryConfigSchema = z.object({
|
|
4683
|
+
sections: z.array(
|
|
4684
|
+
z.object({
|
|
4685
|
+
type: z.union([
|
|
4686
|
+
z.literal("directory"),
|
|
4687
|
+
z.literal("document"),
|
|
4688
|
+
z.literal("heading"),
|
|
4689
|
+
z.literal("jekyll-pages"),
|
|
4690
|
+
z.literal("jekyll-posts")
|
|
4642
4691
|
]),
|
|
4643
|
-
label:
|
|
4644
|
-
path:
|
|
4645
|
-
match:
|
|
4646
|
-
exclude:
|
|
4647
|
-
create:
|
|
4648
|
-
templates:
|
|
4649
|
-
new_doc_ext:
|
|
4650
|
-
read_only:
|
|
4692
|
+
label: z.string(),
|
|
4693
|
+
path: z.string().optional().nullable(),
|
|
4694
|
+
match: z.string().optional().nullable(),
|
|
4695
|
+
exclude: z.string().optional().nullable(),
|
|
4696
|
+
create: z.union([z.literal("all"), z.literal("documents"), z.literal("none")]).optional(),
|
|
4697
|
+
templates: z.array(z.string()).optional().nullable(),
|
|
4698
|
+
new_doc_ext: z.string().optional().nullable(),
|
|
4699
|
+
read_only: z.boolean().optional().nullable()
|
|
4651
4700
|
})
|
|
4652
4701
|
)
|
|
4653
4702
|
});
|
|
4654
|
-
var forestryFieldWithoutField =
|
|
4703
|
+
var forestryFieldWithoutField = z.object({
|
|
4655
4704
|
// TODO: maybe better type this?
|
|
4656
|
-
type:
|
|
4657
|
-
|
|
4658
|
-
|
|
4659
|
-
|
|
4660
|
-
|
|
4661
|
-
|
|
4662
|
-
|
|
4663
|
-
|
|
4664
|
-
|
|
4665
|
-
|
|
4666
|
-
|
|
4667
|
-
|
|
4668
|
-
|
|
4669
|
-
|
|
4670
|
-
|
|
4671
|
-
|
|
4705
|
+
type: z.union([
|
|
4706
|
+
z.literal("text"),
|
|
4707
|
+
z.literal("datetime"),
|
|
4708
|
+
z.literal("list"),
|
|
4709
|
+
z.literal("file"),
|
|
4710
|
+
z.literal("image_gallery"),
|
|
4711
|
+
z.literal("textarea"),
|
|
4712
|
+
z.literal("tag_list"),
|
|
4713
|
+
z.literal("number"),
|
|
4714
|
+
z.literal("boolean"),
|
|
4715
|
+
z.literal("field_group"),
|
|
4716
|
+
z.literal("field_group_list"),
|
|
4717
|
+
z.literal("select"),
|
|
4718
|
+
z.literal("include"),
|
|
4719
|
+
z.literal("blocks"),
|
|
4720
|
+
z.literal("color")
|
|
4672
4721
|
]),
|
|
4673
|
-
template_types:
|
|
4674
|
-
name:
|
|
4675
|
-
label:
|
|
4676
|
-
default:
|
|
4677
|
-
template:
|
|
4678
|
-
config:
|
|
4722
|
+
template_types: z.array(z.string()).optional().nullable(),
|
|
4723
|
+
name: z.string(),
|
|
4724
|
+
label: z.string(),
|
|
4725
|
+
default: z.any().optional(),
|
|
4726
|
+
template: z.string().optional(),
|
|
4727
|
+
config: z.object({
|
|
4679
4728
|
// min and max are used for lists
|
|
4680
|
-
min:
|
|
4681
|
-
max:
|
|
4682
|
-
required:
|
|
4683
|
-
use_select:
|
|
4684
|
-
date_format:
|
|
4685
|
-
time_format:
|
|
4686
|
-
options:
|
|
4687
|
-
source:
|
|
4688
|
-
type:
|
|
4689
|
-
|
|
4690
|
-
|
|
4691
|
-
|
|
4692
|
-
|
|
4729
|
+
min: z.number().optional().nullable(),
|
|
4730
|
+
max: z.number().optional().nullable(),
|
|
4731
|
+
required: z.boolean().optional().nullable(),
|
|
4732
|
+
use_select: z.boolean().optional().nullable(),
|
|
4733
|
+
date_format: z.string().optional().nullable(),
|
|
4734
|
+
time_format: z.string().optional().nullable(),
|
|
4735
|
+
options: z.array(z.string()).optional().nullable(),
|
|
4736
|
+
source: z.object({
|
|
4737
|
+
type: z.union([
|
|
4738
|
+
z.literal("custom"),
|
|
4739
|
+
z.literal("pages"),
|
|
4740
|
+
z.literal("documents"),
|
|
4741
|
+
z.literal("simple"),
|
|
4693
4742
|
// TODO: I want to ignore this key if its invalid
|
|
4694
|
-
|
|
4743
|
+
z.string()
|
|
4695
4744
|
]).optional().nullable(),
|
|
4696
|
-
section:
|
|
4745
|
+
section: z.string().optional().nullable()
|
|
4697
4746
|
}).optional()
|
|
4698
4747
|
}).optional()
|
|
4699
4748
|
});
|
|
4700
|
-
var forestryField =
|
|
4749
|
+
var forestryField = z.lazy(
|
|
4701
4750
|
() => forestryFieldWithoutField.extend({
|
|
4702
|
-
fields:
|
|
4751
|
+
fields: z.array(forestryField).optional()
|
|
4703
4752
|
})
|
|
4704
4753
|
);
|
|
4705
|
-
var FrontmatterTemplateSchema =
|
|
4706
|
-
label:
|
|
4707
|
-
hide_body:
|
|
4708
|
-
fields:
|
|
4754
|
+
var FrontmatterTemplateSchema = z.object({
|
|
4755
|
+
label: z.string(),
|
|
4756
|
+
hide_body: z.boolean().optional(),
|
|
4757
|
+
fields: z.array(forestryField).optional()
|
|
4709
4758
|
});
|
|
4710
4759
|
var transformForestryFieldsToTinaFields = ({
|
|
4711
4760
|
fields,
|
|
@@ -4928,7 +4977,7 @@ var transformForestryFieldsToTinaFields = ({
|
|
|
4928
4977
|
return tinaFields;
|
|
4929
4978
|
};
|
|
4930
4979
|
var getFieldsFromTemplates = ({ tem, pathToForestryConfig, skipBlocks = false }) => {
|
|
4931
|
-
const templatePath =
|
|
4980
|
+
const templatePath = path11.join(
|
|
4932
4981
|
pathToForestryConfig,
|
|
4933
4982
|
".forestry",
|
|
4934
4983
|
"front_matter",
|
|
@@ -4937,7 +4986,7 @@ var getFieldsFromTemplates = ({ tem, pathToForestryConfig, skipBlocks = false })
|
|
|
4937
4986
|
);
|
|
4938
4987
|
let templateString = "";
|
|
4939
4988
|
try {
|
|
4940
|
-
templateString =
|
|
4989
|
+
templateString = fs10.readFileSync(templatePath).toString();
|
|
4941
4990
|
} catch {
|
|
4942
4991
|
throw new Error(
|
|
4943
4992
|
`Could not find template ${tem} at ${templatePath}
|
|
@@ -4945,7 +4994,7 @@ var getFieldsFromTemplates = ({ tem, pathToForestryConfig, skipBlocks = false })
|
|
|
4945
4994
|
This will require manual migration.`
|
|
4946
4995
|
);
|
|
4947
4996
|
}
|
|
4948
|
-
const templateObj =
|
|
4997
|
+
const templateObj = yaml.load(templateString);
|
|
4949
4998
|
const template = parseTemplates({ val: templateObj });
|
|
4950
4999
|
const fields = transformForestryFieldsToTinaFields({
|
|
4951
5000
|
fields: template.fields,
|
|
@@ -4965,6 +5014,7 @@ var parseSections = ({ val }) => {
|
|
|
4965
5014
|
};
|
|
4966
5015
|
|
|
4967
5016
|
// src/cmds/forestry-migrate/index.ts
|
|
5017
|
+
var { minimatch } = pkg;
|
|
4968
5018
|
var BODY_FIELD = {
|
|
4969
5019
|
// This is the body field
|
|
4970
5020
|
type: "rich-text",
|
|
@@ -4993,7 +5043,7 @@ var transformForestryMatchToTinaMatch = (match) => {
|
|
|
4993
5043
|
};
|
|
4994
5044
|
function checkExt(ext) {
|
|
4995
5045
|
const extReal = ext.replace(".", "");
|
|
4996
|
-
if (
|
|
5046
|
+
if (CONTENT_FORMATS.includes(extReal)) {
|
|
4997
5047
|
return extReal;
|
|
4998
5048
|
} else {
|
|
4999
5049
|
return false;
|
|
@@ -5002,9 +5052,9 @@ function checkExt(ext) {
|
|
|
5002
5052
|
var generateAllTemplates = async ({
|
|
5003
5053
|
pathToForestryConfig
|
|
5004
5054
|
}) => {
|
|
5005
|
-
const allTemplates = (await
|
|
5006
|
-
|
|
5007
|
-
)).map((tem) =>
|
|
5055
|
+
const allTemplates = (await fs11.readdir(
|
|
5056
|
+
path12.join(pathToForestryConfig, ".forestry", "front_matter", "templates")
|
|
5057
|
+
)).map((tem) => path12.basename(tem, ".yml"));
|
|
5008
5058
|
const templateMap = /* @__PURE__ */ new Map();
|
|
5009
5059
|
const proms = allTemplates.map(async (tem) => {
|
|
5010
5060
|
try {
|
|
@@ -5014,7 +5064,7 @@ var generateAllTemplates = async ({
|
|
|
5014
5064
|
});
|
|
5015
5065
|
templateMap.set(tem, { fields, templateObj });
|
|
5016
5066
|
} catch (e) {
|
|
5017
|
-
logger.
|
|
5067
|
+
logger.warn(`Error parsing template frontmatter template, ${tem}.yml`);
|
|
5018
5068
|
console.error(e);
|
|
5019
5069
|
templateMap.set(tem, { fields: [], templateObj: {} });
|
|
5020
5070
|
}
|
|
@@ -5058,7 +5108,7 @@ var generateCollectionFromForestrySection = (args) => {
|
|
|
5058
5108
|
}
|
|
5059
5109
|
if (section.type === "directory") {
|
|
5060
5110
|
if (!section?.path || section.path === "/" || section.path === "./" || section.path === ".") {
|
|
5061
|
-
logger.
|
|
5111
|
+
logger.warn(
|
|
5062
5112
|
warnText(
|
|
5063
5113
|
`Warning: Section ${section.label} is using a Root Path. Currently, Tina Does not support Root paths see ${linkText(
|
|
5064
5114
|
"https://github.com/tinacms/tinacms/issues/3768"
|
|
@@ -5079,7 +5129,7 @@ var generateCollectionFromForestrySection = (args) => {
|
|
|
5079
5129
|
glob = section.path + "/" + section.match;
|
|
5080
5130
|
}
|
|
5081
5131
|
if (pages.some((page) => {
|
|
5082
|
-
return (
|
|
5132
|
+
return minimatch(page, glob);
|
|
5083
5133
|
})) {
|
|
5084
5134
|
forestryTemplates.push(templateKey);
|
|
5085
5135
|
}
|
|
@@ -5149,9 +5199,9 @@ var generateCollectionFromForestrySection = (args) => {
|
|
|
5149
5199
|
return c;
|
|
5150
5200
|
} else if (section.type === "document") {
|
|
5151
5201
|
const filePath = section.path;
|
|
5152
|
-
const extname =
|
|
5153
|
-
const fileName =
|
|
5154
|
-
const dir =
|
|
5202
|
+
const extname = path12.extname(filePath);
|
|
5203
|
+
const fileName = path12.basename(filePath, extname);
|
|
5204
|
+
const dir = path12.dirname(filePath);
|
|
5155
5205
|
const ext = checkExt(extname);
|
|
5156
5206
|
if (ext) {
|
|
5157
5207
|
const fields = [];
|
|
@@ -5195,7 +5245,7 @@ var generateCollectionFromForestrySection = (args) => {
|
|
|
5195
5245
|
fields
|
|
5196
5246
|
};
|
|
5197
5247
|
} else {
|
|
5198
|
-
logger.
|
|
5248
|
+
logger.warn(
|
|
5199
5249
|
warnText(
|
|
5200
5250
|
`Error: document section has an unsupported file extension: ${extname} in ${section.path}`
|
|
5201
5251
|
)
|
|
@@ -5213,8 +5263,8 @@ var generateCollections = async ({
|
|
|
5213
5263
|
templateMap,
|
|
5214
5264
|
usingTypescript
|
|
5215
5265
|
});
|
|
5216
|
-
const forestryConfig = await
|
|
5217
|
-
|
|
5266
|
+
const forestryConfig = await fs11.readFile(
|
|
5267
|
+
path12.join(pathToForestryConfig, ".forestry", "settings.yml")
|
|
5218
5268
|
);
|
|
5219
5269
|
rewriteTemplateKeysInDocs({
|
|
5220
5270
|
templateMap,
|
|
@@ -5224,7 +5274,7 @@ var generateCollections = async ({
|
|
|
5224
5274
|
}
|
|
5225
5275
|
});
|
|
5226
5276
|
const collections = parseSections({
|
|
5227
|
-
val:
|
|
5277
|
+
val: yaml2.load(forestryConfig.toString())
|
|
5228
5278
|
}).sections.map(
|
|
5229
5279
|
(section) => generateCollectionFromForestrySection({
|
|
5230
5280
|
section,
|
|
@@ -5244,13 +5294,13 @@ var rewriteTemplateKeysInDocs = (args) => {
|
|
|
5244
5294
|
const { templateObj } = templateMap.get(templateKey);
|
|
5245
5295
|
templateObj?.pages?.forEach((page) => {
|
|
5246
5296
|
try {
|
|
5247
|
-
const filePath =
|
|
5248
|
-
if (
|
|
5297
|
+
const filePath = path12.join(page);
|
|
5298
|
+
if (fs11.lstatSync(filePath).isDirectory()) {
|
|
5249
5299
|
return;
|
|
5250
5300
|
}
|
|
5251
|
-
const extname =
|
|
5252
|
-
const fileContent =
|
|
5253
|
-
const content =
|
|
5301
|
+
const extname = path12.extname(filePath);
|
|
5302
|
+
const fileContent = fs11.readFileSync(filePath).toString();
|
|
5303
|
+
const content = parseFile(
|
|
5254
5304
|
fileContent,
|
|
5255
5305
|
extname,
|
|
5256
5306
|
(yup) => yup.object({}),
|
|
@@ -5260,9 +5310,9 @@ var rewriteTemplateKeysInDocs = (args) => {
|
|
|
5260
5310
|
_template: stringifyLabel(templateKey),
|
|
5261
5311
|
...content
|
|
5262
5312
|
};
|
|
5263
|
-
|
|
5313
|
+
fs11.writeFileSync(
|
|
5264
5314
|
filePath,
|
|
5265
|
-
|
|
5315
|
+
stringifyFile(newContent, extname, true, markdownParseConfig)
|
|
5266
5316
|
);
|
|
5267
5317
|
} catch (error) {
|
|
5268
5318
|
console.log(
|
|
@@ -5274,32 +5324,25 @@ var rewriteTemplateKeysInDocs = (args) => {
|
|
|
5274
5324
|
};
|
|
5275
5325
|
|
|
5276
5326
|
// src/cmds/init/apply.ts
|
|
5277
|
-
|
|
5278
|
-
|
|
5327
|
+
import { Telemetry as Telemetry2 } from "@tinacms/metrics";
|
|
5328
|
+
import fs14 from "fs-extra";
|
|
5279
5329
|
|
|
5280
5330
|
// src/next/commands/codemod-command/index.ts
|
|
5281
|
-
|
|
5282
|
-
|
|
5283
|
-
|
|
5284
|
-
var CodemodCommand = class extends
|
|
5285
|
-
|
|
5286
|
-
|
|
5287
|
-
|
|
5288
|
-
|
|
5289
|
-
|
|
5290
|
-
|
|
5291
|
-
|
|
5292
|
-
|
|
5293
|
-
|
|
5294
|
-
|
|
5295
|
-
|
|
5296
|
-
}
|
|
5297
|
-
static {
|
|
5298
|
-
this.usage = import_clipanion5.Command.Usage({
|
|
5299
|
-
category: `Commands`,
|
|
5300
|
-
description: `Use codemods for various Tina tasks`
|
|
5301
|
-
});
|
|
5302
|
-
}
|
|
5331
|
+
import { Command as Command5, Option as Option5 } from "clipanion";
|
|
5332
|
+
import fs12 from "fs-extra";
|
|
5333
|
+
import path13 from "path";
|
|
5334
|
+
var CodemodCommand = class extends Command5 {
|
|
5335
|
+
static paths = [["codemod"], ["codemod", "move-tina-folder"]];
|
|
5336
|
+
rootPath = Option5.String("--rootPath", {
|
|
5337
|
+
description: "Specify the root directory to run the CLI from"
|
|
5338
|
+
});
|
|
5339
|
+
verbose = Option5.Boolean("-v,--verbose", false, {
|
|
5340
|
+
description: "increase verbosity of logged output"
|
|
5341
|
+
});
|
|
5342
|
+
static usage = Command5.Usage({
|
|
5343
|
+
category: `Commands`,
|
|
5344
|
+
description: `Use codemods for various Tina tasks`
|
|
5345
|
+
});
|
|
5303
5346
|
async catch(error) {
|
|
5304
5347
|
console.log(error);
|
|
5305
5348
|
}
|
|
@@ -5328,13 +5371,13 @@ var moveTinaFolder = async (rootPath = process.cwd()) => {
|
|
|
5328
5371
|
logger.error(e.message);
|
|
5329
5372
|
process.exit(1);
|
|
5330
5373
|
}
|
|
5331
|
-
const tinaDestination =
|
|
5332
|
-
if (await
|
|
5374
|
+
const tinaDestination = path13.join(configManager.rootPath, "tina");
|
|
5375
|
+
if (await fs12.existsSync(tinaDestination)) {
|
|
5333
5376
|
logger.info(
|
|
5334
5377
|
`Folder already exists at ${tinaDestination}. Either delete this folder to complete the codemod, or ensure you have properly copied your config from the ".tina" folder.`
|
|
5335
5378
|
);
|
|
5336
5379
|
} else {
|
|
5337
|
-
await
|
|
5380
|
+
await fs12.moveSync(configManager.tinaFolderPath, tinaDestination);
|
|
5338
5381
|
await writeGitignore(configManager.rootPath);
|
|
5339
5382
|
logger.info(
|
|
5340
5383
|
"Move to 'tina' folder complete. Be sure to update any imports of the autogenerated client!"
|
|
@@ -5342,8 +5385,8 @@ var moveTinaFolder = async (rootPath = process.cwd()) => {
|
|
|
5342
5385
|
}
|
|
5343
5386
|
};
|
|
5344
5387
|
var writeGitignore = async (rootPath) => {
|
|
5345
|
-
await
|
|
5346
|
-
|
|
5388
|
+
await fs12.outputFileSync(
|
|
5389
|
+
path13.join(rootPath, "tina", ".gitignore"),
|
|
5347
5390
|
"__generated__"
|
|
5348
5391
|
);
|
|
5349
5392
|
};
|
|
@@ -5751,7 +5794,7 @@ Suspendisse facilisis, mi ac scelerisque interdum, ligula ex imperdiet felis, a
|
|
|
5751
5794
|
`;
|
|
5752
5795
|
|
|
5753
5796
|
// src/cmds/init/apply.ts
|
|
5754
|
-
|
|
5797
|
+
import { format as format2 } from "prettier";
|
|
5755
5798
|
|
|
5756
5799
|
// src/utils/script-helpers.ts
|
|
5757
5800
|
function generateGqlScript(scriptValue, opts) {
|
|
@@ -5774,38 +5817,38 @@ function extendNextScripts(scripts, opts) {
|
|
|
5774
5817
|
}
|
|
5775
5818
|
|
|
5776
5819
|
// src/cmds/init/codegen/index.ts
|
|
5777
|
-
|
|
5778
|
-
|
|
5820
|
+
import ts2 from "typescript";
|
|
5821
|
+
import fs13 from "fs-extra";
|
|
5779
5822
|
|
|
5780
5823
|
// src/cmds/init/codegen/util.ts
|
|
5781
|
-
|
|
5782
|
-
var makeTransformer = (makeVisitor) => (ctx) => (node) =>
|
|
5824
|
+
import ts from "typescript";
|
|
5825
|
+
var makeTransformer = (makeVisitor) => (ctx) => (node) => ts.visitNode(node, makeVisitor(ctx));
|
|
5783
5826
|
function parseExpression(expression) {
|
|
5784
|
-
const sourceFile =
|
|
5827
|
+
const sourceFile = ts.createSourceFile(
|
|
5785
5828
|
"temp.ts",
|
|
5786
5829
|
expression,
|
|
5787
|
-
|
|
5830
|
+
ts.ScriptTarget.Latest
|
|
5788
5831
|
);
|
|
5789
5832
|
if (sourceFile.statements.length !== 1) {
|
|
5790
5833
|
throw new Error("Expected one statement");
|
|
5791
5834
|
}
|
|
5792
5835
|
const statement = sourceFile.statements[0];
|
|
5793
|
-
if (!
|
|
5836
|
+
if (!ts.isExpressionStatement(statement)) {
|
|
5794
5837
|
throw new Error("Expected an expression statement");
|
|
5795
5838
|
}
|
|
5796
5839
|
return [sourceFile, statement.expression];
|
|
5797
5840
|
}
|
|
5798
5841
|
function parseVariableStatement(stmt) {
|
|
5799
|
-
const sourceFile =
|
|
5842
|
+
const sourceFile = ts.createSourceFile(
|
|
5800
5843
|
"temp.ts",
|
|
5801
5844
|
stmt,
|
|
5802
|
-
|
|
5845
|
+
ts.ScriptTarget.Latest
|
|
5803
5846
|
);
|
|
5804
5847
|
if (sourceFile.statements.length !== 1) {
|
|
5805
5848
|
throw new Error("Expected one statement");
|
|
5806
5849
|
}
|
|
5807
5850
|
const statement = sourceFile.statements[0];
|
|
5808
|
-
if (!
|
|
5851
|
+
if (!ts.isVariableStatement(statement)) {
|
|
5809
5852
|
throw new Error("Expected a variable statement");
|
|
5810
5853
|
}
|
|
5811
5854
|
return [sourceFile, statement];
|
|
@@ -5813,7 +5856,7 @@ function parseVariableStatement(stmt) {
|
|
|
5813
5856
|
|
|
5814
5857
|
// src/cmds/init/codegen/index.ts
|
|
5815
5858
|
var makeVariableStatementVisitor = (sourceFile, variableStmtSourceFile, variableStmt) => (ctx) => (node) => {
|
|
5816
|
-
if (
|
|
5859
|
+
if (ts2.isSourceFile(node)) {
|
|
5817
5860
|
const newStatements = [...node.statements];
|
|
5818
5861
|
let encounteredImports = false;
|
|
5819
5862
|
let firstNonImportStatementIdx = -1;
|
|
@@ -5821,7 +5864,7 @@ var makeVariableStatementVisitor = (sourceFile, variableStmtSourceFile, variable
|
|
|
5821
5864
|
const [newVarDec] = variableStmt.declarationList.declarations;
|
|
5822
5865
|
const newVarDecName = newVarDec.name.getText(variableStmtSourceFile);
|
|
5823
5866
|
for (let i = 0; i < newStatements.length; i++) {
|
|
5824
|
-
const isImport =
|
|
5867
|
+
const isImport = ts2.isImportDeclaration(newStatements[i]);
|
|
5825
5868
|
if (isImport && !encounteredImports) {
|
|
5826
5869
|
encounteredImports = true;
|
|
5827
5870
|
}
|
|
@@ -5829,9 +5872,9 @@ var makeVariableStatementVisitor = (sourceFile, variableStmtSourceFile, variable
|
|
|
5829
5872
|
firstNonImportStatementIdx = i;
|
|
5830
5873
|
}
|
|
5831
5874
|
const stmt = newStatements[i];
|
|
5832
|
-
if (
|
|
5875
|
+
if (ts2.isVariableStatement(stmt)) {
|
|
5833
5876
|
const [dec] = stmt.declarationList.declarations;
|
|
5834
|
-
if (dec.name &&
|
|
5877
|
+
if (dec.name && ts2.isIdentifier(dec.name) && dec.name.getText(sourceFile) === newVarDecName) {
|
|
5835
5878
|
existingStatementIdx = i;
|
|
5836
5879
|
}
|
|
5837
5880
|
}
|
|
@@ -5845,19 +5888,19 @@ var makeVariableStatementVisitor = (sourceFile, variableStmtSourceFile, variable
|
|
|
5845
5888
|
if (existingStatementIdx === -1) {
|
|
5846
5889
|
newStatements.splice(firstNonImportStatementIdx, 0, variableStmt);
|
|
5847
5890
|
}
|
|
5848
|
-
return
|
|
5891
|
+
return ts2.factory.updateSourceFile(node, newStatements);
|
|
5849
5892
|
}
|
|
5850
5893
|
};
|
|
5851
5894
|
var makeImportsVisitor = (sourceFile, importMap) => (ctx) => (node) => {
|
|
5852
|
-
if (
|
|
5895
|
+
if (ts2.isSourceFile(node)) {
|
|
5853
5896
|
const newStatements = [...node.statements];
|
|
5854
5897
|
let changed = false;
|
|
5855
5898
|
for (const [moduleName, imports] of Object.entries(importMap)) {
|
|
5856
5899
|
let foundImportStatement = false;
|
|
5857
5900
|
for (const statement of newStatements) {
|
|
5858
|
-
if (
|
|
5901
|
+
if (ts2.isImportDeclaration(statement) && ts2.isStringLiteral(statement.moduleSpecifier) && statement.moduleSpecifier.text === moduleName) {
|
|
5859
5902
|
foundImportStatement = true;
|
|
5860
|
-
const existingImports = statement.importClause?.namedBindings &&
|
|
5903
|
+
const existingImports = statement.importClause?.namedBindings && ts2.isNamedImports(statement.importClause.namedBindings) ? statement.importClause.namedBindings.elements.map(
|
|
5861
5904
|
(e) => e.name.text
|
|
5862
5905
|
) : [];
|
|
5863
5906
|
const newImports = [
|
|
@@ -5868,22 +5911,22 @@ var makeImportsVisitor = (sourceFile, importMap) => (ctx) => (node) => {
|
|
|
5868
5911
|
])
|
|
5869
5912
|
];
|
|
5870
5913
|
const importSpecifiers = newImports.map(
|
|
5871
|
-
(i) =>
|
|
5914
|
+
(i) => ts2.factory.createImportSpecifier(
|
|
5872
5915
|
void 0,
|
|
5873
|
-
|
|
5874
|
-
|
|
5916
|
+
ts2.factory.createIdentifier(i),
|
|
5917
|
+
ts2.factory.createIdentifier(i)
|
|
5875
5918
|
)
|
|
5876
5919
|
);
|
|
5877
|
-
const namedImports =
|
|
5878
|
-
const importClause =
|
|
5920
|
+
const namedImports = ts2.factory.createNamedImports(importSpecifiers);
|
|
5921
|
+
const importClause = ts2.factory.createImportClause(
|
|
5879
5922
|
false,
|
|
5880
5923
|
void 0,
|
|
5881
5924
|
namedImports
|
|
5882
5925
|
);
|
|
5883
|
-
const importDec =
|
|
5926
|
+
const importDec = ts2.factory.createImportDeclaration(
|
|
5884
5927
|
void 0,
|
|
5885
5928
|
importClause,
|
|
5886
|
-
|
|
5929
|
+
ts2.factory.createStringLiteral(moduleName)
|
|
5887
5930
|
);
|
|
5888
5931
|
newStatements[newStatements.indexOf(statement)] = importDec;
|
|
5889
5932
|
changed = true;
|
|
@@ -5891,45 +5934,45 @@ var makeImportsVisitor = (sourceFile, importMap) => (ctx) => (node) => {
|
|
|
5891
5934
|
}
|
|
5892
5935
|
if (!foundImportStatement) {
|
|
5893
5936
|
const importSpecifiers = imports.map(
|
|
5894
|
-
(i) =>
|
|
5937
|
+
(i) => ts2.factory.createImportSpecifier(
|
|
5895
5938
|
void 0,
|
|
5896
|
-
|
|
5897
|
-
|
|
5939
|
+
ts2.factory.createIdentifier(i),
|
|
5940
|
+
ts2.factory.createIdentifier(i)
|
|
5898
5941
|
)
|
|
5899
5942
|
);
|
|
5900
|
-
const namedImports =
|
|
5901
|
-
const importClause =
|
|
5943
|
+
const namedImports = ts2.factory.createNamedImports(importSpecifiers);
|
|
5944
|
+
const importClause = ts2.factory.createImportClause(
|
|
5902
5945
|
false,
|
|
5903
5946
|
void 0,
|
|
5904
5947
|
namedImports
|
|
5905
5948
|
);
|
|
5906
|
-
const importDec =
|
|
5949
|
+
const importDec = ts2.factory.createImportDeclaration(
|
|
5907
5950
|
void 0,
|
|
5908
5951
|
importClause,
|
|
5909
|
-
|
|
5952
|
+
ts2.factory.createStringLiteral(moduleName)
|
|
5910
5953
|
);
|
|
5911
5954
|
newStatements.unshift(importDec);
|
|
5912
5955
|
changed = true;
|
|
5913
5956
|
}
|
|
5914
5957
|
}
|
|
5915
5958
|
if (changed) {
|
|
5916
|
-
return
|
|
5959
|
+
return ts2.factory.updateSourceFile(node, newStatements);
|
|
5917
5960
|
}
|
|
5918
5961
|
}
|
|
5919
5962
|
};
|
|
5920
5963
|
var makeAddExpressionToSchemaCollectionVisitor = (sourceFile, functionName, newExpressionSourceFile, newExpression) => (ctx) => {
|
|
5921
5964
|
const visit2 = (node) => {
|
|
5922
|
-
if (
|
|
5965
|
+
if (ts2.isCallExpression(node) && ts2.isIdentifier(node.expression) && node.expression.text === functionName && node.arguments.length > 0 && ts2.isObjectLiteralExpression(node.arguments[0])) {
|
|
5923
5966
|
const configObject = node.arguments[0];
|
|
5924
5967
|
const updateProperties = configObject.properties.map((property) => {
|
|
5925
|
-
if (
|
|
5968
|
+
if (ts2.isPropertyAssignment(property)) {
|
|
5926
5969
|
const thisPropertyName = property.name.getText(sourceFile);
|
|
5927
|
-
if (thisPropertyName === "schema" &&
|
|
5970
|
+
if (thisPropertyName === "schema" && ts2.isPropertyAssignment(property) && ts2.isObjectLiteralExpression(property.initializer)) {
|
|
5928
5971
|
const schemaObject = property.initializer;
|
|
5929
5972
|
const collectionsProperty = schemaObject.properties.find(
|
|
5930
|
-
(p) =>
|
|
5973
|
+
(p) => ts2.isPropertyAssignment(p) && p.name.getText(sourceFile) === "collections"
|
|
5931
5974
|
);
|
|
5932
|
-
if (collectionsProperty &&
|
|
5975
|
+
if (collectionsProperty && ts2.isPropertyAssignment(collectionsProperty) && ts2.isArrayLiteralExpression(collectionsProperty.initializer)) {
|
|
5933
5976
|
const collectionsArray = collectionsProperty.initializer;
|
|
5934
5977
|
const collectionItems = collectionsArray.elements.map(
|
|
5935
5978
|
(e) => e.getText(sourceFile)
|
|
@@ -5939,16 +5982,16 @@ var makeAddExpressionToSchemaCollectionVisitor = (sourceFile, functionName, newE
|
|
|
5939
5982
|
)) {
|
|
5940
5983
|
return property;
|
|
5941
5984
|
}
|
|
5942
|
-
return
|
|
5985
|
+
return ts2.factory.updatePropertyAssignment(
|
|
5943
5986
|
property,
|
|
5944
5987
|
property.name,
|
|
5945
|
-
|
|
5988
|
+
ts2.factory.createObjectLiteralExpression(
|
|
5946
5989
|
schemaObject.properties.map((subProp) => {
|
|
5947
|
-
if (
|
|
5948
|
-
return
|
|
5990
|
+
if (ts2.isPropertyAssignment(subProp) && subProp.name.getText(sourceFile) === "collections" && ts2.isArrayLiteralExpression(subProp.initializer)) {
|
|
5991
|
+
return ts2.factory.updatePropertyAssignment(
|
|
5949
5992
|
subProp,
|
|
5950
5993
|
subProp.name,
|
|
5951
|
-
|
|
5994
|
+
ts2.factory.createArrayLiteralExpression(
|
|
5952
5995
|
[newExpression, ...subProp.initializer.elements],
|
|
5953
5996
|
true
|
|
5954
5997
|
)
|
|
@@ -5964,56 +6007,56 @@ var makeAddExpressionToSchemaCollectionVisitor = (sourceFile, functionName, newE
|
|
|
5964
6007
|
}
|
|
5965
6008
|
return property;
|
|
5966
6009
|
});
|
|
5967
|
-
return
|
|
6010
|
+
return ts2.factory.createCallExpression(
|
|
5968
6011
|
node.expression,
|
|
5969
6012
|
node.typeArguments,
|
|
5970
|
-
[
|
|
6013
|
+
[ts2.factory.createObjectLiteralExpression(updateProperties, true)]
|
|
5971
6014
|
);
|
|
5972
6015
|
}
|
|
5973
|
-
return
|
|
6016
|
+
return ts2.visitEachChild(node, visit2, ctx);
|
|
5974
6017
|
};
|
|
5975
6018
|
return (sourceFile2) => {
|
|
5976
|
-
return
|
|
6019
|
+
return ts2.visitEachChild(sourceFile2, visit2, ctx);
|
|
5977
6020
|
};
|
|
5978
6021
|
};
|
|
5979
6022
|
var makeUpdateObjectLiteralPropertyVisitor = (sourceFile, functionName, propertyName, propertyValueExpressionSourceFile, propertyValue) => (ctx) => {
|
|
5980
6023
|
const visitor = (node) => {
|
|
5981
|
-
if (
|
|
6024
|
+
if (ts2.isCallExpression(node) && ts2.isIdentifier(node.expression) && node.expression.text === functionName && node.arguments.length > 0 && ts2.isObjectLiteralExpression(node.arguments[0])) {
|
|
5982
6025
|
let foundProperty = false;
|
|
5983
6026
|
const configObject = node.arguments[0];
|
|
5984
6027
|
const updateProperties = configObject.properties.map((property) => {
|
|
5985
|
-
if (
|
|
6028
|
+
if (ts2.isPropertyAssignment(property) || ts2.isShorthandPropertyAssignment(property)) {
|
|
5986
6029
|
const name2 = property.name.getText(sourceFile);
|
|
5987
6030
|
if (name2 === propertyName) {
|
|
5988
6031
|
foundProperty = true;
|
|
5989
|
-
return
|
|
6032
|
+
return ts2.factory.createPropertyAssignment(name2, propertyValue);
|
|
5990
6033
|
}
|
|
5991
6034
|
}
|
|
5992
6035
|
return property;
|
|
5993
6036
|
});
|
|
5994
6037
|
if (!foundProperty) {
|
|
5995
6038
|
updateProperties.unshift(
|
|
5996
|
-
|
|
6039
|
+
ts2.factory.createPropertyAssignment(propertyName, propertyValue)
|
|
5997
6040
|
);
|
|
5998
6041
|
}
|
|
5999
|
-
return
|
|
6042
|
+
return ts2.factory.createCallExpression(
|
|
6000
6043
|
node.expression,
|
|
6001
6044
|
node.typeArguments,
|
|
6002
|
-
[
|
|
6045
|
+
[ts2.factory.createObjectLiteralExpression(updateProperties, true)]
|
|
6003
6046
|
);
|
|
6004
6047
|
}
|
|
6005
|
-
return
|
|
6048
|
+
return ts2.visitEachChild(node, visitor, ctx);
|
|
6006
6049
|
};
|
|
6007
6050
|
return (sourceFile2) => {
|
|
6008
|
-
return
|
|
6051
|
+
return ts2.visitNode(sourceFile2, visitor);
|
|
6009
6052
|
};
|
|
6010
6053
|
};
|
|
6011
6054
|
var addSelfHostedTinaAuthToConfig = async (config2, configFile) => {
|
|
6012
6055
|
const pathToConfig = configFile.resolve(config2.typescript).path;
|
|
6013
|
-
const sourceFile =
|
|
6056
|
+
const sourceFile = ts2.createSourceFile(
|
|
6014
6057
|
pathToConfig,
|
|
6015
|
-
|
|
6016
|
-
config2.typescript ?
|
|
6058
|
+
fs13.readFileSync(pathToConfig, "utf8"),
|
|
6059
|
+
config2.typescript ? ts2.ScriptTarget.Latest : ts2.ScriptTarget.ESNext
|
|
6017
6060
|
);
|
|
6018
6061
|
const { configImports, configAuthProviderClass, extraTinaCollections } = config2.authProvider;
|
|
6019
6062
|
const importMap = {
|
|
@@ -6026,7 +6069,7 @@ var addSelfHostedTinaAuthToConfig = async (config2, configFile) => {
|
|
|
6026
6069
|
{}
|
|
6027
6070
|
)
|
|
6028
6071
|
};
|
|
6029
|
-
const transformedSourceFileResult =
|
|
6072
|
+
const transformedSourceFileResult = ts2.transform(
|
|
6030
6073
|
sourceFile,
|
|
6031
6074
|
[
|
|
6032
6075
|
makeImportsVisitor(sourceFile, {
|
|
@@ -6062,13 +6105,14 @@ var addSelfHostedTinaAuthToConfig = async (config2, configFile) => {
|
|
|
6062
6105
|
)
|
|
6063
6106
|
].map((visitor) => makeTransformer(visitor))
|
|
6064
6107
|
);
|
|
6065
|
-
return
|
|
6108
|
+
return fs13.writeFile(
|
|
6066
6109
|
pathToConfig,
|
|
6067
|
-
|
|
6110
|
+
ts2.createPrinter({ omitTrailingSemicolon: true }).printFile(transformedSourceFileResult.transformed[0])
|
|
6068
6111
|
);
|
|
6069
6112
|
};
|
|
6070
6113
|
|
|
6071
6114
|
// src/cmds/init/apply.ts
|
|
6115
|
+
import { exec } from "child_process";
|
|
6072
6116
|
async function apply({
|
|
6073
6117
|
env,
|
|
6074
6118
|
params,
|
|
@@ -6179,8 +6223,8 @@ async function apply({
|
|
|
6179
6223
|
await addConfigFile({
|
|
6180
6224
|
configArgs: {
|
|
6181
6225
|
config: config2,
|
|
6182
|
-
publicFolder:
|
|
6183
|
-
|
|
6226
|
+
publicFolder: path14.join(
|
|
6227
|
+
path14.relative(process.cwd(), pathToForestryConfig),
|
|
6184
6228
|
config2.publicFolder
|
|
6185
6229
|
),
|
|
6186
6230
|
collections,
|
|
@@ -6237,7 +6281,7 @@ var reportTelemetry = async ({
|
|
|
6237
6281
|
if (noTelemetry) {
|
|
6238
6282
|
logger.info(logText("Telemetry disabled"));
|
|
6239
6283
|
}
|
|
6240
|
-
const telemetry = new
|
|
6284
|
+
const telemetry = new Telemetry2({ disabled: noTelemetry });
|
|
6241
6285
|
const schemaFileType = usingTypescript ? "ts" : "js";
|
|
6242
6286
|
await telemetry.submitRecord({
|
|
6243
6287
|
event: {
|
|
@@ -6253,18 +6297,18 @@ var createPackageJSON = async () => {
|
|
|
6253
6297
|
};
|
|
6254
6298
|
var createGitignore = async ({ baseDir }) => {
|
|
6255
6299
|
logger.info(logText("No .gitignore found, creating one"));
|
|
6256
|
-
|
|
6300
|
+
fs14.outputFileSync(path14.join(baseDir, ".gitignore"), "node_modules");
|
|
6257
6301
|
};
|
|
6258
6302
|
var updateGitIgnore = async ({
|
|
6259
6303
|
baseDir,
|
|
6260
6304
|
items
|
|
6261
6305
|
}) => {
|
|
6262
6306
|
logger.info(logText(`Adding ${items.join(",")} to .gitignore`));
|
|
6263
|
-
const gitignoreContent =
|
|
6307
|
+
const gitignoreContent = fs14.readFileSync(path14.join(baseDir, ".gitignore")).toString();
|
|
6264
6308
|
const newGitignoreContent = [...gitignoreContent.split("\n"), ...items].join(
|
|
6265
6309
|
"\n"
|
|
6266
6310
|
);
|
|
6267
|
-
await
|
|
6311
|
+
await fs14.writeFile(path14.join(baseDir, ".gitignore"), newGitignoreContent);
|
|
6268
6312
|
};
|
|
6269
6313
|
var addDependencies = async (config2, env, params) => {
|
|
6270
6314
|
const { packageManager } = config2;
|
|
@@ -6339,7 +6383,7 @@ var writeGeneratedFile = async ({
|
|
|
6339
6383
|
if (exists) {
|
|
6340
6384
|
if (overwrite) {
|
|
6341
6385
|
logger.info(`Overwriting file at ${path15}... \u2705`);
|
|
6342
|
-
|
|
6386
|
+
fs14.outputFileSync(path15, content);
|
|
6343
6387
|
} else {
|
|
6344
6388
|
logger.info(`Not overwriting file at ${path15}.`);
|
|
6345
6389
|
logger.info(
|
|
@@ -6349,8 +6393,8 @@ ${indentText(content)}}`)
|
|
|
6349
6393
|
}
|
|
6350
6394
|
} else {
|
|
6351
6395
|
logger.info(`Adding file at ${path15}... \u2705`);
|
|
6352
|
-
await
|
|
6353
|
-
|
|
6396
|
+
await fs14.ensureDir(parentPath);
|
|
6397
|
+
fs14.outputFileSync(path15, content);
|
|
6354
6398
|
}
|
|
6355
6399
|
};
|
|
6356
6400
|
var addConfigFile = async ({
|
|
@@ -6359,7 +6403,7 @@ var addConfigFile = async ({
|
|
|
6359
6403
|
generatedFile,
|
|
6360
6404
|
config: config2
|
|
6361
6405
|
}) => {
|
|
6362
|
-
const content = (
|
|
6406
|
+
const content = format2(generateConfig(configArgs), {
|
|
6363
6407
|
parser: "babel"
|
|
6364
6408
|
});
|
|
6365
6409
|
await writeGeneratedFile({
|
|
@@ -6389,7 +6433,7 @@ var addNextApiRoute = async ({
|
|
|
6389
6433
|
generatedFile,
|
|
6390
6434
|
env
|
|
6391
6435
|
}) => {
|
|
6392
|
-
const content = (
|
|
6436
|
+
const content = format2(nextApiRouteTemplate({ config: config2, env }), {
|
|
6393
6437
|
parser: "babel"
|
|
6394
6438
|
});
|
|
6395
6439
|
await writeGeneratedFile({
|
|
@@ -6428,7 +6472,7 @@ var addContentFile = async ({
|
|
|
6428
6472
|
return () => ({
|
|
6429
6473
|
exists: env.sampleContentExists,
|
|
6430
6474
|
path: env.sampleContentPath,
|
|
6431
|
-
parentPath:
|
|
6475
|
+
parentPath: path14.dirname(env.sampleContentPath)
|
|
6432
6476
|
});
|
|
6433
6477
|
}
|
|
6434
6478
|
},
|
|
@@ -6451,10 +6495,10 @@ ${titleText(" TinaCMS ")} backend initialized!`));
|
|
|
6451
6495
|
return `${x.key}=${x.value || "***"}`;
|
|
6452
6496
|
}).join("\n") + `
|
|
6453
6497
|
TINA_PUBLIC_IS_LOCAL=true`;
|
|
6454
|
-
const envFile =
|
|
6455
|
-
if (!
|
|
6498
|
+
const envFile = path14.join(process.cwd(), ".env");
|
|
6499
|
+
if (!fs14.existsSync(envFile)) {
|
|
6456
6500
|
logger.info(`Adding .env file to your project... \u2705`);
|
|
6457
|
-
|
|
6501
|
+
fs14.writeFileSync(envFile, envFileText);
|
|
6458
6502
|
} else {
|
|
6459
6503
|
logger.info(
|
|
6460
6504
|
"Please add the following environment variables to your .env file"
|
|
@@ -6476,9 +6520,7 @@ ${titleText(" TinaCMS ")} has been initialized!`));
|
|
|
6476
6520
|
);
|
|
6477
6521
|
if (framework.name === "hugo") {
|
|
6478
6522
|
logger.info(
|
|
6479
|
-
focusText("Hugo is required. ")
|
|
6480
|
-
"Don't have Hugo installed? Follow this guide to set it up: ",
|
|
6481
|
-
linkText("https://gohugo.io/installation/")
|
|
6523
|
+
focusText("Hugo is required. ") + "Don't have Hugo installed? Follow this guide to set it up: " + linkText("https://gohugo.io/installation/")
|
|
6482
6524
|
);
|
|
6483
6525
|
}
|
|
6484
6526
|
logger.info(
|
|
@@ -6525,7 +6567,7 @@ var addReactiveFile = {
|
|
|
6525
6567
|
baseDir,
|
|
6526
6568
|
dataLayer
|
|
6527
6569
|
}) => {
|
|
6528
|
-
const packageJsonPath =
|
|
6570
|
+
const packageJsonPath = path14.join(baseDir, "package.json");
|
|
6529
6571
|
await writeGeneratedFile({
|
|
6530
6572
|
generatedFile,
|
|
6531
6573
|
typescript: config2.typescript,
|
|
@@ -6538,7 +6580,7 @@ var addReactiveFile = {
|
|
|
6538
6580
|
})
|
|
6539
6581
|
});
|
|
6540
6582
|
logger.info("Adding a nextjs example... \u2705");
|
|
6541
|
-
const packageJson = JSON.parse(
|
|
6583
|
+
const packageJson = JSON.parse(fs14.readFileSync(packageJsonPath).toString());
|
|
6542
6584
|
const scripts = packageJson.scripts || {};
|
|
6543
6585
|
const updatedPackageJson = JSON.stringify(
|
|
6544
6586
|
{
|
|
@@ -6551,11 +6593,10 @@ var addReactiveFile = {
|
|
|
6551
6593
|
null,
|
|
6552
6594
|
2
|
|
6553
6595
|
);
|
|
6554
|
-
|
|
6596
|
+
fs14.writeFileSync(packageJsonPath, updatedPackageJson);
|
|
6555
6597
|
}
|
|
6556
6598
|
};
|
|
6557
6599
|
function execShellCommand(cmd) {
|
|
6558
|
-
const exec = require("child_process").exec;
|
|
6559
6600
|
return new Promise((resolve2, reject) => {
|
|
6560
6601
|
exec(cmd, (error, stdout, stderr) => {
|
|
6561
6602
|
if (error) {
|
|
@@ -6601,34 +6642,27 @@ var command = new CLICommand({
|
|
|
6601
6642
|
});
|
|
6602
6643
|
|
|
6603
6644
|
// src/next/commands/init-command/index.ts
|
|
6604
|
-
var InitCommand = class extends
|
|
6605
|
-
|
|
6606
|
-
|
|
6607
|
-
|
|
6608
|
-
|
|
6609
|
-
|
|
6610
|
-
|
|
6611
|
-
|
|
6612
|
-
|
|
6613
|
-
|
|
6614
|
-
|
|
6615
|
-
|
|
6616
|
-
|
|
6617
|
-
|
|
6618
|
-
|
|
6619
|
-
|
|
6620
|
-
|
|
6621
|
-
|
|
6622
|
-
|
|
6623
|
-
|
|
6624
|
-
|
|
6625
|
-
}
|
|
6626
|
-
static {
|
|
6627
|
-
this.usage = import_clipanion6.Command.Usage({
|
|
6628
|
-
category: `Commands`,
|
|
6629
|
-
description: `Add Tina to an existing project`
|
|
6630
|
-
});
|
|
6631
|
-
}
|
|
6645
|
+
var InitCommand = class extends Command6 {
|
|
6646
|
+
static paths = [["init"], ["init", "backend"]];
|
|
6647
|
+
pathToForestryConfig = Option6.String("--forestryPath", {
|
|
6648
|
+
description: "Specify the relative path to the .forestry directory, if importing an existing forestry site."
|
|
6649
|
+
});
|
|
6650
|
+
rootPath = Option6.String("--rootPath", {
|
|
6651
|
+
description: "Specify the root directory to run the CLI from (defaults to current working directory)"
|
|
6652
|
+
});
|
|
6653
|
+
debug = Option6.Boolean("--debug", false, {
|
|
6654
|
+
description: "Enable debug logging"
|
|
6655
|
+
});
|
|
6656
|
+
noTelemetry = Option6.Boolean("--noTelemetry", false, {
|
|
6657
|
+
description: "Disable anonymous telemetry that is collected"
|
|
6658
|
+
});
|
|
6659
|
+
tinaVersion = Option6.String("--tinaVersion", {
|
|
6660
|
+
description: "Specify a version for tina dependencies"
|
|
6661
|
+
});
|
|
6662
|
+
static usage = Command6.Usage({
|
|
6663
|
+
category: `Commands`,
|
|
6664
|
+
description: `Add Tina to an existing project`
|
|
6665
|
+
});
|
|
6632
6666
|
async catch(error) {
|
|
6633
6667
|
logger.error("Error occured during tinacms init");
|
|
6634
6668
|
console.error(error);
|
|
@@ -6650,28 +6684,24 @@ var InitCommand = class extends import_clipanion6.Command {
|
|
|
6650
6684
|
};
|
|
6651
6685
|
|
|
6652
6686
|
// src/next/commands/searchindex-command/index.ts
|
|
6653
|
-
|
|
6654
|
-
|
|
6655
|
-
|
|
6656
|
-
|
|
6657
|
-
|
|
6658
|
-
|
|
6659
|
-
|
|
6660
|
-
|
|
6661
|
-
|
|
6662
|
-
|
|
6663
|
-
|
|
6664
|
-
|
|
6665
|
-
|
|
6666
|
-
|
|
6667
|
-
|
|
6668
|
-
|
|
6669
|
-
|
|
6670
|
-
|
|
6671
|
-
category: `Commands`,
|
|
6672
|
-
description: `Index the site for search`
|
|
6673
|
-
});
|
|
6674
|
-
}
|
|
6687
|
+
import { Command as Command7, Option as Option7 } from "clipanion";
|
|
6688
|
+
import { createSchema, FilesystemBridge as FilesystemBridge4 } from "@tinacms/graphql";
|
|
6689
|
+
import {
|
|
6690
|
+
SearchIndexer as SearchIndexer3,
|
|
6691
|
+
TinaCMSSearchIndexClient as TinaCMSSearchIndexClient2
|
|
6692
|
+
} from "@tinacms/search";
|
|
6693
|
+
var SearchIndexCommand = class extends Command7 {
|
|
6694
|
+
static paths = [["search-index"]];
|
|
6695
|
+
rootPath = Option7.String("--rootPath", {
|
|
6696
|
+
description: "Specify the root directory to run the CLI from (defaults to current working directory)"
|
|
6697
|
+
});
|
|
6698
|
+
verbose = Option7.Boolean("-v,--verbose", false, {
|
|
6699
|
+
description: "increase verbosity of logged output"
|
|
6700
|
+
});
|
|
6701
|
+
static usage = Command7.Usage({
|
|
6702
|
+
category: `Commands`,
|
|
6703
|
+
description: `Index the site for search`
|
|
6704
|
+
});
|
|
6675
6705
|
async catch(error) {
|
|
6676
6706
|
logger.error("Error occured during tinacms search-index");
|
|
6677
6707
|
console.error(error);
|
|
@@ -6693,7 +6723,7 @@ var SearchIndexCommand = class extends import_clipanion7.Command {
|
|
|
6693
6723
|
process.exit(1);
|
|
6694
6724
|
}
|
|
6695
6725
|
const { schema } = configManager.config;
|
|
6696
|
-
const tinaSchema = await
|
|
6726
|
+
const tinaSchema = await createSchema({
|
|
6697
6727
|
schema: { ...schema, config: configManager.config }
|
|
6698
6728
|
});
|
|
6699
6729
|
let client;
|
|
@@ -6721,7 +6751,7 @@ var SearchIndexCommand = class extends import_clipanion7.Command {
|
|
|
6721
6751
|
"indexerToken not configured in tina search configuration."
|
|
6722
6752
|
);
|
|
6723
6753
|
}
|
|
6724
|
-
client = new
|
|
6754
|
+
client = new TinaCMSSearchIndexClient2({
|
|
6725
6755
|
apiUrl: `${configManager.config.tinaioConfig?.contentApiUrlOverride || "https://content.tinajs.io"}/searchIndex/${configManager.config?.clientId}`,
|
|
6726
6756
|
branch: configManager.config?.branch,
|
|
6727
6757
|
indexerToken: configManager.config?.search?.tina?.indexerToken,
|
|
@@ -6730,9 +6760,9 @@ var SearchIndexCommand = class extends import_clipanion7.Command {
|
|
|
6730
6760
|
} else {
|
|
6731
6761
|
client = configManager.config?.search?.searchClient;
|
|
6732
6762
|
}
|
|
6733
|
-
const searchIndexer = new
|
|
6763
|
+
const searchIndexer = new SearchIndexer3({
|
|
6734
6764
|
batchSize: configManager.config.search?.indexBatchSize || 100,
|
|
6735
|
-
bridge: new
|
|
6765
|
+
bridge: new FilesystemBridge4(
|
|
6736
6766
|
configManager.rootPath,
|
|
6737
6767
|
configManager.contentRootPath
|
|
6738
6768
|
),
|
|
@@ -6760,7 +6790,7 @@ var SearchIndexCommand = class extends import_clipanion7.Command {
|
|
|
6760
6790
|
};
|
|
6761
6791
|
|
|
6762
6792
|
// src/index.ts
|
|
6763
|
-
var cli = new
|
|
6793
|
+
var cli = new Cli({
|
|
6764
6794
|
binaryName: `tinacms`,
|
|
6765
6795
|
binaryLabel: `TinaCMS`,
|
|
6766
6796
|
binaryVersion: version
|
|
@@ -6771,7 +6801,10 @@ cli.register(AuditCommand);
|
|
|
6771
6801
|
cli.register(InitCommand);
|
|
6772
6802
|
cli.register(CodemodCommand);
|
|
6773
6803
|
cli.register(SearchIndexCommand);
|
|
6774
|
-
cli.register(
|
|
6775
|
-
cli.register(
|
|
6776
|
-
cli.register(
|
|
6804
|
+
cli.register(Builtins.DefinitionsCommand);
|
|
6805
|
+
cli.register(Builtins.HelpCommand);
|
|
6806
|
+
cli.register(Builtins.VersionCommand);
|
|
6777
6807
|
var index_default = cli;
|
|
6808
|
+
export {
|
|
6809
|
+
index_default as default
|
|
6810
|
+
};
|