@tinacms/cli 0.0.0-e27c017-20250619233313 → 0.0.0-e48ff80-20251203000400
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/README.md +5 -5
- package/bin/tinacms +12 -6
- package/dist/cmds/init/prompts/index.d.ts +1 -1
- package/dist/cmds/init/prompts/types.d.ts +1 -1
- package/dist/index.js +918 -849
- package/dist/next/codegen/index.d.ts +3 -9
- package/dist/server/server.d.ts +1 -1
- package/dist/utils/path.d.ts +3 -0
- package/package.json +10 -9
package/dist/index.js
CHANGED
|
@@ -1,53 +1,27 @@
|
|
|
1
|
-
var
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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);
|
|
1
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
2
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
3
|
+
}) : x)(function(x) {
|
|
4
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
5
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
6
|
+
});
|
|
28
7
|
|
|
29
8
|
// 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");
|
|
9
|
+
import { Cli, Builtins } from "clipanion";
|
|
36
10
|
|
|
37
11
|
// package.json
|
|
38
|
-
var version = "
|
|
12
|
+
var version = "2.0.0";
|
|
39
13
|
|
|
40
14
|
// src/next/commands/dev-command/index.ts
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
15
|
+
import path8 from "path";
|
|
16
|
+
import { FilesystemBridge as FilesystemBridge2, buildSchema } from "@tinacms/graphql";
|
|
17
|
+
import { LocalSearchIndexClient, SearchIndexer } from "@tinacms/search";
|
|
18
|
+
import AsyncLock from "async-lock";
|
|
19
|
+
import chokidar from "chokidar";
|
|
20
|
+
import { Command as Command2, Option as Option2 } from "clipanion";
|
|
21
|
+
import fs7 from "fs-extra";
|
|
48
22
|
|
|
49
23
|
// src/logger/index.ts
|
|
50
|
-
|
|
24
|
+
import chalk from "chalk";
|
|
51
25
|
|
|
52
26
|
// src/logger/is-unicode-supported.ts
|
|
53
27
|
function isUnicodeSupported() {
|
|
@@ -61,9 +35,9 @@ function isUnicodeSupported() {
|
|
|
61
35
|
}
|
|
62
36
|
|
|
63
37
|
// src/logger/index.ts
|
|
64
|
-
|
|
65
|
-
var logger =
|
|
66
|
-
|
|
38
|
+
import log4js from "log4js";
|
|
39
|
+
var logger = log4js.getLogger();
|
|
40
|
+
log4js.configure({
|
|
67
41
|
appenders: {
|
|
68
42
|
out: { type: "stdout", layout: { type: "messagePassThrough" } }
|
|
69
43
|
},
|
|
@@ -88,18 +62,18 @@ ${message}
|
|
|
88
62
|
return ln.length > sum ? ln.length : sum;
|
|
89
63
|
}, 0) + 2;
|
|
90
64
|
const msg = lines.map(
|
|
91
|
-
(ln) => `${
|
|
65
|
+
(ln) => `${chalk.gray(bar)} ${chalk.white(ln)}${" ".repeat(
|
|
92
66
|
len - strip(ln).length
|
|
93
|
-
)}${
|
|
67
|
+
)}${chalk.gray(bar)}`
|
|
94
68
|
).join("\n");
|
|
95
69
|
const underscoreLen = len - title.length - 1 > 0 ? len - title.length - 1 : 0;
|
|
96
70
|
process.stdout.write(
|
|
97
|
-
`${
|
|
98
|
-
${
|
|
71
|
+
`${chalk.gray(bar)}
|
|
72
|
+
${chalk.green("\u25CB")} ${chalk.reset(
|
|
99
73
|
title
|
|
100
|
-
)} ${
|
|
74
|
+
)} ${chalk.gray("\u2500".repeat(underscoreLen) + "\u256E")}
|
|
101
75
|
${msg}
|
|
102
|
-
${
|
|
76
|
+
${chalk.gray(
|
|
103
77
|
"\u251C" + "\u2500".repeat(len + 2) + "\u256F"
|
|
104
78
|
)}
|
|
105
79
|
`
|
|
@@ -116,11 +90,11 @@ var summary = (content) => {
|
|
|
116
90
|
});
|
|
117
91
|
});
|
|
118
92
|
content.items.forEach((item) => {
|
|
119
|
-
outString.push(`${item.emoji} ${
|
|
93
|
+
outString.push(`${item.emoji} ${chalk.cyan(item.heading)}`);
|
|
120
94
|
item.subItems.forEach((subItem) => {
|
|
121
95
|
const spaces = longestKey - subItem.key.length + 4;
|
|
122
96
|
outString.push(
|
|
123
|
-
` ${subItem.key}:${[...Array(spaces)].join(" ")}${
|
|
97
|
+
` ${subItem.key}:${[...Array(spaces)].join(" ")}${chalk.cyan(
|
|
124
98
|
subItem.value
|
|
125
99
|
)}`
|
|
126
100
|
);
|
|
@@ -158,12 +132,12 @@ var S_WARN = s("\u25B2", "!");
|
|
|
158
132
|
var S_ERROR = s("\u25A0", "x");
|
|
159
133
|
|
|
160
134
|
// src/utils/spinner.ts
|
|
161
|
-
|
|
135
|
+
import { Spinner } from "cli-spinner";
|
|
162
136
|
async function localSpin({
|
|
163
137
|
waitFor,
|
|
164
138
|
text
|
|
165
139
|
}) {
|
|
166
|
-
const spinner = new
|
|
140
|
+
const spinner = new Spinner({
|
|
167
141
|
text: `${text} %s`,
|
|
168
142
|
stream: process.stderr,
|
|
169
143
|
onTick: function(msg) {
|
|
@@ -194,32 +168,32 @@ function spin({
|
|
|
194
168
|
}
|
|
195
169
|
|
|
196
170
|
// 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 =
|
|
171
|
+
import chalk2 from "chalk";
|
|
172
|
+
var successText = chalk2.bold.green;
|
|
173
|
+
var focusText = chalk2.bold;
|
|
174
|
+
var dangerText = chalk2.bold.red;
|
|
175
|
+
var neutralText = chalk2.bold.cyan;
|
|
176
|
+
var linkText = chalk2.bold.cyan;
|
|
177
|
+
var labelText = chalk2.bold;
|
|
178
|
+
var cmdText = chalk2.inverse;
|
|
205
179
|
var indentedCmd = (str) => {
|
|
206
180
|
return ` \u2503 ` + str;
|
|
207
181
|
};
|
|
208
182
|
var indentText = (str) => {
|
|
209
183
|
return String(str).split("\n").map((line) => ` ${line}`).join("\n");
|
|
210
184
|
};
|
|
211
|
-
var logText =
|
|
212
|
-
var warnText =
|
|
213
|
-
var titleText =
|
|
214
|
-
var CONFIRMATION_TEXT =
|
|
185
|
+
var logText = chalk2.italic.gray;
|
|
186
|
+
var warnText = chalk2.yellowBright.bgBlack;
|
|
187
|
+
var titleText = chalk2.bgHex("d2f1f8").hex("ec4816");
|
|
188
|
+
var CONFIRMATION_TEXT = chalk2.dim("enter to confirm");
|
|
215
189
|
|
|
216
190
|
// src/next/codegen/index.ts
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
191
|
+
import fs from "fs-extra";
|
|
192
|
+
import path from "path";
|
|
193
|
+
import { buildASTSchema, printSchema as printSchema2 } from "graphql";
|
|
220
194
|
|
|
221
195
|
// src/next/codegen/codegen/index.ts
|
|
222
|
-
|
|
196
|
+
import { parse, printSchema } from "graphql";
|
|
223
197
|
|
|
224
198
|
// src/next/codegen/codegen/plugin.ts
|
|
225
199
|
var AddGeneratedClientFunc = (apiURL) => {
|
|
@@ -288,37 +262,44 @@ var AddGeneratedClient = (apiURL) => ({
|
|
|
288
262
|
});
|
|
289
263
|
|
|
290
264
|
// src/next/codegen/codegen/index.ts
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
265
|
+
import { GraphQLFileLoader } from "@graphql-tools/graphql-file-loader";
|
|
266
|
+
import { codegen } from "@graphql-codegen/core";
|
|
267
|
+
import { loadDocuments } from "@graphql-tools/load";
|
|
268
|
+
import { plugin as typescriptOperationsPlugin } from "@graphql-codegen/typescript-operations";
|
|
269
|
+
import { plugin as typescriptPlugin } from "@graphql-codegen/typescript";
|
|
296
270
|
|
|
297
271
|
// src/next/codegen/codegen/sdkPlugin/index.ts
|
|
298
|
-
|
|
299
|
-
|
|
272
|
+
import { visit } from "graphql";
|
|
273
|
+
import {
|
|
274
|
+
concatAST,
|
|
275
|
+
Kind as Kind2
|
|
276
|
+
} from "graphql";
|
|
300
277
|
|
|
301
278
|
// src/next/codegen/codegen/sdkPlugin/visitor.ts
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
279
|
+
import {
|
|
280
|
+
ClientSideBaseVisitor,
|
|
281
|
+
DocumentMode,
|
|
282
|
+
indentMultiline
|
|
283
|
+
} from "@graphql-codegen/visitor-plugin-common";
|
|
284
|
+
import autoBind from "auto-bind";
|
|
285
|
+
import { Kind, print } from "graphql";
|
|
286
|
+
var GenericSdkVisitor = class extends ClientSideBaseVisitor {
|
|
287
|
+
_operationsToInclude = [];
|
|
306
288
|
constructor(schema, fragments, rawConfig) {
|
|
307
289
|
super(schema, fragments, rawConfig, {
|
|
308
290
|
usingObservableFrom: rawConfig.usingObservableFrom
|
|
309
291
|
});
|
|
310
|
-
this
|
|
311
|
-
(0, import_auto_bind.default)(this);
|
|
292
|
+
autoBind(this);
|
|
312
293
|
if (this.config.usingObservableFrom) {
|
|
313
294
|
this._additionalImports.push(this.config.usingObservableFrom);
|
|
314
295
|
}
|
|
315
|
-
if (this.config.documentMode !==
|
|
296
|
+
if (this.config.documentMode !== DocumentMode.string) {
|
|
316
297
|
}
|
|
317
298
|
}
|
|
318
299
|
buildOperation(node, documentVariableName, operationType, operationResultType, operationVariablesTypes) {
|
|
319
300
|
if (node.name == null) {
|
|
320
301
|
throw new Error(
|
|
321
|
-
"Plugin 'generic-sdk' cannot generate SDK for unnamed operation.\n\n" +
|
|
302
|
+
"Plugin 'generic-sdk' cannot generate SDK for unnamed operation.\n\n" + print(node)
|
|
322
303
|
);
|
|
323
304
|
} else {
|
|
324
305
|
this._operationsToInclude.push({
|
|
@@ -336,14 +317,14 @@ var GenericSdkVisitor = class extends import_visitor_plugin_common.ClientSideBas
|
|
|
336
317
|
const usingObservable = !!this.config.usingObservableFrom;
|
|
337
318
|
const allPossibleActions = this._operationsToInclude.map((o) => {
|
|
338
319
|
const optionalVariables = !o.node.variableDefinitions || o.node.variableDefinitions.length === 0 || o.node.variableDefinitions.every(
|
|
339
|
-
(v) => v.type.kind !==
|
|
320
|
+
(v) => v.type.kind !== Kind.NON_NULL_TYPE || v.defaultValue
|
|
340
321
|
);
|
|
341
322
|
const returnType = usingObservable && o.operationType === "Subscription" ? "Observable" : "Promise";
|
|
342
323
|
return `${o.node.name.value}(variables${optionalVariables ? "?" : ""}: ${o.operationVariablesTypes}, options?: C): ${returnType}<${o.operationResultType}> {
|
|
343
324
|
return requester<${o.operationResultType}, ${o.operationVariablesTypes}>(${o.documentVariableName}, variables, options);
|
|
344
325
|
}`;
|
|
345
|
-
}).map((s2) =>
|
|
346
|
-
return `export type Requester<C= {}> = <R, V>(doc: ${this.config.documentMode ===
|
|
326
|
+
}).map((s2) => indentMultiline(s2, 2));
|
|
327
|
+
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
328
|
export function getSdk<C>(requester: Requester<C>) {
|
|
348
329
|
return {
|
|
349
330
|
${allPossibleActions.join(",\n")}
|
|
@@ -355,14 +336,14 @@ var GenericSdkVisitor = class extends import_visitor_plugin_common.ClientSideBas
|
|
|
355
336
|
|
|
356
337
|
// src/next/codegen/codegen/sdkPlugin/index.ts
|
|
357
338
|
var plugin = (schema, documents, config2) => {
|
|
358
|
-
const allAst =
|
|
339
|
+
const allAst = concatAST(
|
|
359
340
|
documents.reduce((prev, v) => {
|
|
360
341
|
return [...prev, v.document];
|
|
361
342
|
}, [])
|
|
362
343
|
);
|
|
363
344
|
const allFragments = [
|
|
364
345
|
...allAst.definitions.filter(
|
|
365
|
-
(d) => d.kind ===
|
|
346
|
+
(d) => d.kind === Kind2.FRAGMENT_DEFINITION
|
|
366
347
|
).map((fragmentDef) => ({
|
|
367
348
|
node: fragmentDef,
|
|
368
349
|
name: fragmentDef.name.value,
|
|
@@ -372,7 +353,7 @@ var plugin = (schema, documents, config2) => {
|
|
|
372
353
|
...config2.externalFragments || []
|
|
373
354
|
];
|
|
374
355
|
const visitor = new GenericSdkVisitor(schema, allFragments, config2);
|
|
375
|
-
const visitorResult =
|
|
356
|
+
const visitorResult = visit(allAst, { leave: visitor });
|
|
376
357
|
return {
|
|
377
358
|
// We will take care of imports
|
|
378
359
|
// prepend: visitor.getImports(),
|
|
@@ -390,10 +371,10 @@ var generateTypes = async (schema, queryPathGlob = process.cwd(), fragDocPath =
|
|
|
390
371
|
let fragDocs = [];
|
|
391
372
|
docs = await loadGraphQLDocuments(queryPathGlob);
|
|
392
373
|
fragDocs = await loadGraphQLDocuments(fragDocPath);
|
|
393
|
-
const res = await
|
|
374
|
+
const res = await codegen({
|
|
394
375
|
// Filename is not used. This is because the typescript plugin returns a string instead of writing to a file.
|
|
395
376
|
filename: process.cwd(),
|
|
396
|
-
schema:
|
|
377
|
+
schema: parse(printSchema(schema)),
|
|
397
378
|
documents: [...docs, ...fragDocs],
|
|
398
379
|
config: {},
|
|
399
380
|
plugins: [
|
|
@@ -406,10 +387,10 @@ var generateTypes = async (schema, queryPathGlob = process.cwd(), fragDocPath =
|
|
|
406
387
|
],
|
|
407
388
|
pluginMap: {
|
|
408
389
|
typescript: {
|
|
409
|
-
plugin:
|
|
390
|
+
plugin: typescriptPlugin
|
|
410
391
|
},
|
|
411
392
|
typescriptOperations: {
|
|
412
|
-
plugin:
|
|
393
|
+
plugin: typescriptOperationsPlugin
|
|
413
394
|
},
|
|
414
395
|
typescriptSdk: {
|
|
415
396
|
plugin
|
|
@@ -422,8 +403,8 @@ var generateTypes = async (schema, queryPathGlob = process.cwd(), fragDocPath =
|
|
|
422
403
|
var loadGraphQLDocuments = async (globPath) => {
|
|
423
404
|
let result = [];
|
|
424
405
|
try {
|
|
425
|
-
result = await
|
|
426
|
-
loaders: [new
|
|
406
|
+
result = await loadDocuments(globPath, {
|
|
407
|
+
loaders: [new GraphQLFileLoader()]
|
|
427
408
|
});
|
|
428
409
|
} catch (e) {
|
|
429
410
|
if (
|
|
@@ -440,11 +421,27 @@ var loadGraphQLDocuments = async (globPath) => {
|
|
|
440
421
|
};
|
|
441
422
|
|
|
442
423
|
// src/next/codegen/index.ts
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
424
|
+
import { transform } from "esbuild";
|
|
425
|
+
import { mapUserFields } from "@tinacms/graphql";
|
|
426
|
+
import normalizePath from "normalize-path";
|
|
446
427
|
var TINA_HOST = "content.tinajs.io";
|
|
447
428
|
var Codegen = class {
|
|
429
|
+
configManager;
|
|
430
|
+
port;
|
|
431
|
+
schema;
|
|
432
|
+
queryDoc;
|
|
433
|
+
fragDoc;
|
|
434
|
+
isLocal;
|
|
435
|
+
// The API url used in the client
|
|
436
|
+
apiURL;
|
|
437
|
+
// This is always the local URL.
|
|
438
|
+
localUrl;
|
|
439
|
+
// production url
|
|
440
|
+
productionUrl;
|
|
441
|
+
graphqlSchemaDoc;
|
|
442
|
+
tinaSchema;
|
|
443
|
+
lookup;
|
|
444
|
+
noClientBuildCache;
|
|
448
445
|
constructor({
|
|
449
446
|
configManager,
|
|
450
447
|
port,
|
|
@@ -460,7 +457,7 @@ var Codegen = class {
|
|
|
460
457
|
this.graphqlSchemaDoc = graphqlSchemaDoc;
|
|
461
458
|
this.configManager = configManager;
|
|
462
459
|
this.port = port;
|
|
463
|
-
this.schema =
|
|
460
|
+
this.schema = buildASTSchema(graphqlSchemaDoc);
|
|
464
461
|
this.tinaSchema = tinaSchema;
|
|
465
462
|
this.queryDoc = queryDoc;
|
|
466
463
|
this.fragDoc = fragDoc;
|
|
@@ -468,19 +465,19 @@ var Codegen = class {
|
|
|
468
465
|
this.noClientBuildCache = noClientBuildCache;
|
|
469
466
|
}
|
|
470
467
|
async writeConfigFile(fileName, data) {
|
|
471
|
-
const filePath =
|
|
468
|
+
const filePath = path.join(
|
|
472
469
|
this.configManager.generatedFolderPath,
|
|
473
470
|
fileName
|
|
474
471
|
);
|
|
475
|
-
await
|
|
476
|
-
await
|
|
472
|
+
await fs.ensureFile(filePath);
|
|
473
|
+
await fs.outputFile(filePath, data);
|
|
477
474
|
if (this.configManager.hasSeparateContentRoot()) {
|
|
478
|
-
const filePath2 =
|
|
475
|
+
const filePath2 = path.join(
|
|
479
476
|
this.configManager.generatedFolderPathContentRepo,
|
|
480
477
|
fileName
|
|
481
478
|
);
|
|
482
|
-
await
|
|
483
|
-
await
|
|
479
|
+
await fs.ensureFile(filePath2);
|
|
480
|
+
await fs.outputFile(filePath2, data);
|
|
484
481
|
}
|
|
485
482
|
}
|
|
486
483
|
async removeGeneratedFilesIfExists() {
|
|
@@ -512,11 +509,11 @@ var Codegen = class {
|
|
|
512
509
|
await this.removeGeneratedFilesIfExists();
|
|
513
510
|
return apiURL;
|
|
514
511
|
}
|
|
515
|
-
await
|
|
512
|
+
await fs.outputFile(
|
|
516
513
|
this.configManager.generatedQueriesFilePath,
|
|
517
514
|
this.queryDoc
|
|
518
515
|
);
|
|
519
|
-
await
|
|
516
|
+
await fs.outputFile(
|
|
520
517
|
this.configManager.generatedFragmentsFilePath,
|
|
521
518
|
this.fragDoc
|
|
522
519
|
);
|
|
@@ -524,21 +521,21 @@ var Codegen = class {
|
|
|
524
521
|
const { clientString } = await this.genClient();
|
|
525
522
|
const databaseClientString = this.configManager.hasSelfHostedConfig() ? await this.genDatabaseClient() : "";
|
|
526
523
|
const { codeString, schemaString } = await this.genTypes();
|
|
527
|
-
await
|
|
524
|
+
await fs.outputFile(
|
|
528
525
|
this.configManager.generatedGraphQLGQLPath,
|
|
529
526
|
schemaString
|
|
530
527
|
);
|
|
531
528
|
if (this.configManager.isUsingTs()) {
|
|
532
|
-
await
|
|
529
|
+
await fs.outputFile(
|
|
533
530
|
this.configManager.generatedTypesTSFilePath,
|
|
534
531
|
codeString
|
|
535
532
|
);
|
|
536
|
-
await
|
|
533
|
+
await fs.outputFile(
|
|
537
534
|
this.configManager.generatedClientTSFilePath,
|
|
538
535
|
clientString
|
|
539
536
|
);
|
|
540
537
|
if (this.configManager.hasSelfHostedConfig()) {
|
|
541
|
-
await
|
|
538
|
+
await fs.outputFile(
|
|
542
539
|
this.configManager.generatedDatabaseClientTSFilePath,
|
|
543
540
|
databaseClientString
|
|
544
541
|
);
|
|
@@ -547,35 +544,35 @@ var Codegen = class {
|
|
|
547
544
|
await unlinkIfExists(this.configManager.generatedTypesDFilePath);
|
|
548
545
|
await unlinkIfExists(this.configManager.generatedTypesJSFilePath);
|
|
549
546
|
} else {
|
|
550
|
-
await
|
|
547
|
+
await fs.outputFile(
|
|
551
548
|
this.configManager.generatedTypesDFilePath,
|
|
552
549
|
codeString
|
|
553
550
|
);
|
|
554
|
-
const jsTypes = await
|
|
555
|
-
await
|
|
551
|
+
const jsTypes = await transform(codeString, { loader: "ts" });
|
|
552
|
+
await fs.outputFile(
|
|
556
553
|
this.configManager.generatedTypesJSFilePath,
|
|
557
554
|
jsTypes.code
|
|
558
555
|
);
|
|
559
|
-
await
|
|
556
|
+
await fs.outputFile(
|
|
560
557
|
this.configManager.generatedClientDFilePath,
|
|
561
558
|
clientString
|
|
562
559
|
);
|
|
563
|
-
const jsClient = await
|
|
564
|
-
await
|
|
560
|
+
const jsClient = await transform(clientString, { loader: "ts" });
|
|
561
|
+
await fs.outputFile(
|
|
565
562
|
this.configManager.generatedClientJSFilePath,
|
|
566
563
|
jsClient.code
|
|
567
564
|
);
|
|
568
565
|
await unlinkIfExists(this.configManager.generatedTypesTSFilePath);
|
|
569
566
|
await unlinkIfExists(this.configManager.generatedClientTSFilePath);
|
|
570
567
|
if (this.configManager.hasSelfHostedConfig()) {
|
|
571
|
-
const jsDatabaseClient = await
|
|
568
|
+
const jsDatabaseClient = await transform(databaseClientString, {
|
|
572
569
|
loader: "ts"
|
|
573
570
|
});
|
|
574
|
-
await
|
|
571
|
+
await fs.outputFile(
|
|
575
572
|
this.configManager.generatedDatabaseClientJSFilePath,
|
|
576
573
|
jsDatabaseClient.code
|
|
577
574
|
);
|
|
578
|
-
await
|
|
575
|
+
await fs.outputFile(
|
|
579
576
|
this.configManager.generatedDatabaseClientDFilePath,
|
|
580
577
|
databaseClientString
|
|
581
578
|
);
|
|
@@ -601,7 +598,7 @@ var Codegen = class {
|
|
|
601
598
|
throw new Error(
|
|
602
599
|
`Client not configured properly. Missing ${missing.join(
|
|
603
600
|
", "
|
|
604
|
-
)}. Please visit https://tina.io/docs/
|
|
601
|
+
)}. Please visit https://tina.io/docs/r/what-is-tinacloud for more information`
|
|
605
602
|
);
|
|
606
603
|
}
|
|
607
604
|
let localUrl = `http://localhost:${this.port}/graphql`;
|
|
@@ -623,7 +620,7 @@ var Codegen = class {
|
|
|
623
620
|
const authCollection = this.tinaSchema.getCollections().find((c) => c.isAuthCollection);
|
|
624
621
|
let authFields = [];
|
|
625
622
|
if (authCollection) {
|
|
626
|
-
const usersFields =
|
|
623
|
+
const usersFields = mapUserFields(authCollection, []);
|
|
627
624
|
if (usersFields.length === 0) {
|
|
628
625
|
throw new Error("No user field found");
|
|
629
626
|
}
|
|
@@ -713,7 +710,7 @@ export default databaseClient;
|
|
|
713
710
|
const apiURL = this.getApiURL();
|
|
714
711
|
const clientString = `import { createClient } from "tinacms/dist/client";
|
|
715
712
|
import { queries } from "./types";
|
|
716
|
-
export const client = createClient({ ${this.noClientBuildCache === false ? `cacheDir: '${(
|
|
713
|
+
export const client = createClient({ ${this.noClientBuildCache === false ? `cacheDir: '${normalizePath(
|
|
717
714
|
this.configManager.generatedCachePath
|
|
718
715
|
)}', ` : ""}url: '${apiURL}', token: '${token}', queries, ${errorPolicy ? `errorPolicy: '${errorPolicy}'` : ""} });
|
|
719
716
|
export default client;
|
|
@@ -739,7 +736,7 @@ export default client;
|
|
|
739
736
|
${typescriptTypes}
|
|
740
737
|
`;
|
|
741
738
|
const schemaString = `# DO NOT MODIFY THIS FILE. This file is automatically generated by Tina
|
|
742
|
-
${(
|
|
739
|
+
${printSchema2(this.schema)}
|
|
743
740
|
schema {
|
|
744
741
|
query: Query
|
|
745
742
|
mutation: Mutation
|
|
@@ -751,7 +748,7 @@ schema {
|
|
|
751
748
|
var maybeWarnFragmentSize = async (filepath) => {
|
|
752
749
|
if (
|
|
753
750
|
// is the file bigger than 100kb?
|
|
754
|
-
(await
|
|
751
|
+
(await fs.stat(filepath)).size > // convert to 100 kb to bytes
|
|
755
752
|
100 * 1024
|
|
756
753
|
) {
|
|
757
754
|
console.warn(
|
|
@@ -768,19 +765,34 @@ var maybeWarnFragmentSize = async (filepath) => {
|
|
|
768
765
|
}
|
|
769
766
|
};
|
|
770
767
|
var unlinkIfExists = async (filepath) => {
|
|
771
|
-
if (
|
|
772
|
-
|
|
768
|
+
if (fs.existsSync(filepath)) {
|
|
769
|
+
fs.unlinkSync(filepath);
|
|
773
770
|
}
|
|
774
771
|
};
|
|
775
772
|
|
|
776
773
|
// src/next/config-manager.ts
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
774
|
+
import fs2 from "fs-extra";
|
|
775
|
+
import path3 from "path";
|
|
776
|
+
import os from "os";
|
|
777
|
+
import { pathToFileURL } from "url";
|
|
778
|
+
import * as esbuild from "esbuild";
|
|
779
|
+
import * as dotenv from "dotenv";
|
|
780
|
+
import normalizePath2 from "normalize-path";
|
|
781
|
+
import chalk3 from "chalk";
|
|
782
|
+
import { createRequire } from "module";
|
|
783
|
+
|
|
784
|
+
// src/utils/path.ts
|
|
785
|
+
import path2 from "path";
|
|
786
|
+
function stripNativeTrailingSlash(p) {
|
|
787
|
+
const { root } = path2.parse(p);
|
|
788
|
+
let str = p;
|
|
789
|
+
while (str.length > root.length && str.endsWith(path2.sep)) {
|
|
790
|
+
str = str.slice(0, -1);
|
|
791
|
+
}
|
|
792
|
+
return str;
|
|
793
|
+
}
|
|
794
|
+
|
|
795
|
+
// src/next/config-manager.ts
|
|
784
796
|
var TINA_FOLDER = "tina";
|
|
785
797
|
var LEGACY_TINA_FOLDER = ".tina";
|
|
786
798
|
var GENERATED_FOLDER = "__generated__";
|
|
@@ -789,17 +801,57 @@ var GRAPHQL_GQL_FILE = "schema.gql";
|
|
|
789
801
|
var SCHEMA_JSON_FILE = "_schema.json";
|
|
790
802
|
var LOOKUP_JSON_FILE = "_lookup.json";
|
|
791
803
|
var ConfigManager = class {
|
|
804
|
+
config;
|
|
805
|
+
rootPath;
|
|
806
|
+
tinaFolderPath;
|
|
807
|
+
isUsingLegacyFolder;
|
|
808
|
+
tinaConfigFilePath;
|
|
809
|
+
tinaSpaPackagePath;
|
|
810
|
+
contentRootPath;
|
|
811
|
+
envFilePath;
|
|
812
|
+
generatedCachePath;
|
|
813
|
+
generatedFolderPath;
|
|
814
|
+
generatedFolderPathContentRepo;
|
|
815
|
+
generatedGraphQLGQLPath;
|
|
816
|
+
generatedGraphQLJSONPath;
|
|
817
|
+
generatedSchemaJSONPath;
|
|
818
|
+
generatedLookupJSONPath;
|
|
819
|
+
generatedTypesTSFilePath;
|
|
820
|
+
generatedTypesJSFilePath;
|
|
821
|
+
generatedTypesDFilePath;
|
|
822
|
+
generatedClientTSFilePath;
|
|
823
|
+
generatedClientJSFilePath;
|
|
824
|
+
generatedClientDFilePath;
|
|
825
|
+
generatedDatabaseClientJSFilePath;
|
|
826
|
+
generatedDatabaseClientTSFilePath;
|
|
827
|
+
generatedDatabaseClientDFilePath;
|
|
828
|
+
generatedQueriesFilePath;
|
|
829
|
+
generatedFragmentsFilePath;
|
|
830
|
+
generatedQueriesAndFragmentsGlob;
|
|
831
|
+
userQueriesAndFragmentsGlob;
|
|
832
|
+
publicFolderPath;
|
|
833
|
+
outputFolderPath;
|
|
834
|
+
outputHTMLFilePath;
|
|
835
|
+
outputGitignorePath;
|
|
836
|
+
selfHostedDatabaseFilePath;
|
|
837
|
+
prebuildFilePath;
|
|
838
|
+
spaRootPath;
|
|
839
|
+
spaMainPath;
|
|
840
|
+
spaHTMLPath;
|
|
841
|
+
tinaGraphQLVersionFromCLI;
|
|
842
|
+
legacyNoSDK;
|
|
843
|
+
watchList;
|
|
792
844
|
constructor({
|
|
793
845
|
rootPath = process.cwd(),
|
|
794
846
|
tinaGraphQLVersion,
|
|
795
847
|
legacyNoSDK
|
|
796
848
|
}) {
|
|
797
|
-
this.rootPath = (
|
|
849
|
+
this.rootPath = normalizePath2(rootPath);
|
|
798
850
|
this.tinaGraphQLVersionFromCLI = tinaGraphQLVersion;
|
|
799
851
|
this.legacyNoSDK = legacyNoSDK;
|
|
800
852
|
}
|
|
801
853
|
isUsingTs() {
|
|
802
|
-
return [".ts", ".tsx"].includes(
|
|
854
|
+
return [".ts", ".tsx"].includes(path3.extname(this.tinaConfigFilePath));
|
|
803
855
|
}
|
|
804
856
|
hasSelfHostedConfig() {
|
|
805
857
|
return !!this.selfHostedDatabaseFilePath;
|
|
@@ -814,13 +866,14 @@ var ConfigManager = class {
|
|
|
814
866
|
return this.config.client?.skip || false;
|
|
815
867
|
}
|
|
816
868
|
async processConfig() {
|
|
869
|
+
const require2 = createRequire(import.meta.url);
|
|
817
870
|
this.tinaFolderPath = await this.getTinaFolderPath(this.rootPath);
|
|
818
|
-
this.envFilePath =
|
|
819
|
-
|
|
871
|
+
this.envFilePath = path3.resolve(
|
|
872
|
+
path3.join(this.tinaFolderPath, "..", ".env")
|
|
820
873
|
);
|
|
821
874
|
dotenv.config({ path: this.envFilePath });
|
|
822
875
|
this.tinaConfigFilePath = await this.getPathWithExtension(
|
|
823
|
-
|
|
876
|
+
path3.join(this.tinaFolderPath, "config")
|
|
824
877
|
);
|
|
825
878
|
if (!this.tinaConfigFilePath) {
|
|
826
879
|
throw new Error(
|
|
@@ -828,89 +881,89 @@ var ConfigManager = class {
|
|
|
828
881
|
);
|
|
829
882
|
}
|
|
830
883
|
this.selfHostedDatabaseFilePath = await this.getPathWithExtension(
|
|
831
|
-
|
|
884
|
+
path3.join(this.tinaFolderPath, "database")
|
|
832
885
|
);
|
|
833
|
-
this.generatedFolderPath =
|
|
834
|
-
this.generatedCachePath =
|
|
886
|
+
this.generatedFolderPath = path3.join(this.tinaFolderPath, GENERATED_FOLDER);
|
|
887
|
+
this.generatedCachePath = path3.join(
|
|
835
888
|
this.generatedFolderPath,
|
|
836
889
|
".cache",
|
|
837
890
|
String((/* @__PURE__ */ new Date()).getTime())
|
|
838
891
|
);
|
|
839
|
-
this.generatedGraphQLGQLPath =
|
|
892
|
+
this.generatedGraphQLGQLPath = path3.join(
|
|
840
893
|
this.generatedFolderPath,
|
|
841
894
|
GRAPHQL_GQL_FILE
|
|
842
895
|
);
|
|
843
|
-
this.generatedGraphQLJSONPath =
|
|
896
|
+
this.generatedGraphQLJSONPath = path3.join(
|
|
844
897
|
this.generatedFolderPath,
|
|
845
898
|
GRAPHQL_JSON_FILE
|
|
846
899
|
);
|
|
847
|
-
this.generatedSchemaJSONPath =
|
|
900
|
+
this.generatedSchemaJSONPath = path3.join(
|
|
848
901
|
this.generatedFolderPath,
|
|
849
902
|
SCHEMA_JSON_FILE
|
|
850
903
|
);
|
|
851
|
-
this.generatedLookupJSONPath =
|
|
904
|
+
this.generatedLookupJSONPath = path3.join(
|
|
852
905
|
this.generatedFolderPath,
|
|
853
906
|
LOOKUP_JSON_FILE
|
|
854
907
|
);
|
|
855
|
-
this.generatedQueriesFilePath =
|
|
908
|
+
this.generatedQueriesFilePath = path3.join(
|
|
856
909
|
this.generatedFolderPath,
|
|
857
910
|
"queries.gql"
|
|
858
911
|
);
|
|
859
|
-
this.generatedFragmentsFilePath =
|
|
912
|
+
this.generatedFragmentsFilePath = path3.join(
|
|
860
913
|
this.generatedFolderPath,
|
|
861
914
|
"frags.gql"
|
|
862
915
|
);
|
|
863
|
-
this.generatedTypesTSFilePath =
|
|
916
|
+
this.generatedTypesTSFilePath = path3.join(
|
|
864
917
|
this.generatedFolderPath,
|
|
865
918
|
"types.ts"
|
|
866
919
|
);
|
|
867
|
-
this.generatedTypesJSFilePath =
|
|
920
|
+
this.generatedTypesJSFilePath = path3.join(
|
|
868
921
|
this.generatedFolderPath,
|
|
869
922
|
"types.js"
|
|
870
923
|
);
|
|
871
|
-
this.generatedTypesDFilePath =
|
|
924
|
+
this.generatedTypesDFilePath = path3.join(
|
|
872
925
|
this.generatedFolderPath,
|
|
873
926
|
"types.d.ts"
|
|
874
927
|
);
|
|
875
|
-
this.userQueriesAndFragmentsGlob =
|
|
928
|
+
this.userQueriesAndFragmentsGlob = path3.join(
|
|
876
929
|
this.tinaFolderPath,
|
|
877
930
|
"queries/**/*.{graphql,gql}"
|
|
878
931
|
);
|
|
879
|
-
this.generatedQueriesAndFragmentsGlob =
|
|
932
|
+
this.generatedQueriesAndFragmentsGlob = path3.join(
|
|
880
933
|
this.generatedFolderPath,
|
|
881
934
|
"*.{graphql,gql}"
|
|
882
935
|
);
|
|
883
|
-
this.generatedClientTSFilePath =
|
|
936
|
+
this.generatedClientTSFilePath = path3.join(
|
|
884
937
|
this.generatedFolderPath,
|
|
885
938
|
"client.ts"
|
|
886
939
|
);
|
|
887
|
-
this.generatedClientJSFilePath =
|
|
940
|
+
this.generatedClientJSFilePath = path3.join(
|
|
888
941
|
this.generatedFolderPath,
|
|
889
942
|
"client.js"
|
|
890
943
|
);
|
|
891
|
-
this.generatedClientDFilePath =
|
|
944
|
+
this.generatedClientDFilePath = path3.join(
|
|
892
945
|
this.generatedFolderPath,
|
|
893
946
|
"client.d.ts"
|
|
894
947
|
);
|
|
895
|
-
this.generatedDatabaseClientDFilePath =
|
|
948
|
+
this.generatedDatabaseClientDFilePath = path3.join(
|
|
896
949
|
this.generatedFolderPath,
|
|
897
950
|
"databaseClient.d.ts"
|
|
898
951
|
);
|
|
899
|
-
this.generatedDatabaseClientTSFilePath =
|
|
952
|
+
this.generatedDatabaseClientTSFilePath = path3.join(
|
|
900
953
|
this.generatedFolderPath,
|
|
901
954
|
"databaseClient.ts"
|
|
902
955
|
);
|
|
903
|
-
this.generatedDatabaseClientJSFilePath =
|
|
956
|
+
this.generatedDatabaseClientJSFilePath = path3.join(
|
|
904
957
|
this.generatedFolderPath,
|
|
905
958
|
"databaseClient.js"
|
|
906
959
|
);
|
|
907
|
-
const clientExists = this.isUsingTs() ? await
|
|
960
|
+
const clientExists = this.isUsingTs() ? await fs2.pathExists(this.generatedClientTSFilePath) : await fs2.pathExists(this.generatedClientJSFilePath);
|
|
908
961
|
if (!clientExists) {
|
|
909
962
|
const file = "export default ()=>({})\nexport const client = ()=>({})";
|
|
910
963
|
if (this.isUsingTs()) {
|
|
911
|
-
await
|
|
964
|
+
await fs2.outputFile(this.generatedClientTSFilePath, file);
|
|
912
965
|
} else {
|
|
913
|
-
await
|
|
966
|
+
await fs2.outputFile(this.generatedClientJSFilePath, file);
|
|
914
967
|
}
|
|
915
968
|
}
|
|
916
969
|
const { config: config2, prebuildPath, watchList } = await this.loadConfigFile(
|
|
@@ -920,30 +973,29 @@ var ConfigManager = class {
|
|
|
920
973
|
this.watchList = watchList;
|
|
921
974
|
this.config = config2;
|
|
922
975
|
this.prebuildFilePath = prebuildPath;
|
|
923
|
-
this.publicFolderPath =
|
|
976
|
+
this.publicFolderPath = path3.join(
|
|
924
977
|
this.rootPath,
|
|
925
978
|
this.config.build.publicFolder
|
|
926
979
|
);
|
|
927
|
-
this.outputFolderPath =
|
|
980
|
+
this.outputFolderPath = path3.join(
|
|
928
981
|
this.publicFolderPath,
|
|
929
982
|
this.config.build.outputFolder
|
|
930
983
|
);
|
|
931
|
-
this.outputHTMLFilePath =
|
|
932
|
-
this.outputGitignorePath =
|
|
933
|
-
const fullLocalContentPath =
|
|
934
|
-
this.tinaFolderPath,
|
|
935
|
-
this.config.localContentPath || ""
|
|
984
|
+
this.outputHTMLFilePath = path3.join(this.outputFolderPath, "index.html");
|
|
985
|
+
this.outputGitignorePath = path3.join(this.outputFolderPath, ".gitignore");
|
|
986
|
+
const fullLocalContentPath = stripNativeTrailingSlash(
|
|
987
|
+
path3.join(this.tinaFolderPath, this.config.localContentPath || "")
|
|
936
988
|
);
|
|
937
989
|
if (this.config.localContentPath) {
|
|
938
|
-
const localContentPathExists = await
|
|
990
|
+
const localContentPathExists = await fs2.pathExists(fullLocalContentPath);
|
|
939
991
|
if (localContentPathExists) {
|
|
940
992
|
logger.info(`Using separate content repo at ${fullLocalContentPath}`);
|
|
941
993
|
this.contentRootPath = fullLocalContentPath;
|
|
942
994
|
} else {
|
|
943
995
|
logger.warn(
|
|
944
|
-
`${
|
|
996
|
+
`${chalk3.yellow("Warning:")} The localContentPath ${chalk3.cyan(
|
|
945
997
|
fullLocalContentPath
|
|
946
|
-
)} does not exist. Please create it or remove the localContentPath from your config file at ${
|
|
998
|
+
)} does not exist. Please create it or remove the localContentPath from your config file at ${chalk3.cyan(
|
|
947
999
|
this.tinaConfigFilePath
|
|
948
1000
|
)}`
|
|
949
1001
|
);
|
|
@@ -952,22 +1004,22 @@ var ConfigManager = class {
|
|
|
952
1004
|
if (!this.contentRootPath) {
|
|
953
1005
|
this.contentRootPath = this.rootPath;
|
|
954
1006
|
}
|
|
955
|
-
this.generatedFolderPathContentRepo =
|
|
1007
|
+
this.generatedFolderPathContentRepo = path3.join(
|
|
956
1008
|
await this.getTinaFolderPath(this.contentRootPath),
|
|
957
1009
|
GENERATED_FOLDER
|
|
958
1010
|
);
|
|
959
|
-
this.spaMainPath =
|
|
960
|
-
this.spaRootPath =
|
|
1011
|
+
this.spaMainPath = require2.resolve("@tinacms/app");
|
|
1012
|
+
this.spaRootPath = path3.join(this.spaMainPath, "..", "..");
|
|
961
1013
|
}
|
|
962
1014
|
async getTinaFolderPath(rootPath) {
|
|
963
|
-
const tinaFolderPath =
|
|
964
|
-
const tinaFolderExists = await
|
|
1015
|
+
const tinaFolderPath = path3.join(rootPath, TINA_FOLDER);
|
|
1016
|
+
const tinaFolderExists = await fs2.pathExists(tinaFolderPath);
|
|
965
1017
|
if (tinaFolderExists) {
|
|
966
1018
|
this.isUsingLegacyFolder = false;
|
|
967
1019
|
return tinaFolderPath;
|
|
968
1020
|
}
|
|
969
|
-
const legacyFolderPath =
|
|
970
|
-
const legacyFolderExists = await
|
|
1021
|
+
const legacyFolderPath = path3.join(rootPath, LEGACY_TINA_FOLDER);
|
|
1022
|
+
const legacyFolderExists = await fs2.pathExists(legacyFolderPath);
|
|
971
1023
|
if (legacyFolderExists) {
|
|
972
1024
|
this.isUsingLegacyFolder = true;
|
|
973
1025
|
return legacyFolderPath;
|
|
@@ -986,7 +1038,7 @@ var ConfigManager = class {
|
|
|
986
1038
|
patch: version2[2] || "x"
|
|
987
1039
|
};
|
|
988
1040
|
}
|
|
989
|
-
const generatedSchema =
|
|
1041
|
+
const generatedSchema = fs2.readJSONSync(this.generatedSchemaJSONPath);
|
|
990
1042
|
if (!generatedSchema || !(typeof generatedSchema?.version !== "undefined")) {
|
|
991
1043
|
throw new Error(
|
|
992
1044
|
`Can not find Tina GraphQL version in ${this.generatedSchemaJSONPath}`
|
|
@@ -1033,7 +1085,7 @@ var ConfigManager = class {
|
|
|
1033
1085
|
return;
|
|
1034
1086
|
}
|
|
1035
1087
|
const filepathWithExtension = `${filepath}.${ext}`;
|
|
1036
|
-
const exists =
|
|
1088
|
+
const exists = fs2.existsSync(filepathWithExtension);
|
|
1037
1089
|
if (exists) {
|
|
1038
1090
|
result = filepathWithExtension;
|
|
1039
1091
|
}
|
|
@@ -1042,33 +1094,53 @@ var ConfigManager = class {
|
|
|
1042
1094
|
return result;
|
|
1043
1095
|
}
|
|
1044
1096
|
async loadDatabaseFile() {
|
|
1045
|
-
const tmpdir =
|
|
1046
|
-
const outfile =
|
|
1097
|
+
const tmpdir = path3.join(os.tmpdir(), Date.now().toString());
|
|
1098
|
+
const outfile = path3.join(tmpdir, "database.build.mjs");
|
|
1047
1099
|
await esbuild.build({
|
|
1048
1100
|
entryPoints: [this.selfHostedDatabaseFilePath],
|
|
1049
1101
|
bundle: true,
|
|
1050
1102
|
platform: "node",
|
|
1103
|
+
format: "esm",
|
|
1051
1104
|
outfile,
|
|
1052
|
-
loader: loaders
|
|
1105
|
+
loader: loaders,
|
|
1106
|
+
// Provide a require() polyfill for ESM bundles containing CommonJS packages.
|
|
1107
|
+
// Some bundled packages (e.g., 'scmp' used by 'mongodb-level') use require('crypto').
|
|
1108
|
+
// When esbuild inlines these CommonJS packages, it keeps the require() calls,
|
|
1109
|
+
// but ESM doesn't have a global require. This banner creates one using Node.js's
|
|
1110
|
+
// official createRequire API, allowing the bundled CommonJS code to work in ESM.
|
|
1111
|
+
banner: {
|
|
1112
|
+
js: `import { createRequire } from 'module';const require = createRequire(import.meta.url);`
|
|
1113
|
+
}
|
|
1053
1114
|
});
|
|
1054
|
-
const result =
|
|
1055
|
-
|
|
1115
|
+
const result = await import(pathToFileURL(outfile).href);
|
|
1116
|
+
fs2.removeSync(outfile);
|
|
1056
1117
|
return result.default;
|
|
1057
1118
|
}
|
|
1058
1119
|
async loadConfigFile(generatedFolderPath, configFilePath) {
|
|
1059
|
-
const tmpdir =
|
|
1060
|
-
const preBuildConfigPath =
|
|
1120
|
+
const tmpdir = path3.join(os.tmpdir(), Date.now().toString());
|
|
1121
|
+
const preBuildConfigPath = path3.join(
|
|
1061
1122
|
this.generatedFolderPath,
|
|
1062
1123
|
"config.prebuild.jsx"
|
|
1063
1124
|
);
|
|
1064
|
-
const
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1125
|
+
const nativeNodeModulesPlugin = {
|
|
1126
|
+
name: "native-node-modules",
|
|
1127
|
+
setup(build3) {
|
|
1128
|
+
build3.onResolve({ filter: /^node:.*/ }, (args) => {
|
|
1129
|
+
return {
|
|
1130
|
+
path: args.path,
|
|
1131
|
+
external: true
|
|
1132
|
+
};
|
|
1133
|
+
});
|
|
1134
|
+
}
|
|
1135
|
+
};
|
|
1136
|
+
const outfile = path3.join(tmpdir, "config.build.jsx");
|
|
1137
|
+
const outfile2 = path3.join(tmpdir, "config.build.mjs");
|
|
1138
|
+
const tempTSConfigFile = path3.join(tmpdir, "tsconfig.json");
|
|
1139
|
+
fs2.outputFileSync(tempTSConfigFile, "{}");
|
|
1068
1140
|
const result2 = await esbuild.build({
|
|
1069
1141
|
entryPoints: [configFilePath],
|
|
1070
1142
|
bundle: true,
|
|
1071
|
-
target: ["
|
|
1143
|
+
target: ["esnext"],
|
|
1072
1144
|
platform: "browser",
|
|
1073
1145
|
format: "esm",
|
|
1074
1146
|
logLevel: "silent",
|
|
@@ -1088,9 +1160,10 @@ var ConfigManager = class {
|
|
|
1088
1160
|
await esbuild.build({
|
|
1089
1161
|
entryPoints: [configFilePath],
|
|
1090
1162
|
bundle: true,
|
|
1091
|
-
target: ["
|
|
1163
|
+
target: ["esnext"],
|
|
1092
1164
|
logLevel: "silent",
|
|
1093
1165
|
platform: "node",
|
|
1166
|
+
format: "esm",
|
|
1094
1167
|
outfile,
|
|
1095
1168
|
loader: loaders
|
|
1096
1169
|
});
|
|
@@ -1100,19 +1173,21 @@ var ConfigManager = class {
|
|
|
1100
1173
|
// Suppress warning about comparison with -0 from client module
|
|
1101
1174
|
logLevel: "silent",
|
|
1102
1175
|
platform: "node",
|
|
1176
|
+
target: ["esnext"],
|
|
1177
|
+
format: "esm",
|
|
1103
1178
|
outfile: outfile2,
|
|
1104
1179
|
loader: loaders
|
|
1105
1180
|
});
|
|
1106
1181
|
let result;
|
|
1107
1182
|
try {
|
|
1108
|
-
result =
|
|
1183
|
+
result = await import(pathToFileURL(outfile2).href);
|
|
1109
1184
|
} catch (e) {
|
|
1110
1185
|
console.error("Unexpected error loading config");
|
|
1111
1186
|
console.error(e);
|
|
1112
1187
|
throw e;
|
|
1113
1188
|
}
|
|
1114
|
-
|
|
1115
|
-
|
|
1189
|
+
fs2.removeSync(outfile);
|
|
1190
|
+
fs2.removeSync(outfile2);
|
|
1116
1191
|
return {
|
|
1117
1192
|
config: result.default,
|
|
1118
1193
|
prebuildPath: preBuildConfigPath,
|
|
@@ -1147,20 +1222,24 @@ var loaders = {
|
|
|
1147
1222
|
};
|
|
1148
1223
|
|
|
1149
1224
|
// src/next/database.ts
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1225
|
+
import {
|
|
1226
|
+
createDatabaseInternal,
|
|
1227
|
+
FilesystemBridge,
|
|
1228
|
+
TinaLevelClient
|
|
1229
|
+
} from "@tinacms/graphql";
|
|
1230
|
+
import { pipeline } from "readable-stream";
|
|
1231
|
+
import { createServer } from "net";
|
|
1232
|
+
import { ManyLevelHost } from "many-level";
|
|
1233
|
+
import { MemoryLevel } from "memory-level";
|
|
1155
1234
|
var createDBServer = (port) => {
|
|
1156
|
-
const levelHost = new
|
|
1235
|
+
const levelHost = new ManyLevelHost(
|
|
1157
1236
|
// @ts-ignore
|
|
1158
|
-
new
|
|
1237
|
+
new MemoryLevel({
|
|
1159
1238
|
valueEncoding: "json"
|
|
1160
1239
|
})
|
|
1161
1240
|
);
|
|
1162
|
-
const dbServer =
|
|
1163
|
-
return
|
|
1241
|
+
const dbServer = createServer(function(socket) {
|
|
1242
|
+
return pipeline(socket, levelHost.createRpcStream(), socket, () => {
|
|
1164
1243
|
});
|
|
1165
1244
|
});
|
|
1166
1245
|
dbServer.once("error", (err) => {
|
|
@@ -1174,7 +1253,7 @@ var createDBServer = (port) => {
|
|
|
1174
1253
|
};
|
|
1175
1254
|
async function createAndInitializeDatabase(configManager, datalayerPort, bridgeOverride) {
|
|
1176
1255
|
let database;
|
|
1177
|
-
const bridge = bridgeOverride || new
|
|
1256
|
+
const bridge = bridgeOverride || new FilesystemBridge(configManager.rootPath, configManager.contentRootPath);
|
|
1178
1257
|
if (configManager.hasSelfHostedConfig() && configManager.config.contentApiUrlOverride) {
|
|
1179
1258
|
database = await configManager.loadDatabaseFile();
|
|
1180
1259
|
database.bridge = bridge;
|
|
@@ -1186,9 +1265,9 @@ async function createAndInitializeDatabase(configManager, datalayerPort, bridgeO
|
|
|
1186
1265
|
)} but there was no "contentApiUrlOverride" set. Falling back to built-in datalayer`
|
|
1187
1266
|
);
|
|
1188
1267
|
}
|
|
1189
|
-
const level = new
|
|
1268
|
+
const level = new TinaLevelClient(datalayerPort);
|
|
1190
1269
|
level.openConnection();
|
|
1191
|
-
database =
|
|
1270
|
+
database = createDatabaseInternal({
|
|
1192
1271
|
bridge,
|
|
1193
1272
|
level,
|
|
1194
1273
|
tinaDirectory: configManager.isUsingLegacyFolder ? LEGACY_TINA_FOLDER : TINA_FOLDER
|
|
@@ -1198,17 +1277,17 @@ async function createAndInitializeDatabase(configManager, datalayerPort, bridgeO
|
|
|
1198
1277
|
}
|
|
1199
1278
|
|
|
1200
1279
|
// src/next/commands/baseCommands.ts
|
|
1201
|
-
|
|
1202
|
-
|
|
1280
|
+
import { Command, Option } from "clipanion";
|
|
1281
|
+
import chalk4 from "chalk";
|
|
1203
1282
|
|
|
1204
1283
|
// src/utils/start-subprocess.ts
|
|
1205
|
-
|
|
1284
|
+
import childProcess from "child_process";
|
|
1206
1285
|
var startSubprocess2 = async ({ command: command2 }) => {
|
|
1207
1286
|
if (typeof command2 === "string") {
|
|
1208
1287
|
const commands = command2.split(" ");
|
|
1209
1288
|
const firstCommand = commands[0];
|
|
1210
1289
|
const args = commands.slice(1) || [];
|
|
1211
|
-
const ps =
|
|
1290
|
+
const ps = childProcess.spawn(firstCommand, args, {
|
|
1212
1291
|
stdio: "inherit",
|
|
1213
1292
|
shell: true
|
|
1214
1293
|
});
|
|
@@ -1232,45 +1311,42 @@ stack: ${code.stack || "No stack was provided"}`);
|
|
|
1232
1311
|
};
|
|
1233
1312
|
|
|
1234
1313
|
// src/next/commands/baseCommands.ts
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
var BaseCommand = class extends
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
description: "Disable anonymous telemetry that is collected"
|
|
1266
|
-
});
|
|
1267
|
-
}
|
|
1314
|
+
import { getChangedFiles, getSha, shaExists } from "@tinacms/graphql";
|
|
1315
|
+
import fs3 from "fs-extra";
|
|
1316
|
+
var BaseCommand = class extends Command {
|
|
1317
|
+
experimentalDataLayer = Option.Boolean("--experimentalData", {
|
|
1318
|
+
description: "DEPRECATED - Build the server with additional data querying capabilities"
|
|
1319
|
+
});
|
|
1320
|
+
isomorphicGitBridge = Option.Boolean("--isomorphicGitBridge", {
|
|
1321
|
+
description: "DEPRECATED - Enable Isomorphic Git Bridge Implementation"
|
|
1322
|
+
});
|
|
1323
|
+
port = Option.String("-p,--port", "4001", {
|
|
1324
|
+
description: "Specify a port to run the server on. (default 4001)"
|
|
1325
|
+
});
|
|
1326
|
+
datalayerPort = Option.String("--datalayer-port", "9000", {
|
|
1327
|
+
description: "Specify a port to run the datalayer server on. (default 9000)"
|
|
1328
|
+
});
|
|
1329
|
+
subCommand = Option.String("-c,--command", {
|
|
1330
|
+
description: "The sub-command to run"
|
|
1331
|
+
});
|
|
1332
|
+
rootPath = Option.String("--rootPath", {
|
|
1333
|
+
description: "Specify the root directory to run the CLI from (defaults to current working directory)"
|
|
1334
|
+
});
|
|
1335
|
+
verbose = Option.Boolean("-v,--verbose", false, {
|
|
1336
|
+
description: "increase verbosity of logged output"
|
|
1337
|
+
});
|
|
1338
|
+
noSDK = Option.Boolean("--noSDK", false, {
|
|
1339
|
+
description: "DEPRECATED - This should now be set in the config at client.skip = true'. Don't generate the generated client SDK"
|
|
1340
|
+
});
|
|
1341
|
+
noTelemetry = Option.Boolean("--noTelemetry", false, {
|
|
1342
|
+
description: "Disable anonymous telemetry that is collected"
|
|
1343
|
+
});
|
|
1268
1344
|
async startSubCommand() {
|
|
1269
1345
|
let subProc;
|
|
1270
1346
|
if (this.subCommand) {
|
|
1271
1347
|
subProc = await startSubprocess2({ command: this.subCommand });
|
|
1272
1348
|
logger.info(
|
|
1273
|
-
`Running web application with command: ${
|
|
1349
|
+
`Running web application with command: ${chalk4.cyan(this.subCommand)}`
|
|
1274
1350
|
);
|
|
1275
1351
|
}
|
|
1276
1352
|
function exitHandler(options, exitCode) {
|
|
@@ -1318,7 +1394,7 @@ var BaseCommand = class extends import_clipanion.Command {
|
|
|
1318
1394
|
const rootPath = configManager.rootPath;
|
|
1319
1395
|
let sha;
|
|
1320
1396
|
try {
|
|
1321
|
-
sha = await
|
|
1397
|
+
sha = await getSha({ fs: fs3, dir: rootPath });
|
|
1322
1398
|
} catch (e) {
|
|
1323
1399
|
if (partialReindex) {
|
|
1324
1400
|
console.error(
|
|
@@ -1328,7 +1404,7 @@ var BaseCommand = class extends import_clipanion.Command {
|
|
|
1328
1404
|
}
|
|
1329
1405
|
}
|
|
1330
1406
|
const lastSha = await database.getMetadata("lastSha");
|
|
1331
|
-
const exists = lastSha && await
|
|
1407
|
+
const exists = lastSha && await shaExists({ fs: fs3, dir: rootPath, sha: lastSha });
|
|
1332
1408
|
let res;
|
|
1333
1409
|
if (partialReindex && lastSha && exists && sha) {
|
|
1334
1410
|
const pathFilter = {};
|
|
@@ -1342,15 +1418,15 @@ var BaseCommand = class extends import_clipanion.Command {
|
|
|
1342
1418
|
matches: collection.match?.exclude || collection.match?.include ? tinaSchema.getMatches({ collection }) : void 0
|
|
1343
1419
|
};
|
|
1344
1420
|
}
|
|
1345
|
-
const { added, modified, deleted } = await
|
|
1346
|
-
fs:
|
|
1421
|
+
const { added, modified, deleted } = await getChangedFiles({
|
|
1422
|
+
fs: fs3,
|
|
1347
1423
|
dir: rootPath,
|
|
1348
1424
|
from: lastSha,
|
|
1349
1425
|
to: sha,
|
|
1350
1426
|
pathFilter
|
|
1351
1427
|
});
|
|
1352
1428
|
const tinaPathUpdates = modified.filter(
|
|
1353
|
-
(
|
|
1429
|
+
(path15) => path15.startsWith(".tina/__generated__/_schema.json") || path15.startsWith("tina/tina-lock.json")
|
|
1354
1430
|
);
|
|
1355
1431
|
if (tinaPathUpdates.length > 0) {
|
|
1356
1432
|
res = await database.indexContent({
|
|
@@ -1428,7 +1504,7 @@ var errorHTML = `<style type="text/css">
|
|
|
1428
1504
|
the assets for this page.
|
|
1429
1505
|
</p>
|
|
1430
1506
|
<p>
|
|
1431
|
-
Please visit <a href="https://tina.io/docs/
|
|
1507
|
+
Please visit <a href="https://tina.io/docs/r/FAQ/#13-how-do-i-resolve-failed-loading-tinacms-assets-error">this doc</a> for help.
|
|
1432
1508
|
</p>
|
|
1433
1509
|
</div>
|
|
1434
1510
|
</div>`.trim().replace(/[\r\n\s]+/g, " ");
|
|
@@ -1466,34 +1542,38 @@ var devHTML = (port) => `<!DOCTYPE html>
|
|
|
1466
1542
|
</html>`;
|
|
1467
1543
|
|
|
1468
1544
|
// src/next/commands/dev-command/server/index.ts
|
|
1469
|
-
|
|
1545
|
+
import { createServer as createViteServer } from "vite";
|
|
1470
1546
|
|
|
1471
1547
|
// src/next/vite/index.ts
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1548
|
+
import path5 from "node:path";
|
|
1549
|
+
import react from "@vitejs/plugin-react";
|
|
1550
|
+
import fs4 from "fs-extra";
|
|
1551
|
+
import normalizePath3 from "normalize-path";
|
|
1552
|
+
import {
|
|
1553
|
+
splitVendorChunkPlugin
|
|
1554
|
+
} from "vite";
|
|
1477
1555
|
|
|
1478
1556
|
// src/next/vite/tailwind.ts
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1557
|
+
import path4 from "node:path";
|
|
1558
|
+
import aspectRatio from "@tailwindcss/aspect-ratio";
|
|
1559
|
+
import containerQueries from "@tailwindcss/container-queries";
|
|
1560
|
+
import twTypography from "@tailwindcss/typography";
|
|
1561
|
+
import tailwind from "tailwindcss";
|
|
1562
|
+
import defaultTheme from "tailwindcss/defaultTheme.js";
|
|
1563
|
+
import { createRequire as createRequire2 } from "module";
|
|
1485
1564
|
var tinaTailwind = (spaPath, prebuildFilePath) => {
|
|
1486
1565
|
return {
|
|
1487
1566
|
name: "vite-plugin-tina",
|
|
1488
1567
|
// @ts-ignore
|
|
1489
1568
|
config: (viteConfig) => {
|
|
1569
|
+
const require2 = createRequire2(import.meta.url);
|
|
1490
1570
|
const plugins = [];
|
|
1491
1571
|
const content = [
|
|
1492
|
-
|
|
1572
|
+
path4.join(spaPath, "src/**/*.{vue,js,ts,jsx,tsx,svelte}"),
|
|
1493
1573
|
prebuildFilePath,
|
|
1494
|
-
|
|
1574
|
+
require2.resolve("tinacms")
|
|
1495
1575
|
];
|
|
1496
|
-
const tw = (
|
|
1576
|
+
const tw = tailwind({
|
|
1497
1577
|
theme: {
|
|
1498
1578
|
columns: {
|
|
1499
1579
|
auto: "auto",
|
|
@@ -1681,6 +1761,9 @@ var tinaTailwind = (spaPath, prebuildFilePath) => {
|
|
|
1681
1761
|
500: "#EC4815",
|
|
1682
1762
|
600: "#DC4419"
|
|
1683
1763
|
},
|
|
1764
|
+
"tina-orange": "#EC4815",
|
|
1765
|
+
"tina-orange-dark": "#C2410C",
|
|
1766
|
+
"tina-orange-light": "#FFF7ED",
|
|
1684
1767
|
background: "#FFFFFF",
|
|
1685
1768
|
foreground: "#0A0A0A",
|
|
1686
1769
|
muted: "#F5F5F5",
|
|
@@ -1702,7 +1785,7 @@ var tinaTailwind = (spaPath, prebuildFilePath) => {
|
|
|
1702
1785
|
ring: "#0A0A0A"
|
|
1703
1786
|
},
|
|
1704
1787
|
fontFamily: {
|
|
1705
|
-
sans: ["Inter", ...
|
|
1788
|
+
sans: ["Inter", ...defaultTheme.fontFamily.sans]
|
|
1706
1789
|
},
|
|
1707
1790
|
lineHeight: {
|
|
1708
1791
|
3: "12px",
|
|
@@ -1727,9 +1810,9 @@ var tinaTailwind = (spaPath, prebuildFilePath) => {
|
|
|
1727
1810
|
},
|
|
1728
1811
|
content,
|
|
1729
1812
|
plugins: [
|
|
1730
|
-
(
|
|
1731
|
-
|
|
1732
|
-
|
|
1813
|
+
twTypography({ className: "tina-prose" }),
|
|
1814
|
+
aspectRatio,
|
|
1815
|
+
containerQueries
|
|
1733
1816
|
]
|
|
1734
1817
|
});
|
|
1735
1818
|
plugins.push(tw);
|
|
@@ -1750,35 +1833,35 @@ async function listFilesRecursively({
|
|
|
1750
1833
|
config: config2,
|
|
1751
1834
|
roothPath
|
|
1752
1835
|
}) {
|
|
1753
|
-
const fullDirectoryPath =
|
|
1836
|
+
const fullDirectoryPath = path5.join(
|
|
1754
1837
|
roothPath,
|
|
1755
1838
|
config2.publicFolder,
|
|
1756
1839
|
directoryPath
|
|
1757
1840
|
);
|
|
1758
|
-
const exists = await
|
|
1841
|
+
const exists = await fs4.pathExists(fullDirectoryPath);
|
|
1759
1842
|
if (!exists) {
|
|
1760
1843
|
return { "0": [] };
|
|
1761
1844
|
}
|
|
1762
|
-
const items = await
|
|
1845
|
+
const items = await fs4.readdir(fullDirectoryPath);
|
|
1763
1846
|
const staticMediaItems = [];
|
|
1764
1847
|
for (const item of items) {
|
|
1765
|
-
const itemPath =
|
|
1766
|
-
const stats = await
|
|
1848
|
+
const itemPath = path5.join(fullDirectoryPath, item);
|
|
1849
|
+
const stats = await fs4.promises.lstat(itemPath);
|
|
1767
1850
|
const staticMediaItem = {
|
|
1768
1851
|
id: item,
|
|
1769
1852
|
filename: item,
|
|
1770
1853
|
type: stats.isDirectory() ? "dir" : "file",
|
|
1771
1854
|
directory: `${directoryPath.replace(config2.mediaRoot, "")}`,
|
|
1772
|
-
src: `/${
|
|
1855
|
+
src: `/${path5.join(directoryPath, item)}`,
|
|
1773
1856
|
thumbnails: {
|
|
1774
|
-
"75x75": `/${
|
|
1775
|
-
"400x400": `/${
|
|
1776
|
-
"1000x1000": `/${
|
|
1857
|
+
"75x75": `/${path5.join(directoryPath, item)}`,
|
|
1858
|
+
"400x400": `/${path5.join(directoryPath, item)}`,
|
|
1859
|
+
"1000x1000": `/${path5.join(directoryPath, item)}`
|
|
1777
1860
|
}
|
|
1778
1861
|
};
|
|
1779
1862
|
if (stats.isDirectory()) {
|
|
1780
1863
|
staticMediaItem.children = await listFilesRecursively({
|
|
1781
|
-
directoryPath:
|
|
1864
|
+
directoryPath: path5.join(directoryPath, item),
|
|
1782
1865
|
config: config2,
|
|
1783
1866
|
roothPath
|
|
1784
1867
|
});
|
|
@@ -1819,7 +1902,7 @@ var createConfig = async ({
|
|
|
1819
1902
|
}
|
|
1820
1903
|
}
|
|
1821
1904
|
});
|
|
1822
|
-
const staticMediaPath =
|
|
1905
|
+
const staticMediaPath = path5.join(
|
|
1823
1906
|
configManager.generatedFolderPath,
|
|
1824
1907
|
"static-media.json"
|
|
1825
1908
|
);
|
|
@@ -1829,21 +1912,21 @@ var createConfig = async ({
|
|
|
1829
1912
|
config: configManager.config.media.tina,
|
|
1830
1913
|
roothPath: configManager.rootPath
|
|
1831
1914
|
});
|
|
1832
|
-
await
|
|
1915
|
+
await fs4.outputFile(staticMediaPath, JSON.stringify(staticMedia, null, 2));
|
|
1833
1916
|
} else {
|
|
1834
|
-
await
|
|
1917
|
+
await fs4.outputFile(staticMediaPath, `[]`);
|
|
1835
1918
|
}
|
|
1836
1919
|
const alias = {
|
|
1837
1920
|
TINA_IMPORT: configManager.prebuildFilePath,
|
|
1838
1921
|
SCHEMA_IMPORT: configManager.generatedGraphQLJSONPath,
|
|
1839
1922
|
STATIC_MEDIA_IMPORT: staticMediaPath,
|
|
1840
|
-
crypto:
|
|
1841
|
-
fs:
|
|
1842
|
-
os:
|
|
1843
|
-
path:
|
|
1923
|
+
crypto: path5.join(configManager.spaRootPath, "src", "dummy-client.ts"),
|
|
1924
|
+
fs: path5.join(configManager.spaRootPath, "src", "dummy-client.ts"),
|
|
1925
|
+
os: path5.join(configManager.spaRootPath, "src", "dummy-client.ts"),
|
|
1926
|
+
path: path5.join(configManager.spaRootPath, "src", "dummy-client.ts")
|
|
1844
1927
|
};
|
|
1845
1928
|
if (configManager.shouldSkipSDK()) {
|
|
1846
|
-
alias["CLIENT_IMPORT"] =
|
|
1929
|
+
alias["CLIENT_IMPORT"] = path5.join(
|
|
1847
1930
|
configManager.spaRootPath,
|
|
1848
1931
|
"src",
|
|
1849
1932
|
"dummy-client.ts"
|
|
@@ -1859,7 +1942,7 @@ var createConfig = async ({
|
|
|
1859
1942
|
const version2 = `${fullVersion.major}.${fullVersion.minor}`;
|
|
1860
1943
|
const config2 = {
|
|
1861
1944
|
root: configManager.spaRootPath,
|
|
1862
|
-
base: `/${basePath ? `${(
|
|
1945
|
+
base: `/${basePath ? `${normalizePath3(basePath)}/` : ""}${normalizePath3(
|
|
1863
1946
|
configManager.config.build.outputFolder
|
|
1864
1947
|
)}/`,
|
|
1865
1948
|
appType: "spa",
|
|
@@ -1922,13 +2005,14 @@ var createConfig = async ({
|
|
|
1922
2005
|
* `splitVendorChunkPlugin` is needed because `tinacms` is quite large,
|
|
1923
2006
|
* Vite's chunking strategy chokes on memory issues for smaller machines (ie. on CI).
|
|
1924
2007
|
*/
|
|
1925
|
-
(
|
|
2008
|
+
react({
|
|
1926
2009
|
babel: {
|
|
1927
2010
|
// Supresses the warning [NOTE] babel The code generator has deoptimised the styling of
|
|
1928
2011
|
compact: true
|
|
1929
|
-
}
|
|
2012
|
+
},
|
|
2013
|
+
fastRefresh: false
|
|
1930
2014
|
}),
|
|
1931
|
-
|
|
2015
|
+
splitVendorChunkPlugin(),
|
|
1932
2016
|
tinaTailwind(configManager.spaRootPath, configManager.prebuildFilePath),
|
|
1933
2017
|
...plugins
|
|
1934
2018
|
]
|
|
@@ -1937,21 +2021,21 @@ var createConfig = async ({
|
|
|
1937
2021
|
};
|
|
1938
2022
|
|
|
1939
2023
|
// src/next/vite/plugins.ts
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
2024
|
+
import { createFilter } from "@rollup/pluginutils";
|
|
2025
|
+
import fs6 from "fs";
|
|
2026
|
+
import { transformWithEsbuild } from "vite";
|
|
2027
|
+
import { transform as esbuildTransform } from "esbuild";
|
|
2028
|
+
import path7 from "path";
|
|
2029
|
+
import bodyParser from "body-parser";
|
|
2030
|
+
import cors from "cors";
|
|
2031
|
+
import { resolve as gqlResolve } from "@tinacms/graphql";
|
|
1948
2032
|
|
|
1949
2033
|
// src/next/commands/dev-command/server/media.ts
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
2034
|
+
import fs5 from "fs-extra";
|
|
2035
|
+
import path6, { join } from "path";
|
|
2036
|
+
import busboy from "busboy";
|
|
1953
2037
|
var createMediaRouter = (config2) => {
|
|
1954
|
-
const mediaFolder =
|
|
2038
|
+
const mediaFolder = path6.join(
|
|
1955
2039
|
config2.rootPath,
|
|
1956
2040
|
config2.publicFolder,
|
|
1957
2041
|
config2.mediaRoot
|
|
@@ -1975,12 +2059,12 @@ var createMediaRouter = (config2) => {
|
|
|
1975
2059
|
res.end(JSON.stringify(didDelete));
|
|
1976
2060
|
};
|
|
1977
2061
|
const handlePost = async function(req, res) {
|
|
1978
|
-
const bb = (
|
|
2062
|
+
const bb = busboy({ headers: req.headers });
|
|
1979
2063
|
bb.on("file", async (_name, file, _info) => {
|
|
1980
2064
|
const fullPath = decodeURI(req.url?.slice("/media/upload/".length));
|
|
1981
|
-
const saveTo =
|
|
1982
|
-
await
|
|
1983
|
-
file.pipe(
|
|
2065
|
+
const saveTo = path6.join(mediaFolder, ...fullPath.split("/"));
|
|
2066
|
+
await fs5.ensureDir(path6.dirname(saveTo));
|
|
2067
|
+
file.pipe(fs5.createWriteStream(saveTo));
|
|
1984
2068
|
});
|
|
1985
2069
|
bb.on("error", (error) => {
|
|
1986
2070
|
res.statusCode = 500;
|
|
@@ -2006,6 +2090,9 @@ var parseMediaFolder = (str) => {
|
|
|
2006
2090
|
return returnString;
|
|
2007
2091
|
};
|
|
2008
2092
|
var MediaModel = class {
|
|
2093
|
+
rootPath;
|
|
2094
|
+
publicFolder;
|
|
2095
|
+
mediaRoot;
|
|
2009
2096
|
constructor({ rootPath, publicFolder, mediaRoot }) {
|
|
2010
2097
|
this.rootPath = rootPath;
|
|
2011
2098
|
this.mediaRoot = mediaRoot;
|
|
@@ -2013,23 +2100,23 @@ var MediaModel = class {
|
|
|
2013
2100
|
}
|
|
2014
2101
|
async listMedia(args) {
|
|
2015
2102
|
try {
|
|
2016
|
-
const folderPath =
|
|
2103
|
+
const folderPath = join(
|
|
2017
2104
|
this.rootPath,
|
|
2018
2105
|
this.publicFolder,
|
|
2019
2106
|
this.mediaRoot,
|
|
2020
2107
|
decodeURIComponent(args.searchPath)
|
|
2021
2108
|
);
|
|
2022
2109
|
const searchPath = parseMediaFolder(args.searchPath);
|
|
2023
|
-
if (!await
|
|
2110
|
+
if (!await fs5.pathExists(folderPath)) {
|
|
2024
2111
|
return {
|
|
2025
2112
|
files: [],
|
|
2026
2113
|
directories: []
|
|
2027
2114
|
};
|
|
2028
2115
|
}
|
|
2029
|
-
const filesStr = await
|
|
2116
|
+
const filesStr = await fs5.readdir(folderPath);
|
|
2030
2117
|
const filesProm = filesStr.map(async (file) => {
|
|
2031
|
-
const filePath =
|
|
2032
|
-
const stat = await
|
|
2118
|
+
const filePath = join(folderPath, file);
|
|
2119
|
+
const stat = await fs5.stat(filePath);
|
|
2033
2120
|
let src = `/${file}`;
|
|
2034
2121
|
const isFile = stat.isFile();
|
|
2035
2122
|
if (!isFile) {
|
|
@@ -2085,14 +2172,14 @@ var MediaModel = class {
|
|
|
2085
2172
|
}
|
|
2086
2173
|
async deleteMedia(args) {
|
|
2087
2174
|
try {
|
|
2088
|
-
const file =
|
|
2175
|
+
const file = join(
|
|
2089
2176
|
this.rootPath,
|
|
2090
2177
|
this.publicFolder,
|
|
2091
2178
|
this.mediaRoot,
|
|
2092
2179
|
decodeURIComponent(args.searchPath)
|
|
2093
2180
|
);
|
|
2094
|
-
await
|
|
2095
|
-
await
|
|
2181
|
+
await fs5.stat(file);
|
|
2182
|
+
await fs5.remove(file);
|
|
2096
2183
|
return { ok: true };
|
|
2097
2184
|
} catch (error) {
|
|
2098
2185
|
console.error(error);
|
|
@@ -2150,9 +2237,9 @@ var transformTsxPlugin = ({
|
|
|
2150
2237
|
const plug = {
|
|
2151
2238
|
name: "transform-tsx",
|
|
2152
2239
|
async transform(code, id) {
|
|
2153
|
-
const extName =
|
|
2240
|
+
const extName = path7.extname(id);
|
|
2154
2241
|
if (extName.startsWith(".tsx") || extName.startsWith(".ts")) {
|
|
2155
|
-
const result = await (
|
|
2242
|
+
const result = await esbuildTransform(code, { loader: "tsx" });
|
|
2156
2243
|
return {
|
|
2157
2244
|
code: result.code
|
|
2158
2245
|
};
|
|
@@ -2171,8 +2258,8 @@ var devServerEndPointsPlugin = ({
|
|
|
2171
2258
|
const plug = {
|
|
2172
2259
|
name: "graphql-endpoints",
|
|
2173
2260
|
configureServer(server) {
|
|
2174
|
-
server.middlewares.use((
|
|
2175
|
-
server.middlewares.use(
|
|
2261
|
+
server.middlewares.use(cors());
|
|
2262
|
+
server.middlewares.use(bodyParser.json({ limit: "5mb" }));
|
|
2176
2263
|
server.middlewares.use(async (req, res, next) => {
|
|
2177
2264
|
const mediaPaths = configManager.config.media?.tina;
|
|
2178
2265
|
const mediaRouter = createMediaRouter({
|
|
@@ -2211,7 +2298,7 @@ var devServerEndPointsPlugin = ({
|
|
|
2211
2298
|
const { query, variables } = req.body;
|
|
2212
2299
|
let result;
|
|
2213
2300
|
await databaseLock(async () => {
|
|
2214
|
-
result = await (
|
|
2301
|
+
result = await gqlResolve({
|
|
2215
2302
|
config: {
|
|
2216
2303
|
useRelativeMedia: true
|
|
2217
2304
|
},
|
|
@@ -2247,13 +2334,13 @@ function viteTransformExtension({
|
|
|
2247
2334
|
include = "**/*.svg",
|
|
2248
2335
|
exclude
|
|
2249
2336
|
} = {}) {
|
|
2250
|
-
const filter =
|
|
2337
|
+
const filter = createFilter(include, exclude);
|
|
2251
2338
|
return {
|
|
2252
2339
|
name: "vite-plugin-svgr",
|
|
2253
2340
|
async transform(code, id) {
|
|
2254
2341
|
if (filter(id)) {
|
|
2255
2342
|
const { transform: transform2 } = await import("@svgr/core");
|
|
2256
|
-
const svgCode = await
|
|
2343
|
+
const svgCode = await fs6.promises.readFile(
|
|
2257
2344
|
id.replace(/\?.*$/, ""),
|
|
2258
2345
|
"utf8"
|
|
2259
2346
|
);
|
|
@@ -2263,7 +2350,7 @@ function viteTransformExtension({
|
|
|
2263
2350
|
previousExport: exportAsDefault ? null : code
|
|
2264
2351
|
}
|
|
2265
2352
|
});
|
|
2266
|
-
const res = await
|
|
2353
|
+
const res = await transformWithEsbuild(componentCode, id, {
|
|
2267
2354
|
loader: "jsx",
|
|
2268
2355
|
...esbuildOptions
|
|
2269
2356
|
});
|
|
@@ -2290,7 +2377,7 @@ var createDevServer = async (configManager, database, searchIndex, apiURL, noWat
|
|
|
2290
2377
|
}),
|
|
2291
2378
|
viteTransformExtension()
|
|
2292
2379
|
];
|
|
2293
|
-
return (
|
|
2380
|
+
return createViteServer(
|
|
2294
2381
|
await createConfig({
|
|
2295
2382
|
configManager,
|
|
2296
2383
|
database,
|
|
@@ -2320,37 +2407,30 @@ var createDevServer = async (configManager, database, searchIndex, apiURL, noWat
|
|
|
2320
2407
|
|
|
2321
2408
|
// src/next/commands/dev-command/index.ts
|
|
2322
2409
|
var DevCommand = class extends BaseCommand {
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
|
|
2326
|
-
this
|
|
2327
|
-
|
|
2328
|
-
|
|
2329
|
-
|
|
2330
|
-
|
|
2331
|
-
|
|
2332
|
-
|
|
2333
|
-
|
|
2334
|
-
|
|
2335
|
-
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
-
|
|
2344
|
-
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
description: `Builds Tina and starts the dev server`,
|
|
2348
|
-
examples: [
|
|
2349
|
-
[`A basic example`, `$0 dev`],
|
|
2350
|
-
[`A second example`, `$0 dev --rootPath`]
|
|
2351
|
-
]
|
|
2352
|
-
});
|
|
2353
|
-
}
|
|
2410
|
+
static paths = [["dev"], ["server:start"]];
|
|
2411
|
+
// NOTE: camelCase commands for string options don't work if there's an `=` used https://github.com/arcanis/clipanion/issues/141
|
|
2412
|
+
watchFolders = Option2.String("-w,--watchFolders", {
|
|
2413
|
+
description: "DEPRECATED - a list of folders (relative to where this is being run) that the cli will watch for changes"
|
|
2414
|
+
});
|
|
2415
|
+
noWatch = Option2.Boolean("--noWatch", false, {
|
|
2416
|
+
description: "Don't regenerate config on file changes"
|
|
2417
|
+
});
|
|
2418
|
+
outputSearchIndexPath = Option2.String("--outputSearchIndexPath", {
|
|
2419
|
+
description: "Path to write the search index to"
|
|
2420
|
+
});
|
|
2421
|
+
noServer = Option2.Boolean("--no-server", false, {
|
|
2422
|
+
description: "Do not start the dev server"
|
|
2423
|
+
});
|
|
2424
|
+
indexingLock = new AsyncLock();
|
|
2425
|
+
// Prevent indexes and reads occurring at once
|
|
2426
|
+
static usage = Command2.Usage({
|
|
2427
|
+
category: `Commands`,
|
|
2428
|
+
description: `Builds Tina and starts the dev server`,
|
|
2429
|
+
examples: [
|
|
2430
|
+
[`A basic example`, `$0 dev`],
|
|
2431
|
+
[`A second example`, `$0 dev --rootPath`]
|
|
2432
|
+
]
|
|
2433
|
+
});
|
|
2354
2434
|
async catch(error) {
|
|
2355
2435
|
logger.error("Error occured during tinacms dev");
|
|
2356
2436
|
console.error(error);
|
|
@@ -2387,7 +2467,7 @@ var DevCommand = class extends BaseCommand {
|
|
|
2387
2467
|
} else {
|
|
2388
2468
|
database.clearCache();
|
|
2389
2469
|
}
|
|
2390
|
-
const { tinaSchema: tinaSchema2, graphQLSchema: graphQLSchema2, lookup, queryDoc, fragDoc } = await
|
|
2470
|
+
const { tinaSchema: tinaSchema2, graphQLSchema: graphQLSchema2, lookup, queryDoc, fragDoc } = await buildSchema(configManager.config);
|
|
2391
2471
|
const codegen2 = new Codegen({
|
|
2392
2472
|
isLocal: true,
|
|
2393
2473
|
configManager,
|
|
@@ -2401,29 +2481,32 @@ var DevCommand = class extends BaseCommand {
|
|
|
2401
2481
|
});
|
|
2402
2482
|
const apiURL2 = await codegen2.execute();
|
|
2403
2483
|
if (!configManager.isUsingLegacyFolder) {
|
|
2404
|
-
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
const
|
|
2408
|
-
|
|
2409
|
-
|
|
2484
|
+
const schemaObject = await fs7.readJSON(
|
|
2485
|
+
configManager.generatedSchemaJSONPath
|
|
2486
|
+
);
|
|
2487
|
+
const lookupObject = await fs7.readJSON(
|
|
2488
|
+
configManager.generatedLookupJSONPath
|
|
2489
|
+
);
|
|
2490
|
+
const graphqlSchemaObject = await fs7.readJSON(
|
|
2491
|
+
configManager.generatedGraphQLJSONPath
|
|
2492
|
+
);
|
|
2410
2493
|
const tinaLockFilename = "tina-lock.json";
|
|
2411
2494
|
const tinaLockContent = JSON.stringify({
|
|
2412
2495
|
schema: schemaObject,
|
|
2413
2496
|
lookup: lookupObject,
|
|
2414
2497
|
graphql: graphqlSchemaObject
|
|
2415
2498
|
});
|
|
2416
|
-
|
|
2417
|
-
|
|
2499
|
+
fs7.writeFileSync(
|
|
2500
|
+
path8.join(configManager.tinaFolderPath, tinaLockFilename),
|
|
2418
2501
|
tinaLockContent
|
|
2419
2502
|
);
|
|
2420
2503
|
if (configManager.hasSeparateContentRoot()) {
|
|
2421
2504
|
const rootPath = await configManager.getTinaFolderPath(
|
|
2422
2505
|
configManager.contentRootPath
|
|
2423
2506
|
);
|
|
2424
|
-
const filePath =
|
|
2425
|
-
await
|
|
2426
|
-
await
|
|
2507
|
+
const filePath = path8.join(rootPath, tinaLockFilename);
|
|
2508
|
+
await fs7.ensureFile(filePath);
|
|
2509
|
+
await fs7.outputFile(filePath, tinaLockContent);
|
|
2427
2510
|
}
|
|
2428
2511
|
}
|
|
2429
2512
|
await this.indexContentWithSpinner({
|
|
@@ -2466,19 +2549,19 @@ ${dangerText(e.message)}
|
|
|
2466
2549
|
const { apiURL, graphQLSchema, tinaSchema } = await setup({
|
|
2467
2550
|
firstTime: true
|
|
2468
2551
|
});
|
|
2469
|
-
await
|
|
2470
|
-
await
|
|
2552
|
+
await fs7.outputFile(configManager.outputHTMLFilePath, devHTML(this.port));
|
|
2553
|
+
await fs7.outputFile(
|
|
2471
2554
|
configManager.outputGitignorePath,
|
|
2472
2555
|
"index.html\nassets/"
|
|
2473
2556
|
);
|
|
2474
|
-
const searchIndexClient = new
|
|
2557
|
+
const searchIndexClient = new LocalSearchIndexClient({
|
|
2475
2558
|
stopwordLanguages: configManager.config.search?.tina?.stopwordLanguages,
|
|
2476
2559
|
tokenSplitRegex: configManager.config.search?.tina?.tokenSplitRegex
|
|
2477
2560
|
});
|
|
2478
2561
|
await searchIndexClient.onStartIndexing();
|
|
2479
|
-
const searchIndexer = new
|
|
2562
|
+
const searchIndexer = new SearchIndexer({
|
|
2480
2563
|
batchSize: configManager.config.search?.indexBatchSize || 100,
|
|
2481
|
-
bridge: new
|
|
2564
|
+
bridge: new FilesystemBridge2(
|
|
2482
2565
|
configManager.rootPath,
|
|
2483
2566
|
configManager.contentRootPath
|
|
2484
2567
|
),
|
|
@@ -2519,7 +2602,7 @@ ${dangerText(e.message)}
|
|
|
2519
2602
|
);
|
|
2520
2603
|
await server.listen(Number(this.port));
|
|
2521
2604
|
if (!this.noWatch) {
|
|
2522
|
-
|
|
2605
|
+
chokidar.watch(configManager.watchList).on("change", async () => {
|
|
2523
2606
|
await dbLock(async () => {
|
|
2524
2607
|
logger.info(`Tina config change detected, rebuilding`);
|
|
2525
2608
|
await setup({ firstTime: false });
|
|
@@ -2581,11 +2664,11 @@ ${dangerText(e.message)}
|
|
|
2581
2664
|
// subItems: [
|
|
2582
2665
|
// {
|
|
2583
2666
|
// key: 'Custom queries',
|
|
2584
|
-
// value: 'https://tina.io/
|
|
2667
|
+
// value: 'https://tina.io/docs/r/content-api-overview',
|
|
2585
2668
|
// },
|
|
2586
2669
|
// {
|
|
2587
2670
|
// key: 'Visual editing',
|
|
2588
|
-
// value: 'https://tina.io/visual-editing',
|
|
2671
|
+
// value: 'https://tina.io/docs/r/visual-editing-setup',
|
|
2589
2672
|
// },
|
|
2590
2673
|
// ],
|
|
2591
2674
|
// },
|
|
@@ -2596,14 +2679,14 @@ ${dangerText(e.message)}
|
|
|
2596
2679
|
watchContentFiles(configManager, database, databaseLock, searchIndexer) {
|
|
2597
2680
|
const collectionContentFiles = [];
|
|
2598
2681
|
configManager.config.schema.collections.forEach((collection) => {
|
|
2599
|
-
const collectionGlob = `${
|
|
2682
|
+
const collectionGlob = `${path8.join(
|
|
2600
2683
|
configManager.contentRootPath,
|
|
2601
2684
|
collection.path
|
|
2602
2685
|
)}/**/*.${collection.format || "md"}`;
|
|
2603
2686
|
collectionContentFiles.push(collectionGlob);
|
|
2604
2687
|
});
|
|
2605
2688
|
let ready = false;
|
|
2606
|
-
|
|
2689
|
+
chokidar.watch(collectionContentFiles).on("ready", () => {
|
|
2607
2690
|
ready = true;
|
|
2608
2691
|
}).on("add", async (addedFile) => {
|
|
2609
2692
|
if (!ready) {
|
|
@@ -2640,28 +2723,35 @@ ${dangerText(e.message)}
|
|
|
2640
2723
|
await callback();
|
|
2641
2724
|
});
|
|
2642
2725
|
};
|
|
2643
|
-
|
|
2726
|
+
chokidar.watch(configManager.userQueriesAndFragmentsGlob).on("add", executeCallback).on("change", executeCallback).on("unlink", executeCallback);
|
|
2644
2727
|
}
|
|
2645
2728
|
};
|
|
2646
2729
|
|
|
2647
2730
|
// src/next/commands/build-command/index.ts
|
|
2648
|
-
|
|
2649
|
-
|
|
2650
|
-
|
|
2651
|
-
|
|
2652
|
-
|
|
2653
|
-
|
|
2654
|
-
|
|
2655
|
-
|
|
2656
|
-
|
|
2657
|
-
|
|
2731
|
+
import crypto from "crypto";
|
|
2732
|
+
import path9 from "path";
|
|
2733
|
+
import { diff } from "@graphql-inspector/core";
|
|
2734
|
+
import { FilesystemBridge as FilesystemBridge3, buildSchema as buildSchema2 } from "@tinacms/graphql";
|
|
2735
|
+
import { parseURL as parseURL2 } from "@tinacms/schema-tools";
|
|
2736
|
+
import {
|
|
2737
|
+
SearchIndexer as SearchIndexer2,
|
|
2738
|
+
TinaCMSSearchIndexClient
|
|
2739
|
+
} from "@tinacms/search";
|
|
2740
|
+
import { Command as Command3, Option as Option3 } from "clipanion";
|
|
2741
|
+
import fs8 from "fs-extra";
|
|
2742
|
+
import {
|
|
2743
|
+
buildASTSchema as buildASTSchema2,
|
|
2744
|
+
buildClientSchema,
|
|
2745
|
+
getIntrospectionQuery
|
|
2746
|
+
} from "graphql";
|
|
2747
|
+
import Progress2 from "progress";
|
|
2658
2748
|
|
|
2659
2749
|
// src/utils/index.ts
|
|
2660
|
-
|
|
2750
|
+
import { ChangeType } from "@graphql-inspector/core";
|
|
2661
2751
|
var getFaqLink = (type) => {
|
|
2662
2752
|
switch (type) {
|
|
2663
|
-
case
|
|
2664
|
-
return "https://tina.io/docs/
|
|
2753
|
+
case ChangeType.FieldRemoved: {
|
|
2754
|
+
return "https://tina.io/docs/r/FAQ/#2-how-do-i-resolve-the-local-graphql-schema-doesnt-match-the-remote-graphql-schema-error";
|
|
2665
2755
|
}
|
|
2666
2756
|
default:
|
|
2667
2757
|
return null;
|
|
@@ -2682,7 +2772,7 @@ async function sleepAndCallFunc({
|
|
|
2682
2772
|
}
|
|
2683
2773
|
|
|
2684
2774
|
// src/next/commands/build-command/server.ts
|
|
2685
|
-
|
|
2775
|
+
import { build as build2 } from "vite";
|
|
2686
2776
|
var buildProductionSpa = async (configManager, database, apiURL) => {
|
|
2687
2777
|
const publicEnv = {};
|
|
2688
2778
|
Object.keys(process.env).forEach((key) => {
|
|
@@ -2716,12 +2806,12 @@ var buildProductionSpa = async (configManager, database, apiURL) => {
|
|
|
2716
2806
|
}
|
|
2717
2807
|
}
|
|
2718
2808
|
});
|
|
2719
|
-
return (
|
|
2809
|
+
return build2(config2);
|
|
2720
2810
|
};
|
|
2721
2811
|
|
|
2722
2812
|
// src/next/commands/build-command/waitForDB.ts
|
|
2723
|
-
|
|
2724
|
-
|
|
2813
|
+
import { parseURL } from "@tinacms/schema-tools";
|
|
2814
|
+
import Progress from "progress";
|
|
2725
2815
|
var POLLING_INTERVAL = 5e3;
|
|
2726
2816
|
var STATUS_INPROGRESS = "inprogress";
|
|
2727
2817
|
var STATUS_COMPLETE = "complete";
|
|
@@ -2734,14 +2824,14 @@ var IndexFailedError = class extends Error {
|
|
|
2734
2824
|
};
|
|
2735
2825
|
var waitForDB = async (config2, apiUrl, previewName, verbose) => {
|
|
2736
2826
|
const token = config2.token;
|
|
2737
|
-
const { clientId, branch, isLocalClient, host } =
|
|
2827
|
+
const { clientId, branch, isLocalClient, host } = parseURL(apiUrl);
|
|
2738
2828
|
if (isLocalClient || !host || !clientId || !branch) {
|
|
2739
2829
|
if (verbose) {
|
|
2740
2830
|
logger.info(logText("Not using TinaCloud, skipping DB check"));
|
|
2741
2831
|
}
|
|
2742
2832
|
return;
|
|
2743
2833
|
}
|
|
2744
|
-
const bar2 = new
|
|
2834
|
+
const bar2 = new Progress(
|
|
2745
2835
|
"Checking indexing process in TinaCloud... :prog",
|
|
2746
2836
|
1
|
|
2747
2837
|
);
|
|
@@ -2804,51 +2894,44 @@ var waitForDB = async (config2, apiUrl, previewName, verbose) => {
|
|
|
2804
2894
|
|
|
2805
2895
|
// src/next/commands/build-command/index.ts
|
|
2806
2896
|
var BuildCommand = class extends BaseCommand {
|
|
2807
|
-
|
|
2808
|
-
|
|
2809
|
-
|
|
2810
|
-
|
|
2811
|
-
|
|
2812
|
-
|
|
2813
|
-
|
|
2814
|
-
|
|
2815
|
-
|
|
2816
|
-
|
|
2817
|
-
|
|
2818
|
-
|
|
2819
|
-
|
|
2820
|
-
|
|
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
|
-
static {
|
|
2847
|
-
this.usage = import_clipanion3.Command.Usage({
|
|
2848
|
-
category: `Commands`,
|
|
2849
|
-
description: `Build the CMS and autogenerated modules for usage with TinaCloud`
|
|
2850
|
-
});
|
|
2851
|
-
}
|
|
2897
|
+
static paths = [["build"]];
|
|
2898
|
+
localOption = Option3.Boolean("--local", {
|
|
2899
|
+
description: "Starts local Graphql server and builds the local client instead of production client"
|
|
2900
|
+
});
|
|
2901
|
+
skipIndexing = Option3.Boolean("--skip-indexing", false, {
|
|
2902
|
+
description: "Skips indexing the content. This can be used for building the site without indexing the content (defaults to false)"
|
|
2903
|
+
});
|
|
2904
|
+
partialReindex = Option3.Boolean("--partial-reindex", false, {
|
|
2905
|
+
description: "Re-indexes only the content that has changed since the last build (defaults to false). Not currently supported for separate content repos."
|
|
2906
|
+
});
|
|
2907
|
+
tinaGraphQLVersion = Option3.String("--tina-graphql-version", {
|
|
2908
|
+
description: "Specify the version of @tinacms/graphql to use (defaults to latest)"
|
|
2909
|
+
});
|
|
2910
|
+
/**
|
|
2911
|
+
* 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
|
|
2912
|
+
*/
|
|
2913
|
+
skipCloudChecks = Option3.Boolean("--skip-cloud-checks", false, {
|
|
2914
|
+
description: "Skips checking the provided cloud config."
|
|
2915
|
+
});
|
|
2916
|
+
skipSearchIndex = Option3.Boolean("--skip-search-index", false, {
|
|
2917
|
+
description: "Skip indexing the site for search"
|
|
2918
|
+
});
|
|
2919
|
+
upstreamBranch = Option3.String("--upstream-branch", {
|
|
2920
|
+
description: "Optional upstream branch with the schema. If not specified, default will be used."
|
|
2921
|
+
});
|
|
2922
|
+
previewBaseBranch = Option3.String("--preview-base-branch", {
|
|
2923
|
+
description: "The base branch for the preview"
|
|
2924
|
+
});
|
|
2925
|
+
previewName = Option3.String("--preview-name", {
|
|
2926
|
+
description: "The name of the preview branch"
|
|
2927
|
+
});
|
|
2928
|
+
noClientBuildCache = Option3.Boolean("--no-client-build-cache", false, {
|
|
2929
|
+
description: "Disables the client build cache"
|
|
2930
|
+
});
|
|
2931
|
+
static usage = Command3.Usage({
|
|
2932
|
+
category: `Commands`,
|
|
2933
|
+
description: `Build the CMS and autogenerated modules for usage with TinaCloud`
|
|
2934
|
+
});
|
|
2852
2935
|
async catch(error) {
|
|
2853
2936
|
console.error(error);
|
|
2854
2937
|
process.exit(1);
|
|
@@ -2893,7 +2976,7 @@ ${dangerText(e.message)}`);
|
|
|
2893
2976
|
configManager,
|
|
2894
2977
|
Number(this.datalayerPort)
|
|
2895
2978
|
);
|
|
2896
|
-
const { queryDoc, fragDoc, graphQLSchema, tinaSchema, lookup } = await (
|
|
2979
|
+
const { queryDoc, fragDoc, graphQLSchema, tinaSchema, lookup } = await buildSchema2(configManager.config);
|
|
2897
2980
|
const codegen2 = new Codegen({
|
|
2898
2981
|
configManager,
|
|
2899
2982
|
port: this.localOption ? Number(this.port) : void 0,
|
|
@@ -3001,7 +3084,7 @@ ${dangerText(e.message)}
|
|
|
3001
3084
|
}
|
|
3002
3085
|
}
|
|
3003
3086
|
await buildProductionSpa(configManager, database, codegen2.productionUrl);
|
|
3004
|
-
await
|
|
3087
|
+
await fs8.outputFile(
|
|
3005
3088
|
configManager.outputGitignorePath,
|
|
3006
3089
|
"index.html\nassets/"
|
|
3007
3090
|
);
|
|
@@ -3033,7 +3116,7 @@ ${dangerText(e.message)}
|
|
|
3033
3116
|
"indexerToken not configured in tina search configuration."
|
|
3034
3117
|
);
|
|
3035
3118
|
}
|
|
3036
|
-
client = new
|
|
3119
|
+
client = new TinaCMSSearchIndexClient({
|
|
3037
3120
|
apiUrl: `${configManager.config.tinaioConfig?.contentApiUrlOverride || "https://content.tinajs.io"}/searchIndex/${configManager.config?.clientId}`,
|
|
3038
3121
|
branch: configManager.config?.branch,
|
|
3039
3122
|
indexerToken: configManager.config?.search?.tina?.indexerToken,
|
|
@@ -3042,9 +3125,9 @@ ${dangerText(e.message)}
|
|
|
3042
3125
|
} else {
|
|
3043
3126
|
client = configManager.config?.search?.searchClient;
|
|
3044
3127
|
}
|
|
3045
|
-
const searchIndexer = new
|
|
3128
|
+
const searchIndexer = new SearchIndexer2({
|
|
3046
3129
|
batchSize: configManager.config.search?.indexBatchSize || 100,
|
|
3047
|
-
bridge: new
|
|
3130
|
+
bridge: new FilesystemBridge3(
|
|
3048
3131
|
configManager.rootPath,
|
|
3049
3132
|
configManager.contentRootPath
|
|
3050
3133
|
),
|
|
@@ -3114,8 +3197,8 @@ ${dangerText(e.message)}
|
|
|
3114
3197
|
const MAX_RETRIES = 5;
|
|
3115
3198
|
const { config: config2 } = configManager;
|
|
3116
3199
|
const token = config2.token;
|
|
3117
|
-
const { clientId, branch, host } = (
|
|
3118
|
-
const bar2 = new
|
|
3200
|
+
const { clientId, branch, host } = parseURL2(apiURL);
|
|
3201
|
+
const bar2 = new Progress2("Checking clientId and token. :prog", 1);
|
|
3119
3202
|
const getBranchInfo = async () => {
|
|
3120
3203
|
const url = `https://${host}/db/${clientId}/status/${previewBaseBranch || branch}`;
|
|
3121
3204
|
const branchInfo2 = {
|
|
@@ -3169,7 +3252,7 @@ ${dangerText(e.message)}
|
|
|
3169
3252
|
bar2.tick({
|
|
3170
3253
|
prog: "\u2705"
|
|
3171
3254
|
});
|
|
3172
|
-
const branchBar = new
|
|
3255
|
+
const branchBar = new Progress2(
|
|
3173
3256
|
`Checking branch '${config2.branch}' is on TinaCloud. :prog`,
|
|
3174
3257
|
1
|
|
3175
3258
|
);
|
|
@@ -3209,7 +3292,7 @@ ${dangerText(e.message)}
|
|
|
3209
3292
|
async syncProject(configManager, apiURL, options) {
|
|
3210
3293
|
const { config: config2 } = configManager;
|
|
3211
3294
|
const token = config2.token;
|
|
3212
|
-
const { clientId, branch, host } = (
|
|
3295
|
+
const { clientId, branch, host } = parseURL2(apiURL);
|
|
3213
3296
|
const { previewName, previewBaseBranch, upstreamBranch } = options || {};
|
|
3214
3297
|
let url = `https://${host}/db/${clientId}/reset/${branch}?refreshSchema=true&skipIfSchemaCurrent=true`;
|
|
3215
3298
|
if (upstreamBranch && previewBaseBranch && previewName) {
|
|
@@ -3219,7 +3302,7 @@ ${dangerText(e.message)}
|
|
|
3219
3302
|
} else if (upstreamBranch && !previewBaseBranch && !previewName) {
|
|
3220
3303
|
url = `https://${host}/db/${clientId}/reset/${branch}?refreshSchema=true&skipIfSchemaCurrent=true&upstreamBranch=${upstreamBranch}`;
|
|
3221
3304
|
}
|
|
3222
|
-
const bar2 = new
|
|
3305
|
+
const bar2 = new Progress2("Syncing Project. :prog", 1);
|
|
3223
3306
|
try {
|
|
3224
3307
|
const res = await request({
|
|
3225
3308
|
token,
|
|
@@ -3260,7 +3343,7 @@ ${dangerText(e.message)}
|
|
|
3260
3343
|
}
|
|
3261
3344
|
}
|
|
3262
3345
|
async checkGraphqlSchema(configManager, database, apiURL, timestamp) {
|
|
3263
|
-
const bar2 = new
|
|
3346
|
+
const bar2 = new Progress2(
|
|
3264
3347
|
"Checking local GraphQL Schema matches server. :prog",
|
|
3265
3348
|
1
|
|
3266
3349
|
);
|
|
@@ -3282,11 +3365,11 @@ Additional info: Branch: ${config2.branch}, Client ID: ${config2.clientId} `;
|
|
|
3282
3365
|
}
|
|
3283
3366
|
throw new Error(errorMessage);
|
|
3284
3367
|
}
|
|
3285
|
-
const remoteGqlSchema =
|
|
3368
|
+
const remoteGqlSchema = buildClientSchema(remoteSchema);
|
|
3286
3369
|
const localSchemaDocument = await database.getGraphQLSchemaFromBridge();
|
|
3287
|
-
const localGraphqlSchema = (
|
|
3370
|
+
const localGraphqlSchema = buildASTSchema2(localSchemaDocument);
|
|
3288
3371
|
try {
|
|
3289
|
-
const diffResult = await
|
|
3372
|
+
const diffResult = await diff(remoteGqlSchema, localGraphqlSchema);
|
|
3290
3373
|
if (diffResult.length === 0) {
|
|
3291
3374
|
bar2.tick({
|
|
3292
3375
|
prog: "\u2705"
|
|
@@ -3334,13 +3417,13 @@ Additional info:
|
|
|
3334
3417
|
}
|
|
3335
3418
|
}
|
|
3336
3419
|
async checkTinaSchema(configManager, database, apiURL, previewName, verbose, timestamp) {
|
|
3337
|
-
const bar2 = new
|
|
3420
|
+
const bar2 = new Progress2(
|
|
3338
3421
|
"Checking local Tina Schema matches server. :prog",
|
|
3339
3422
|
1
|
|
3340
3423
|
);
|
|
3341
3424
|
const { config: config2 } = configManager;
|
|
3342
3425
|
const token = config2.token;
|
|
3343
|
-
const { clientId, branch, isLocalClient, host } = (
|
|
3426
|
+
const { clientId, branch, isLocalClient, host } = parseURL2(apiURL);
|
|
3344
3427
|
if (isLocalClient || !host || !clientId || !branch) {
|
|
3345
3428
|
if (verbose) {
|
|
3346
3429
|
logger.info(logText("Not using TinaCloud, skipping Tina Schema check"));
|
|
@@ -3368,11 +3451,11 @@ Additional info: Branch: ${config2.branch}, Client ID: ${config2.clientId} `;
|
|
|
3368
3451
|
}
|
|
3369
3452
|
const localTinaSchema = JSON.parse(
|
|
3370
3453
|
await database.bridge.get(
|
|
3371
|
-
|
|
3454
|
+
path9.join(database.tinaDirectory, "__generated__", "_schema.json")
|
|
3372
3455
|
)
|
|
3373
3456
|
);
|
|
3374
3457
|
localTinaSchema.version = void 0;
|
|
3375
|
-
const localTinaSchemaSha =
|
|
3458
|
+
const localTinaSchemaSha = crypto.createHash("sha256").update(JSON.stringify(localTinaSchema)).digest("hex");
|
|
3376
3459
|
if (localTinaSchemaSha === remoteTinaSchemaSha) {
|
|
3377
3460
|
bar2.tick({
|
|
3378
3461
|
prog: "\u2705"
|
|
@@ -3423,12 +3506,12 @@ async function request(args) {
|
|
|
3423
3506
|
Message from server: ${json.message}`;
|
|
3424
3507
|
}
|
|
3425
3508
|
throw new Error(
|
|
3426
|
-
`Server responded with status code ${res.status}, ${res.statusText}. ${additionalInfo ? additionalInfo : ""} Please see our FAQ for more information: https://tina.io/docs/
|
|
3509
|
+
`Server responded with status code ${res.status}, ${res.statusText}. ${additionalInfo ? additionalInfo : ""} Please see our FAQ for more information: https://tina.io/docs/r/FAQ/`
|
|
3427
3510
|
);
|
|
3428
3511
|
}
|
|
3429
3512
|
if (json.errors) {
|
|
3430
3513
|
throw new Error(
|
|
3431
|
-
`Unable to fetch, please see our FAQ for more information: https://tina.io/docs/
|
|
3514
|
+
`Unable to fetch, please see our FAQ for more information: https://tina.io/docs/r/FAQ/
|
|
3432
3515
|
|
|
3433
3516
|
Errors:
|
|
3434
3517
|
${json.errors.map((error) => error.message).join("\n")}`
|
|
@@ -3450,7 +3533,7 @@ var fetchRemoteGraphqlSchema = async ({
|
|
|
3450
3533
|
headers.append("X-API-KEY", token);
|
|
3451
3534
|
}
|
|
3452
3535
|
const body = JSON.stringify({
|
|
3453
|
-
query:
|
|
3536
|
+
query: getIntrospectionQuery(),
|
|
3454
3537
|
variables: {}
|
|
3455
3538
|
});
|
|
3456
3539
|
headers.append("Content-Type", "application/json");
|
|
@@ -3483,14 +3566,14 @@ var fetchSchemaSha = async ({
|
|
|
3483
3566
|
};
|
|
3484
3567
|
|
|
3485
3568
|
// src/next/commands/audit-command/index.ts
|
|
3486
|
-
|
|
3487
|
-
|
|
3569
|
+
import { Command as Command4, Option as Option4 } from "clipanion";
|
|
3570
|
+
import { buildSchema as buildSchema3 } from "@tinacms/graphql";
|
|
3488
3571
|
|
|
3489
3572
|
// src/next/commands/audit-command/audit.ts
|
|
3490
|
-
|
|
3491
|
-
|
|
3492
|
-
|
|
3493
|
-
|
|
3573
|
+
import prompts from "prompts";
|
|
3574
|
+
import { Telemetry } from "@tinacms/metrics";
|
|
3575
|
+
import { resolve } from "@tinacms/graphql";
|
|
3576
|
+
import chalk5 from "chalk";
|
|
3494
3577
|
var audit = async ({
|
|
3495
3578
|
database,
|
|
3496
3579
|
clean,
|
|
@@ -3498,7 +3581,7 @@ var audit = async ({
|
|
|
3498
3581
|
noTelemetry,
|
|
3499
3582
|
verbose
|
|
3500
3583
|
}) => {
|
|
3501
|
-
const telemetry = new
|
|
3584
|
+
const telemetry = new Telemetry({ disabled: noTelemetry });
|
|
3502
3585
|
await telemetry.submitRecord({
|
|
3503
3586
|
event: {
|
|
3504
3587
|
name: "tinacms:cli:audit:invoke",
|
|
@@ -3508,25 +3591,25 @@ var audit = async ({
|
|
|
3508
3591
|
});
|
|
3509
3592
|
if (clean) {
|
|
3510
3593
|
logger.info(
|
|
3511
|
-
`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 ${
|
|
3594
|
+
`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(
|
|
3512
3595
|
"clean git tree"
|
|
3513
3596
|
)} so unwanted changes can be undone.
|
|
3514
3597
|
|
|
3515
3598
|
`
|
|
3516
3599
|
);
|
|
3517
|
-
const res = await (
|
|
3600
|
+
const res = await prompts({
|
|
3518
3601
|
name: "useClean",
|
|
3519
3602
|
type: "confirm",
|
|
3520
3603
|
message: `Do you want to continue?`
|
|
3521
3604
|
});
|
|
3522
3605
|
if (!res.useClean) {
|
|
3523
|
-
logger.warn(
|
|
3606
|
+
logger.warn(chalk5.yellowBright("\u26A0\uFE0F Audit not complete"));
|
|
3524
3607
|
process.exit(0);
|
|
3525
3608
|
}
|
|
3526
3609
|
}
|
|
3527
3610
|
if (useDefaultValues && !clean) {
|
|
3528
3611
|
logger.warn(
|
|
3529
|
-
|
|
3612
|
+
chalk5.yellowBright(
|
|
3530
3613
|
"WARNING: using the `--useDefaultValues` without the `--clean` flag has no effect. Please re-run audit and add the `--clean` flag"
|
|
3531
3614
|
)
|
|
3532
3615
|
);
|
|
@@ -3554,10 +3637,10 @@ var audit = async ({
|
|
|
3554
3637
|
}
|
|
3555
3638
|
if (error) {
|
|
3556
3639
|
logger.error(
|
|
3557
|
-
|
|
3640
|
+
chalk5.redBright(`\u203C\uFE0F Audit ${chalk5.bold("failed")} with errors`)
|
|
3558
3641
|
);
|
|
3559
3642
|
} else {
|
|
3560
|
-
logger.info(
|
|
3643
|
+
logger.info(chalk5.greenBright("\u2705 Audit passed"));
|
|
3561
3644
|
}
|
|
3562
3645
|
};
|
|
3563
3646
|
var auditDocuments = async (args) => {
|
|
@@ -3574,7 +3657,7 @@ var auditDocuments = async (args) => {
|
|
|
3574
3657
|
}
|
|
3575
3658
|
}
|
|
3576
3659
|
}`;
|
|
3577
|
-
const docResult = await
|
|
3660
|
+
const docResult = await resolve({
|
|
3578
3661
|
database,
|
|
3579
3662
|
query: documentQuery,
|
|
3580
3663
|
variables: {},
|
|
@@ -3585,11 +3668,11 @@ var auditDocuments = async (args) => {
|
|
|
3585
3668
|
if (docResult.errors) {
|
|
3586
3669
|
error = true;
|
|
3587
3670
|
docResult.errors.forEach((err) => {
|
|
3588
|
-
logger.error(
|
|
3671
|
+
logger.error(chalk5.red(err.message));
|
|
3589
3672
|
if (err.originalError.originalError) {
|
|
3590
3673
|
logger.error(
|
|
3591
3674
|
// @ts-ignore FIXME: this doesn't seem right
|
|
3592
|
-
|
|
3675
|
+
chalk5.red(` ${err.originalError.originalError.message}`)
|
|
3593
3676
|
);
|
|
3594
3677
|
}
|
|
3595
3678
|
});
|
|
@@ -3616,7 +3699,7 @@ var auditDocuments = async (args) => {
|
|
|
3616
3699
|
params: $params
|
|
3617
3700
|
){__typename}
|
|
3618
3701
|
}`;
|
|
3619
|
-
const mutationRes = await
|
|
3702
|
+
const mutationRes = await resolve({
|
|
3620
3703
|
database,
|
|
3621
3704
|
query: mutation,
|
|
3622
3705
|
variables: {
|
|
@@ -3631,7 +3714,7 @@ var auditDocuments = async (args) => {
|
|
|
3631
3714
|
if (mutationRes.errors) {
|
|
3632
3715
|
mutationRes.errors.forEach((err) => {
|
|
3633
3716
|
error = true;
|
|
3634
|
-
logger.error(
|
|
3717
|
+
logger.error(chalk5.red(err.message));
|
|
3635
3718
|
});
|
|
3636
3719
|
}
|
|
3637
3720
|
}
|
|
@@ -3648,38 +3731,31 @@ function filterObject(obj) {
|
|
|
3648
3731
|
}
|
|
3649
3732
|
|
|
3650
3733
|
// src/next/commands/audit-command/index.ts
|
|
3651
|
-
|
|
3652
|
-
var AuditCommand = class extends
|
|
3653
|
-
|
|
3654
|
-
|
|
3655
|
-
|
|
3656
|
-
|
|
3657
|
-
|
|
3658
|
-
|
|
3659
|
-
|
|
3660
|
-
|
|
3661
|
-
|
|
3662
|
-
|
|
3663
|
-
|
|
3664
|
-
|
|
3665
|
-
|
|
3666
|
-
|
|
3667
|
-
|
|
3668
|
-
|
|
3669
|
-
|
|
3670
|
-
|
|
3671
|
-
|
|
3672
|
-
|
|
3673
|
-
|
|
3674
|
-
|
|
3675
|
-
|
|
3676
|
-
}
|
|
3677
|
-
static {
|
|
3678
|
-
this.usage = import_clipanion4.Command.Usage({
|
|
3679
|
-
category: `Commands`,
|
|
3680
|
-
description: `Audit config and content files`
|
|
3681
|
-
});
|
|
3682
|
-
}
|
|
3734
|
+
import { AuditFileSystemBridge } from "@tinacms/graphql";
|
|
3735
|
+
var AuditCommand = class extends Command4 {
|
|
3736
|
+
static paths = [["audit"]];
|
|
3737
|
+
rootPath = Option4.String("--rootPath", {
|
|
3738
|
+
description: "Specify the root directory to run the CLI from"
|
|
3739
|
+
});
|
|
3740
|
+
verbose = Option4.Boolean("-v,--verbose", false, {
|
|
3741
|
+
description: "increase verbosity of logged output"
|
|
3742
|
+
});
|
|
3743
|
+
clean = Option4.Boolean("--clean", false, {
|
|
3744
|
+
description: "Clean the output"
|
|
3745
|
+
});
|
|
3746
|
+
useDefaultValues = Option4.Boolean("--useDefaultValues", false, {
|
|
3747
|
+
description: "When cleaning the output, use defaults on the config"
|
|
3748
|
+
});
|
|
3749
|
+
noTelemetry = Option4.Boolean("--noTelemetry", false, {
|
|
3750
|
+
description: "Disable anonymous telemetry that is collected"
|
|
3751
|
+
});
|
|
3752
|
+
datalayerPort = Option4.String("--datalayer-port", "9000", {
|
|
3753
|
+
description: "Specify a port to run the datalayer server on. (default 9000)"
|
|
3754
|
+
});
|
|
3755
|
+
static usage = Command4.Usage({
|
|
3756
|
+
category: `Commands`,
|
|
3757
|
+
description: `Audit config and content files`
|
|
3758
|
+
});
|
|
3683
3759
|
async catch(error) {
|
|
3684
3760
|
logger.error("Error occured during tinacms audit");
|
|
3685
3761
|
if (this.verbose) {
|
|
@@ -3700,9 +3776,9 @@ var AuditCommand = class extends import_clipanion4.Command {
|
|
|
3700
3776
|
const database = await createAndInitializeDatabase(
|
|
3701
3777
|
configManager,
|
|
3702
3778
|
Number(this.datalayerPort),
|
|
3703
|
-
this.clean ? void 0 : new
|
|
3779
|
+
this.clean ? void 0 : new AuditFileSystemBridge(configManager.rootPath)
|
|
3704
3780
|
);
|
|
3705
|
-
const { tinaSchema, graphQLSchema, lookup } = await (
|
|
3781
|
+
const { tinaSchema, graphQLSchema, lookup } = await buildSchema3(
|
|
3706
3782
|
configManager.config
|
|
3707
3783
|
);
|
|
3708
3784
|
const warnings = [];
|
|
@@ -3735,29 +3811,29 @@ var AuditCommand = class extends import_clipanion4.Command {
|
|
|
3735
3811
|
};
|
|
3736
3812
|
|
|
3737
3813
|
// src/next/commands/init-command/index.ts
|
|
3738
|
-
|
|
3814
|
+
import { Command as Command6, Option as Option6 } from "clipanion";
|
|
3739
3815
|
|
|
3740
3816
|
// src/cmds/init/detectEnvironment.ts
|
|
3741
|
-
|
|
3742
|
-
|
|
3817
|
+
import fs9 from "fs-extra";
|
|
3818
|
+
import path10 from "path";
|
|
3743
3819
|
var checkGitignoreForItem = async ({
|
|
3744
3820
|
baseDir,
|
|
3745
3821
|
line
|
|
3746
3822
|
}) => {
|
|
3747
|
-
const gitignoreContent =
|
|
3823
|
+
const gitignoreContent = fs9.readFileSync(path10.join(baseDir, ".gitignore")).toString();
|
|
3748
3824
|
return gitignoreContent.split("\n").some((item) => item === line);
|
|
3749
3825
|
};
|
|
3750
3826
|
var makeGeneratedFile = async (name2, generatedFileType, parentPath, opts) => {
|
|
3751
3827
|
const result = {
|
|
3752
|
-
fullPathTS:
|
|
3828
|
+
fullPathTS: path10.join(
|
|
3753
3829
|
parentPath,
|
|
3754
3830
|
`${name2}.${opts?.typescriptSuffix || opts?.extensionOverride || "ts"}`
|
|
3755
3831
|
),
|
|
3756
|
-
fullPathJS:
|
|
3832
|
+
fullPathJS: path10.join(
|
|
3757
3833
|
parentPath,
|
|
3758
3834
|
`${name2}.${opts?.extensionOverride || "js"}`
|
|
3759
3835
|
),
|
|
3760
|
-
fullPathOverride: opts?.extensionOverride ?
|
|
3836
|
+
fullPathOverride: opts?.extensionOverride ? path10.join(parentPath, `${name2}.${opts?.extensionOverride}`) : "",
|
|
3761
3837
|
generatedFileType,
|
|
3762
3838
|
name: name2,
|
|
3763
3839
|
parentPath,
|
|
@@ -3775,8 +3851,8 @@ var makeGeneratedFile = async (name2, generatedFileType, parentPath, opts) => {
|
|
|
3775
3851
|
};
|
|
3776
3852
|
}
|
|
3777
3853
|
};
|
|
3778
|
-
result.typescriptExists = await
|
|
3779
|
-
result.javascriptExists = await
|
|
3854
|
+
result.typescriptExists = await fs9.pathExists(result.fullPathTS);
|
|
3855
|
+
result.javascriptExists = await fs9.pathExists(result.fullPathJS);
|
|
3780
3856
|
return result;
|
|
3781
3857
|
};
|
|
3782
3858
|
var detectEnvironment = async ({
|
|
@@ -3785,21 +3861,21 @@ var detectEnvironment = async ({
|
|
|
3785
3861
|
rootPath,
|
|
3786
3862
|
debug = false
|
|
3787
3863
|
}) => {
|
|
3788
|
-
const hasForestryConfig = await
|
|
3789
|
-
|
|
3864
|
+
const hasForestryConfig = await fs9.pathExists(
|
|
3865
|
+
path10.join(pathToForestryConfig, ".forestry", "settings.yml")
|
|
3790
3866
|
);
|
|
3791
|
-
const sampleContentPath =
|
|
3867
|
+
const sampleContentPath = path10.join(
|
|
3792
3868
|
baseDir,
|
|
3793
3869
|
"content",
|
|
3794
3870
|
"posts",
|
|
3795
3871
|
"hello-world.md"
|
|
3796
3872
|
);
|
|
3797
|
-
const usingSrc =
|
|
3798
|
-
const tinaFolder =
|
|
3873
|
+
const usingSrc = fs9.pathExistsSync(path10.join(baseDir, "src")) && (fs9.pathExistsSync(path10.join(baseDir, "src", "app")) || fs9.pathExistsSync(path10.join(baseDir, "src", "pages")));
|
|
3874
|
+
const tinaFolder = path10.join(baseDir, "tina");
|
|
3799
3875
|
const tinaConfigExists = Boolean(
|
|
3800
3876
|
// Does the tina folder exist?
|
|
3801
|
-
await
|
|
3802
|
-
(await
|
|
3877
|
+
await fs9.pathExists(tinaFolder) && // Does the tina folder contain a config file?
|
|
3878
|
+
(await fs9.readdir(tinaFolder)).find((x) => x.includes("config"))
|
|
3803
3879
|
);
|
|
3804
3880
|
const pagesDir = [baseDir, usingSrc ? "src" : false, "pages"].filter(
|
|
3805
3881
|
Boolean
|
|
@@ -3811,12 +3887,12 @@ var detectEnvironment = async ({
|
|
|
3811
3887
|
"next-api-handler": await makeGeneratedFile(
|
|
3812
3888
|
"[...routes]",
|
|
3813
3889
|
"next-api-handler",
|
|
3814
|
-
|
|
3890
|
+
path10.join(...pagesDir, "api", "tina")
|
|
3815
3891
|
),
|
|
3816
3892
|
"reactive-example": await makeGeneratedFile(
|
|
3817
3893
|
"[filename]",
|
|
3818
3894
|
"reactive-example",
|
|
3819
|
-
|
|
3895
|
+
path10.join(...pagesDir, "demo", "blog"),
|
|
3820
3896
|
{
|
|
3821
3897
|
typescriptSuffix: "tsx"
|
|
3822
3898
|
}
|
|
@@ -3824,22 +3900,22 @@ var detectEnvironment = async ({
|
|
|
3824
3900
|
"users-json": await makeGeneratedFile(
|
|
3825
3901
|
"index",
|
|
3826
3902
|
"users-json",
|
|
3827
|
-
|
|
3903
|
+
path10.join(baseDir, "content", "users"),
|
|
3828
3904
|
{ extensionOverride: "json" }
|
|
3829
3905
|
),
|
|
3830
3906
|
"sample-content": await makeGeneratedFile(
|
|
3831
3907
|
"hello-world",
|
|
3832
3908
|
"sample-content",
|
|
3833
|
-
|
|
3909
|
+
path10.join(baseDir, "content", "posts"),
|
|
3834
3910
|
{ extensionOverride: "md" }
|
|
3835
3911
|
)
|
|
3836
3912
|
};
|
|
3837
|
-
const hasSampleContent = await
|
|
3838
|
-
const hasPackageJSON = await
|
|
3913
|
+
const hasSampleContent = await fs9.pathExists(sampleContentPath);
|
|
3914
|
+
const hasPackageJSON = await fs9.pathExists("package.json");
|
|
3839
3915
|
let hasTinaDeps = false;
|
|
3840
3916
|
if (hasPackageJSON) {
|
|
3841
3917
|
try {
|
|
3842
|
-
const packageJSON = await
|
|
3918
|
+
const packageJSON = await fs9.readJSON("package.json");
|
|
3843
3919
|
const deps = [];
|
|
3844
3920
|
if (packageJSON?.dependencies) {
|
|
3845
3921
|
deps.push(...Object.keys(packageJSON.dependencies));
|
|
@@ -3856,15 +3932,15 @@ var detectEnvironment = async ({
|
|
|
3856
3932
|
);
|
|
3857
3933
|
}
|
|
3858
3934
|
}
|
|
3859
|
-
const hasGitIgnore = await
|
|
3935
|
+
const hasGitIgnore = await fs9.pathExists(path10.join(".gitignore"));
|
|
3860
3936
|
const hasGitIgnoreNodeModules = hasGitIgnore && await checkGitignoreForItem({ baseDir, line: "node_modules" });
|
|
3861
3937
|
const hasEnvTina = hasGitIgnore && await checkGitignoreForItem({ baseDir, line: ".env.tina" });
|
|
3862
3938
|
const hasGitIgnoreEnv = hasGitIgnore && await checkGitignoreForItem({ baseDir, line: ".env" });
|
|
3863
3939
|
let frontMatterFormat;
|
|
3864
3940
|
if (hasForestryConfig) {
|
|
3865
|
-
const hugoConfigPath =
|
|
3866
|
-
if (await
|
|
3867
|
-
const hugoConfig = await
|
|
3941
|
+
const hugoConfigPath = path10.join(rootPath, "config.toml");
|
|
3942
|
+
if (await fs9.pathExists(hugoConfigPath)) {
|
|
3943
|
+
const hugoConfig = await fs9.readFile(hugoConfigPath, "utf8");
|
|
3868
3944
|
const metaDataFormat = hugoConfig.toString().match(/metaDataFormat = "(.*)"/)?.[1];
|
|
3869
3945
|
if (metaDataFormat && (metaDataFormat === "yaml" || metaDataFormat === "toml" || metaDataFormat === "json")) {
|
|
3870
3946
|
frontMatterFormat = metaDataFormat;
|
|
@@ -3895,10 +3971,10 @@ var detectEnvironment = async ({
|
|
|
3895
3971
|
var detectEnvironment_default = detectEnvironment;
|
|
3896
3972
|
|
|
3897
3973
|
// src/cmds/init/prompts/index.ts
|
|
3898
|
-
|
|
3974
|
+
import prompts6 from "prompts";
|
|
3899
3975
|
|
|
3900
3976
|
// src/cmds/init/prompts/askTinaCloudSetup.ts
|
|
3901
|
-
|
|
3977
|
+
import prompts2 from "prompts";
|
|
3902
3978
|
var tinaCloudSetupQuestions = [
|
|
3903
3979
|
{
|
|
3904
3980
|
name: "clientId",
|
|
@@ -3920,7 +3996,7 @@ ${logText(
|
|
|
3920
3996
|
}
|
|
3921
3997
|
];
|
|
3922
3998
|
var askTinaCloudSetup = async ({ config: config2 }) => {
|
|
3923
|
-
const { clientId, token } = await (
|
|
3999
|
+
const { clientId, token } = await prompts2(tinaCloudSetupQuestions);
|
|
3924
4000
|
config2.envVars.push(
|
|
3925
4001
|
{
|
|
3926
4002
|
key: "NEXT_PUBLIC_TINA_CLIENT_ID",
|
|
@@ -3934,7 +4010,7 @@ var askTinaCloudSetup = async ({ config: config2 }) => {
|
|
|
3934
4010
|
};
|
|
3935
4011
|
|
|
3936
4012
|
// src/cmds/init/prompts/gitProvider.ts
|
|
3937
|
-
|
|
4013
|
+
import prompts3 from "prompts";
|
|
3938
4014
|
var supportedGitProviders = {
|
|
3939
4015
|
github: {
|
|
3940
4016
|
imports: [
|
|
@@ -3956,7 +4032,7 @@ var supportedGitProviders = {
|
|
|
3956
4032
|
}
|
|
3957
4033
|
};
|
|
3958
4034
|
var chooseGitProvider = async ({ config: config2 }) => {
|
|
3959
|
-
const result = await (
|
|
4035
|
+
const result = await prompts3([
|
|
3960
4036
|
{
|
|
3961
4037
|
name: "githubToken",
|
|
3962
4038
|
type: "text",
|
|
@@ -3964,7 +4040,7 @@ var chooseGitProvider = async ({ config: config2 }) => {
|
|
|
3964
4040
|
${logText(
|
|
3965
4041
|
"Learn more here: "
|
|
3966
4042
|
)}${linkText(
|
|
3967
|
-
"https://tina.io/docs/self-
|
|
4043
|
+
"https://tina.io/docs/r/self-hosting-nextjs/#github-personal-access-token"
|
|
3968
4044
|
)}`,
|
|
3969
4045
|
initial: process.env.GITHUB_PERSONAL_ACCESS_TOKEN
|
|
3970
4046
|
},
|
|
@@ -4001,7 +4077,7 @@ ${logText(
|
|
|
4001
4077
|
};
|
|
4002
4078
|
|
|
4003
4079
|
// src/cmds/init/prompts/databaseAdapter.ts
|
|
4004
|
-
|
|
4080
|
+
import prompts4 from "prompts";
|
|
4005
4081
|
var supportedDatabaseAdapters = {
|
|
4006
4082
|
["upstash-redis"]: {
|
|
4007
4083
|
databaseAdapterClassText: `new RedisLevel({
|
|
@@ -4047,7 +4123,7 @@ var databaseAdapterUpdateConfig = {
|
|
|
4047
4123
|
other: async (_args) => {
|
|
4048
4124
|
},
|
|
4049
4125
|
mongodb: async ({ config: config2 }) => {
|
|
4050
|
-
const result = await (
|
|
4126
|
+
const result = await prompts4([
|
|
4051
4127
|
{
|
|
4052
4128
|
name: "mongoDBUri",
|
|
4053
4129
|
type: "text",
|
|
@@ -4062,7 +4138,7 @@ var databaseAdapterUpdateConfig = {
|
|
|
4062
4138
|
});
|
|
4063
4139
|
},
|
|
4064
4140
|
"upstash-redis": async ({ config: config2 }) => {
|
|
4065
|
-
const result = await (
|
|
4141
|
+
const result = await prompts4([
|
|
4066
4142
|
{
|
|
4067
4143
|
name: "kvRestApiUrl",
|
|
4068
4144
|
type: "text",
|
|
@@ -4093,7 +4169,7 @@ var chooseDatabaseAdapter = async ({
|
|
|
4093
4169
|
framework,
|
|
4094
4170
|
config: config2
|
|
4095
4171
|
}) => {
|
|
4096
|
-
const answers = await (
|
|
4172
|
+
const answers = await prompts4([
|
|
4097
4173
|
{
|
|
4098
4174
|
name: "dataLayerAdapter",
|
|
4099
4175
|
message: "Select a self-hosted Database Adapter",
|
|
@@ -4123,8 +4199,8 @@ var chooseDatabaseAdapter = async ({
|
|
|
4123
4199
|
};
|
|
4124
4200
|
|
|
4125
4201
|
// src/cmds/init/prompts/authProvider.ts
|
|
4126
|
-
|
|
4127
|
-
|
|
4202
|
+
import crypto2 from "crypto-js";
|
|
4203
|
+
import prompts5 from "prompts";
|
|
4128
4204
|
var supportedAuthProviders = {
|
|
4129
4205
|
other: {
|
|
4130
4206
|
name: "other"
|
|
@@ -4173,12 +4249,12 @@ var authProviderUpdateConfig = {
|
|
|
4173
4249
|
},
|
|
4174
4250
|
"tina-cloud": askTinaCloudSetup,
|
|
4175
4251
|
"next-auth": async ({ config: config2 }) => {
|
|
4176
|
-
const result = await (
|
|
4252
|
+
const result = await prompts5([
|
|
4177
4253
|
{
|
|
4178
4254
|
name: "nextAuthSecret",
|
|
4179
4255
|
type: "text",
|
|
4180
4256
|
message: `What is the NextAuth.js Secret? (Hit enter to use a randomly generated secret)`,
|
|
4181
|
-
initial: process.env.NEXTAUTH_SECRET ||
|
|
4257
|
+
initial: process.env.NEXTAUTH_SECRET || crypto2.lib.WordArray.random(16).toString()
|
|
4182
4258
|
}
|
|
4183
4259
|
]);
|
|
4184
4260
|
config2.envVars.push({
|
|
@@ -4203,7 +4279,7 @@ var forestryDisclaimer = logText(
|
|
|
4203
4279
|
`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)`
|
|
4204
4280
|
);
|
|
4205
4281
|
var askCommonSetUp = async () => {
|
|
4206
|
-
const answers = await (
|
|
4282
|
+
const answers = await prompts6([
|
|
4207
4283
|
{
|
|
4208
4284
|
name: "framework",
|
|
4209
4285
|
type: "select",
|
|
@@ -4225,7 +4301,8 @@ var askCommonSetUp = async () => {
|
|
|
4225
4301
|
choices: [
|
|
4226
4302
|
{ title: "PNPM", value: "pnpm" },
|
|
4227
4303
|
{ title: "Yarn", value: "yarn" },
|
|
4228
|
-
{ title: "NPM", value: "npm" }
|
|
4304
|
+
{ title: "NPM", value: "npm" },
|
|
4305
|
+
{ title: "Bun", value: "bun" }
|
|
4229
4306
|
]
|
|
4230
4307
|
}
|
|
4231
4308
|
]);
|
|
@@ -4266,7 +4343,7 @@ ${forestryDisclaimer}`
|
|
|
4266
4343
|
message: `What format are you using in your frontmatter?`
|
|
4267
4344
|
});
|
|
4268
4345
|
}
|
|
4269
|
-
const answers = await (
|
|
4346
|
+
const answers = await prompts6(questions);
|
|
4270
4347
|
return answers;
|
|
4271
4348
|
};
|
|
4272
4349
|
var askTinaSetupPrompts = async (params) => {
|
|
@@ -4286,16 +4363,16 @@ var askTinaSetupPrompts = async (params) => {
|
|
|
4286
4363
|
message: `Where are public assets stored? (default: "public")
|
|
4287
4364
|
` + logText(
|
|
4288
4365
|
`Not sure what value to use? Refer to our "Frameworks" doc: ${linkText(
|
|
4289
|
-
"https://tina.io/docs/
|
|
4366
|
+
"https://tina.io/docs/r/framework-guides-overview"
|
|
4290
4367
|
)}`
|
|
4291
4368
|
)
|
|
4292
4369
|
});
|
|
4293
4370
|
}
|
|
4294
|
-
const answers = await (
|
|
4371
|
+
const answers = await prompts6(questions);
|
|
4295
4372
|
return answers;
|
|
4296
4373
|
};
|
|
4297
4374
|
var askIfUsingSelfHosted = async () => {
|
|
4298
|
-
const answers = await (
|
|
4375
|
+
const answers = await prompts6([
|
|
4299
4376
|
{
|
|
4300
4377
|
name: "hosting",
|
|
4301
4378
|
type: "select",
|
|
@@ -4328,20 +4405,20 @@ var makeImportString = (imports) => {
|
|
|
4328
4405
|
};
|
|
4329
4406
|
|
|
4330
4407
|
// src/cmds/init/prompts/generatedFiles.ts
|
|
4331
|
-
|
|
4408
|
+
import prompts7 from "prompts";
|
|
4332
4409
|
var askIfOverride = async ({
|
|
4333
4410
|
generatedFile,
|
|
4334
4411
|
usingTypescript
|
|
4335
4412
|
}) => {
|
|
4336
4413
|
if (usingTypescript) {
|
|
4337
|
-
const result = await (
|
|
4414
|
+
const result = await prompts7({
|
|
4338
4415
|
name: `override`,
|
|
4339
4416
|
type: "confirm",
|
|
4340
4417
|
message: `Found existing file at ${generatedFile.fullPathTS}. Would you like to overwrite?`
|
|
4341
4418
|
});
|
|
4342
4419
|
return Boolean(result.override);
|
|
4343
4420
|
} else {
|
|
4344
|
-
const result = await (
|
|
4421
|
+
const result = await prompts7({
|
|
4345
4422
|
name: `override`,
|
|
4346
4423
|
type: "confirm",
|
|
4347
4424
|
message: `Found existing file at ${generatedFile.fullPathJS}. Would you like to overwrite?`
|
|
@@ -4476,24 +4553,25 @@ var CLICommand = class {
|
|
|
4476
4553
|
};
|
|
4477
4554
|
|
|
4478
4555
|
// src/cmds/init/apply.ts
|
|
4479
|
-
|
|
4556
|
+
import path14 from "path";
|
|
4480
4557
|
|
|
4481
4558
|
// src/cmds/forestry-migrate/index.ts
|
|
4482
|
-
|
|
4483
|
-
|
|
4484
|
-
|
|
4485
|
-
|
|
4486
|
-
|
|
4487
|
-
|
|
4559
|
+
import fs11 from "fs-extra";
|
|
4560
|
+
import path12 from "path";
|
|
4561
|
+
import yaml2 from "js-yaml";
|
|
4562
|
+
import pkg from "minimatch";
|
|
4563
|
+
import { parseFile, stringifyFile } from "@tinacms/graphql";
|
|
4564
|
+
import { CONTENT_FORMATS } from "@tinacms/schema-tools";
|
|
4488
4565
|
|
|
4489
4566
|
// src/cmds/forestry-migrate/util/index.ts
|
|
4490
|
-
|
|
4491
|
-
|
|
4492
|
-
|
|
4493
|
-
|
|
4567
|
+
import fs10 from "fs-extra";
|
|
4568
|
+
import path11 from "path";
|
|
4569
|
+
import yaml from "js-yaml";
|
|
4570
|
+
import z from "zod";
|
|
4494
4571
|
|
|
4495
4572
|
// src/cmds/forestry-migrate/util/errorSingleton.ts
|
|
4496
4573
|
var ErrorSingleton = class _ErrorSingleton {
|
|
4574
|
+
static instance;
|
|
4497
4575
|
/**
|
|
4498
4576
|
* The Singleton's constructor should always be private to prevent direct
|
|
4499
4577
|
* construction calls with the `new` operator.
|
|
@@ -4513,6 +4591,7 @@ var ErrorSingleton = class _ErrorSingleton {
|
|
|
4513
4591
|
}
|
|
4514
4592
|
return _ErrorSingleton.instance;
|
|
4515
4593
|
}
|
|
4594
|
+
collectionNameErrors;
|
|
4516
4595
|
addErrorName(error) {
|
|
4517
4596
|
this.collectionNameErrors.push(error);
|
|
4518
4597
|
}
|
|
@@ -4535,8 +4614,8 @@ var ErrorSingleton = class _ErrorSingleton {
|
|
|
4535
4614
|
};
|
|
4536
4615
|
|
|
4537
4616
|
// src/cmds/forestry-migrate/util/codeTransformer.ts
|
|
4538
|
-
|
|
4539
|
-
|
|
4617
|
+
import { format } from "prettier";
|
|
4618
|
+
import TsParser from "prettier/parser-typescript.js";
|
|
4540
4619
|
var addVariablesToCode = (codeWithTinaPrefix) => {
|
|
4541
4620
|
const code = codeWithTinaPrefix.replace(
|
|
4542
4621
|
/"__TINA_INTERNAL__:::(.*?):::"/g,
|
|
@@ -4573,7 +4652,7 @@ var makeTemplateFile = async ({
|
|
|
4573
4652
|
`export function ${stringifyLabelWithField(
|
|
4574
4653
|
template.templateObj.label
|
|
4575
4654
|
)} (){
|
|
4576
|
-
return ${addVariablesToCode(JSON.stringify(template.fields, null, 2)).code} ${usingTypescript ? "as TinaField[]" : ""}
|
|
4655
|
+
return ${addVariablesToCode(JSON.stringify(template.fields, null, 2)).code} ${usingTypescript ? "as TinaField[]" : ""}
|
|
4577
4656
|
} `
|
|
4578
4657
|
);
|
|
4579
4658
|
}
|
|
@@ -4581,9 +4660,9 @@ var makeTemplateFile = async ({
|
|
|
4581
4660
|
${usingTypescript ? "import type { TinaField } from 'tinacms'" : ""}
|
|
4582
4661
|
${templateCodeText.join("\n")}
|
|
4583
4662
|
`;
|
|
4584
|
-
const formattedCode =
|
|
4663
|
+
const formattedCode = format(templateCode, {
|
|
4585
4664
|
parser: "typescript",
|
|
4586
|
-
plugins: [
|
|
4665
|
+
plugins: [TsParser]
|
|
4587
4666
|
});
|
|
4588
4667
|
return { importStatements, templateCodeText: formattedCode };
|
|
4589
4668
|
};
|
|
@@ -4615,82 +4694,82 @@ var stringifyTemplateName = (name2, template) => {
|
|
|
4615
4694
|
return newName;
|
|
4616
4695
|
}
|
|
4617
4696
|
};
|
|
4618
|
-
var forestryConfigSchema =
|
|
4619
|
-
sections:
|
|
4620
|
-
|
|
4621
|
-
type:
|
|
4622
|
-
|
|
4623
|
-
|
|
4624
|
-
|
|
4625
|
-
|
|
4626
|
-
|
|
4697
|
+
var forestryConfigSchema = z.object({
|
|
4698
|
+
sections: z.array(
|
|
4699
|
+
z.object({
|
|
4700
|
+
type: z.union([
|
|
4701
|
+
z.literal("directory"),
|
|
4702
|
+
z.literal("document"),
|
|
4703
|
+
z.literal("heading"),
|
|
4704
|
+
z.literal("jekyll-pages"),
|
|
4705
|
+
z.literal("jekyll-posts")
|
|
4627
4706
|
]),
|
|
4628
|
-
label:
|
|
4629
|
-
path:
|
|
4630
|
-
match:
|
|
4631
|
-
exclude:
|
|
4632
|
-
create:
|
|
4633
|
-
templates:
|
|
4634
|
-
new_doc_ext:
|
|
4635
|
-
read_only:
|
|
4707
|
+
label: z.string(),
|
|
4708
|
+
path: z.string().optional().nullable(),
|
|
4709
|
+
match: z.string().optional().nullable(),
|
|
4710
|
+
exclude: z.string().optional().nullable(),
|
|
4711
|
+
create: z.union([z.literal("all"), z.literal("documents"), z.literal("none")]).optional(),
|
|
4712
|
+
templates: z.array(z.string()).optional().nullable(),
|
|
4713
|
+
new_doc_ext: z.string().optional().nullable(),
|
|
4714
|
+
read_only: z.boolean().optional().nullable()
|
|
4636
4715
|
})
|
|
4637
4716
|
)
|
|
4638
4717
|
});
|
|
4639
|
-
var forestryFieldWithoutField =
|
|
4718
|
+
var forestryFieldWithoutField = z.object({
|
|
4640
4719
|
// TODO: maybe better type this?
|
|
4641
|
-
type:
|
|
4642
|
-
|
|
4643
|
-
|
|
4644
|
-
|
|
4645
|
-
|
|
4646
|
-
|
|
4647
|
-
|
|
4648
|
-
|
|
4649
|
-
|
|
4650
|
-
|
|
4651
|
-
|
|
4652
|
-
|
|
4653
|
-
|
|
4654
|
-
|
|
4655
|
-
|
|
4656
|
-
|
|
4720
|
+
type: z.union([
|
|
4721
|
+
z.literal("text"),
|
|
4722
|
+
z.literal("datetime"),
|
|
4723
|
+
z.literal("list"),
|
|
4724
|
+
z.literal("file"),
|
|
4725
|
+
z.literal("image_gallery"),
|
|
4726
|
+
z.literal("textarea"),
|
|
4727
|
+
z.literal("tag_list"),
|
|
4728
|
+
z.literal("number"),
|
|
4729
|
+
z.literal("boolean"),
|
|
4730
|
+
z.literal("field_group"),
|
|
4731
|
+
z.literal("field_group_list"),
|
|
4732
|
+
z.literal("select"),
|
|
4733
|
+
z.literal("include"),
|
|
4734
|
+
z.literal("blocks"),
|
|
4735
|
+
z.literal("color")
|
|
4657
4736
|
]),
|
|
4658
|
-
template_types:
|
|
4659
|
-
name:
|
|
4660
|
-
label:
|
|
4661
|
-
default:
|
|
4662
|
-
template:
|
|
4663
|
-
config:
|
|
4737
|
+
template_types: z.array(z.string()).optional().nullable(),
|
|
4738
|
+
name: z.string(),
|
|
4739
|
+
label: z.string(),
|
|
4740
|
+
default: z.any().optional(),
|
|
4741
|
+
template: z.string().optional(),
|
|
4742
|
+
config: z.object({
|
|
4664
4743
|
// min and max are used for lists
|
|
4665
|
-
min:
|
|
4666
|
-
max:
|
|
4667
|
-
required:
|
|
4668
|
-
use_select:
|
|
4669
|
-
date_format:
|
|
4670
|
-
time_format:
|
|
4671
|
-
options:
|
|
4672
|
-
source:
|
|
4673
|
-
type:
|
|
4674
|
-
|
|
4675
|
-
|
|
4676
|
-
|
|
4677
|
-
|
|
4744
|
+
min: z.number().optional().nullable(),
|
|
4745
|
+
max: z.number().optional().nullable(),
|
|
4746
|
+
required: z.boolean().optional().nullable(),
|
|
4747
|
+
use_select: z.boolean().optional().nullable(),
|
|
4748
|
+
date_format: z.string().optional().nullable(),
|
|
4749
|
+
time_format: z.string().optional().nullable(),
|
|
4750
|
+
options: z.array(z.string()).optional().nullable(),
|
|
4751
|
+
source: z.object({
|
|
4752
|
+
type: z.union([
|
|
4753
|
+
z.literal("custom"),
|
|
4754
|
+
z.literal("pages"),
|
|
4755
|
+
z.literal("documents"),
|
|
4756
|
+
z.literal("simple"),
|
|
4678
4757
|
// TODO: I want to ignore this key if its invalid
|
|
4679
|
-
|
|
4758
|
+
z.string()
|
|
4680
4759
|
]).optional().nullable(),
|
|
4681
|
-
section:
|
|
4760
|
+
section: z.string().optional().nullable()
|
|
4682
4761
|
}).optional()
|
|
4683
4762
|
}).optional()
|
|
4684
4763
|
});
|
|
4685
|
-
var forestryField =
|
|
4764
|
+
var forestryField = z.lazy(
|
|
4686
4765
|
() => forestryFieldWithoutField.extend({
|
|
4687
|
-
fields:
|
|
4766
|
+
fields: z.array(forestryField).optional()
|
|
4688
4767
|
})
|
|
4689
4768
|
);
|
|
4690
|
-
var FrontmatterTemplateSchema =
|
|
4691
|
-
label:
|
|
4692
|
-
hide_body:
|
|
4693
|
-
fields:
|
|
4769
|
+
var FrontmatterTemplateSchema = z.object({
|
|
4770
|
+
label: z.string(),
|
|
4771
|
+
hide_body: z.boolean().optional(),
|
|
4772
|
+
fields: z.array(forestryField).optional()
|
|
4694
4773
|
});
|
|
4695
4774
|
var transformForestryFieldsToTinaFields = ({
|
|
4696
4775
|
fields,
|
|
@@ -4913,7 +4992,7 @@ var transformForestryFieldsToTinaFields = ({
|
|
|
4913
4992
|
return tinaFields;
|
|
4914
4993
|
};
|
|
4915
4994
|
var getFieldsFromTemplates = ({ tem, pathToForestryConfig, skipBlocks = false }) => {
|
|
4916
|
-
const templatePath =
|
|
4995
|
+
const templatePath = path11.join(
|
|
4917
4996
|
pathToForestryConfig,
|
|
4918
4997
|
".forestry",
|
|
4919
4998
|
"front_matter",
|
|
@@ -4922,7 +5001,7 @@ var getFieldsFromTemplates = ({ tem, pathToForestryConfig, skipBlocks = false })
|
|
|
4922
5001
|
);
|
|
4923
5002
|
let templateString = "";
|
|
4924
5003
|
try {
|
|
4925
|
-
templateString =
|
|
5004
|
+
templateString = fs10.readFileSync(templatePath).toString();
|
|
4926
5005
|
} catch {
|
|
4927
5006
|
throw new Error(
|
|
4928
5007
|
`Could not find template ${tem} at ${templatePath}
|
|
@@ -4930,7 +5009,7 @@ var getFieldsFromTemplates = ({ tem, pathToForestryConfig, skipBlocks = false })
|
|
|
4930
5009
|
This will require manual migration.`
|
|
4931
5010
|
);
|
|
4932
5011
|
}
|
|
4933
|
-
const templateObj =
|
|
5012
|
+
const templateObj = yaml.load(templateString);
|
|
4934
5013
|
const template = parseTemplates({ val: templateObj });
|
|
4935
5014
|
const fields = transformForestryFieldsToTinaFields({
|
|
4936
5015
|
fields: template.fields,
|
|
@@ -4950,6 +5029,7 @@ var parseSections = ({ val }) => {
|
|
|
4950
5029
|
};
|
|
4951
5030
|
|
|
4952
5031
|
// src/cmds/forestry-migrate/index.ts
|
|
5032
|
+
var { minimatch } = pkg;
|
|
4953
5033
|
var BODY_FIELD = {
|
|
4954
5034
|
// This is the body field
|
|
4955
5035
|
type: "rich-text",
|
|
@@ -4978,7 +5058,7 @@ var transformForestryMatchToTinaMatch = (match) => {
|
|
|
4978
5058
|
};
|
|
4979
5059
|
function checkExt(ext) {
|
|
4980
5060
|
const extReal = ext.replace(".", "");
|
|
4981
|
-
if (
|
|
5061
|
+
if (CONTENT_FORMATS.includes(extReal)) {
|
|
4982
5062
|
return extReal;
|
|
4983
5063
|
} else {
|
|
4984
5064
|
return false;
|
|
@@ -4987,9 +5067,9 @@ function checkExt(ext) {
|
|
|
4987
5067
|
var generateAllTemplates = async ({
|
|
4988
5068
|
pathToForestryConfig
|
|
4989
5069
|
}) => {
|
|
4990
|
-
const allTemplates = (await
|
|
4991
|
-
|
|
4992
|
-
)).map((tem) =>
|
|
5070
|
+
const allTemplates = (await fs11.readdir(
|
|
5071
|
+
path12.join(pathToForestryConfig, ".forestry", "front_matter", "templates")
|
|
5072
|
+
)).map((tem) => path12.basename(tem, ".yml"));
|
|
4993
5073
|
const templateMap = /* @__PURE__ */ new Map();
|
|
4994
5074
|
const proms = allTemplates.map(async (tem) => {
|
|
4995
5075
|
try {
|
|
@@ -5064,7 +5144,7 @@ var generateCollectionFromForestrySection = (args) => {
|
|
|
5064
5144
|
glob = section.path + "/" + section.match;
|
|
5065
5145
|
}
|
|
5066
5146
|
if (pages.some((page) => {
|
|
5067
|
-
return (
|
|
5147
|
+
return minimatch(page, glob);
|
|
5068
5148
|
})) {
|
|
5069
5149
|
forestryTemplates.push(templateKey);
|
|
5070
5150
|
}
|
|
@@ -5134,9 +5214,9 @@ var generateCollectionFromForestrySection = (args) => {
|
|
|
5134
5214
|
return c;
|
|
5135
5215
|
} else if (section.type === "document") {
|
|
5136
5216
|
const filePath = section.path;
|
|
5137
|
-
const extname =
|
|
5138
|
-
const fileName =
|
|
5139
|
-
const dir =
|
|
5217
|
+
const extname = path12.extname(filePath);
|
|
5218
|
+
const fileName = path12.basename(filePath, extname);
|
|
5219
|
+
const dir = path12.dirname(filePath);
|
|
5140
5220
|
const ext = checkExt(extname);
|
|
5141
5221
|
if (ext) {
|
|
5142
5222
|
const fields = [];
|
|
@@ -5156,7 +5236,7 @@ var generateCollectionFromForestrySection = (args) => {
|
|
|
5156
5236
|
name: "dummy",
|
|
5157
5237
|
label: "Dummy field",
|
|
5158
5238
|
type: "string",
|
|
5159
|
-
description: "This is a dummy field, please replace it with the fields you want to edit. See https://tina.io/docs/
|
|
5239
|
+
description: "This is a dummy field, please replace it with the fields you want to edit. See https://tina.io/docs/r/content-modelling-collections/ for more info"
|
|
5160
5240
|
});
|
|
5161
5241
|
logger.warn(
|
|
5162
5242
|
warnText(
|
|
@@ -5198,8 +5278,8 @@ var generateCollections = async ({
|
|
|
5198
5278
|
templateMap,
|
|
5199
5279
|
usingTypescript
|
|
5200
5280
|
});
|
|
5201
|
-
const forestryConfig = await
|
|
5202
|
-
|
|
5281
|
+
const forestryConfig = await fs11.readFile(
|
|
5282
|
+
path12.join(pathToForestryConfig, ".forestry", "settings.yml")
|
|
5203
5283
|
);
|
|
5204
5284
|
rewriteTemplateKeysInDocs({
|
|
5205
5285
|
templateMap,
|
|
@@ -5209,7 +5289,7 @@ var generateCollections = async ({
|
|
|
5209
5289
|
}
|
|
5210
5290
|
});
|
|
5211
5291
|
const collections = parseSections({
|
|
5212
|
-
val:
|
|
5292
|
+
val: yaml2.load(forestryConfig.toString())
|
|
5213
5293
|
}).sections.map(
|
|
5214
5294
|
(section) => generateCollectionFromForestrySection({
|
|
5215
5295
|
section,
|
|
@@ -5229,13 +5309,13 @@ var rewriteTemplateKeysInDocs = (args) => {
|
|
|
5229
5309
|
const { templateObj } = templateMap.get(templateKey);
|
|
5230
5310
|
templateObj?.pages?.forEach((page) => {
|
|
5231
5311
|
try {
|
|
5232
|
-
const filePath =
|
|
5233
|
-
if (
|
|
5312
|
+
const filePath = path12.join(page);
|
|
5313
|
+
if (fs11.lstatSync(filePath).isDirectory()) {
|
|
5234
5314
|
return;
|
|
5235
5315
|
}
|
|
5236
|
-
const extname =
|
|
5237
|
-
const fileContent =
|
|
5238
|
-
const content =
|
|
5316
|
+
const extname = path12.extname(filePath);
|
|
5317
|
+
const fileContent = fs11.readFileSync(filePath).toString();
|
|
5318
|
+
const content = parseFile(
|
|
5239
5319
|
fileContent,
|
|
5240
5320
|
extname,
|
|
5241
5321
|
(yup) => yup.object({}),
|
|
@@ -5245,9 +5325,9 @@ var rewriteTemplateKeysInDocs = (args) => {
|
|
|
5245
5325
|
_template: stringifyLabel(templateKey),
|
|
5246
5326
|
...content
|
|
5247
5327
|
};
|
|
5248
|
-
|
|
5328
|
+
fs11.writeFileSync(
|
|
5249
5329
|
filePath,
|
|
5250
|
-
|
|
5330
|
+
stringifyFile(newContent, extname, true, markdownParseConfig)
|
|
5251
5331
|
);
|
|
5252
5332
|
} catch (error) {
|
|
5253
5333
|
console.log(
|
|
@@ -5259,32 +5339,25 @@ var rewriteTemplateKeysInDocs = (args) => {
|
|
|
5259
5339
|
};
|
|
5260
5340
|
|
|
5261
5341
|
// src/cmds/init/apply.ts
|
|
5262
|
-
|
|
5263
|
-
|
|
5342
|
+
import { Telemetry as Telemetry2 } from "@tinacms/metrics";
|
|
5343
|
+
import fs14 from "fs-extra";
|
|
5264
5344
|
|
|
5265
5345
|
// src/next/commands/codemod-command/index.ts
|
|
5266
|
-
|
|
5267
|
-
|
|
5268
|
-
|
|
5269
|
-
var CodemodCommand = class extends
|
|
5270
|
-
|
|
5271
|
-
|
|
5272
|
-
|
|
5273
|
-
|
|
5274
|
-
|
|
5275
|
-
|
|
5276
|
-
|
|
5277
|
-
|
|
5278
|
-
|
|
5279
|
-
|
|
5280
|
-
|
|
5281
|
-
}
|
|
5282
|
-
static {
|
|
5283
|
-
this.usage = import_clipanion5.Command.Usage({
|
|
5284
|
-
category: `Commands`,
|
|
5285
|
-
description: `Use codemods for various Tina tasks`
|
|
5286
|
-
});
|
|
5287
|
-
}
|
|
5346
|
+
import { Command as Command5, Option as Option5 } from "clipanion";
|
|
5347
|
+
import fs12 from "fs-extra";
|
|
5348
|
+
import path13 from "path";
|
|
5349
|
+
var CodemodCommand = class extends Command5 {
|
|
5350
|
+
static paths = [["codemod"], ["codemod", "move-tina-folder"]];
|
|
5351
|
+
rootPath = Option5.String("--rootPath", {
|
|
5352
|
+
description: "Specify the root directory to run the CLI from"
|
|
5353
|
+
});
|
|
5354
|
+
verbose = Option5.Boolean("-v,--verbose", false, {
|
|
5355
|
+
description: "increase verbosity of logged output"
|
|
5356
|
+
});
|
|
5357
|
+
static usage = Command5.Usage({
|
|
5358
|
+
category: `Commands`,
|
|
5359
|
+
description: `Use codemods for various Tina tasks`
|
|
5360
|
+
});
|
|
5288
5361
|
async catch(error) {
|
|
5289
5362
|
console.log(error);
|
|
5290
5363
|
}
|
|
@@ -5313,13 +5386,13 @@ var moveTinaFolder = async (rootPath = process.cwd()) => {
|
|
|
5313
5386
|
logger.error(e.message);
|
|
5314
5387
|
process.exit(1);
|
|
5315
5388
|
}
|
|
5316
|
-
const tinaDestination =
|
|
5317
|
-
if (await
|
|
5389
|
+
const tinaDestination = path13.join(configManager.rootPath, "tina");
|
|
5390
|
+
if (await fs12.existsSync(tinaDestination)) {
|
|
5318
5391
|
logger.info(
|
|
5319
5392
|
`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.`
|
|
5320
5393
|
);
|
|
5321
5394
|
} else {
|
|
5322
|
-
await
|
|
5395
|
+
await fs12.moveSync(configManager.tinaFolderPath, tinaDestination);
|
|
5323
5396
|
await writeGitignore(configManager.rootPath);
|
|
5324
5397
|
logger.info(
|
|
5325
5398
|
"Move to 'tina' folder complete. Be sure to update any imports of the autogenerated client!"
|
|
@@ -5327,8 +5400,8 @@ var moveTinaFolder = async (rootPath = process.cwd()) => {
|
|
|
5327
5400
|
}
|
|
5328
5401
|
};
|
|
5329
5402
|
var writeGitignore = async (rootPath) => {
|
|
5330
|
-
await
|
|
5331
|
-
|
|
5403
|
+
await fs12.outputFileSync(
|
|
5404
|
+
path13.join(rootPath, "tina", ".gitignore"),
|
|
5332
5405
|
"__generated__"
|
|
5333
5406
|
);
|
|
5334
5407
|
};
|
|
@@ -5381,7 +5454,7 @@ const BlogPage = (props) => {
|
|
|
5381
5454
|
<div className='bg-green-100 text-center'>
|
|
5382
5455
|
Lost and looking for a place to start?
|
|
5383
5456
|
<a
|
|
5384
|
-
href='https://tina.io/
|
|
5457
|
+
href='https://tina.io/docs/r/beginner-series'
|
|
5385
5458
|
className='text-blue-500 underline'
|
|
5386
5459
|
>
|
|
5387
5460
|
{' '}
|
|
@@ -5663,7 +5736,7 @@ import { LocalAuthProvider } from "tinacms";`;
|
|
|
5663
5736
|
publicFolder: "${args.publicFolder}",
|
|
5664
5737
|
},
|
|
5665
5738
|
},
|
|
5666
|
-
// See docs on content modeling for more info on how to setup new content models: https://tina.io/docs/
|
|
5739
|
+
// See docs on content modeling for more info on how to setup new content models: https://tina.io/docs/r/content-modelling-collections/
|
|
5667
5740
|
schema: {
|
|
5668
5741
|
collections: ${generateCollectionString(args)},
|
|
5669
5742
|
},
|
|
@@ -5736,7 +5809,7 @@ Suspendisse facilisis, mi ac scelerisque interdum, ligula ex imperdiet felis, a
|
|
|
5736
5809
|
`;
|
|
5737
5810
|
|
|
5738
5811
|
// src/cmds/init/apply.ts
|
|
5739
|
-
|
|
5812
|
+
import { format as format2 } from "prettier";
|
|
5740
5813
|
|
|
5741
5814
|
// src/utils/script-helpers.ts
|
|
5742
5815
|
function generateGqlScript(scriptValue, opts) {
|
|
@@ -5759,38 +5832,38 @@ function extendNextScripts(scripts, opts) {
|
|
|
5759
5832
|
}
|
|
5760
5833
|
|
|
5761
5834
|
// src/cmds/init/codegen/index.ts
|
|
5762
|
-
|
|
5763
|
-
|
|
5835
|
+
import ts2 from "typescript";
|
|
5836
|
+
import fs13 from "fs-extra";
|
|
5764
5837
|
|
|
5765
5838
|
// src/cmds/init/codegen/util.ts
|
|
5766
|
-
|
|
5767
|
-
var makeTransformer = (makeVisitor) => (ctx) => (node) =>
|
|
5839
|
+
import ts from "typescript";
|
|
5840
|
+
var makeTransformer = (makeVisitor) => (ctx) => (node) => ts.visitNode(node, makeVisitor(ctx));
|
|
5768
5841
|
function parseExpression(expression) {
|
|
5769
|
-
const sourceFile =
|
|
5842
|
+
const sourceFile = ts.createSourceFile(
|
|
5770
5843
|
"temp.ts",
|
|
5771
5844
|
expression,
|
|
5772
|
-
|
|
5845
|
+
ts.ScriptTarget.Latest
|
|
5773
5846
|
);
|
|
5774
5847
|
if (sourceFile.statements.length !== 1) {
|
|
5775
5848
|
throw new Error("Expected one statement");
|
|
5776
5849
|
}
|
|
5777
5850
|
const statement = sourceFile.statements[0];
|
|
5778
|
-
if (!
|
|
5851
|
+
if (!ts.isExpressionStatement(statement)) {
|
|
5779
5852
|
throw new Error("Expected an expression statement");
|
|
5780
5853
|
}
|
|
5781
5854
|
return [sourceFile, statement.expression];
|
|
5782
5855
|
}
|
|
5783
5856
|
function parseVariableStatement(stmt) {
|
|
5784
|
-
const sourceFile =
|
|
5857
|
+
const sourceFile = ts.createSourceFile(
|
|
5785
5858
|
"temp.ts",
|
|
5786
5859
|
stmt,
|
|
5787
|
-
|
|
5860
|
+
ts.ScriptTarget.Latest
|
|
5788
5861
|
);
|
|
5789
5862
|
if (sourceFile.statements.length !== 1) {
|
|
5790
5863
|
throw new Error("Expected one statement");
|
|
5791
5864
|
}
|
|
5792
5865
|
const statement = sourceFile.statements[0];
|
|
5793
|
-
if (!
|
|
5866
|
+
if (!ts.isVariableStatement(statement)) {
|
|
5794
5867
|
throw new Error("Expected a variable statement");
|
|
5795
5868
|
}
|
|
5796
5869
|
return [sourceFile, statement];
|
|
@@ -5798,7 +5871,7 @@ function parseVariableStatement(stmt) {
|
|
|
5798
5871
|
|
|
5799
5872
|
// src/cmds/init/codegen/index.ts
|
|
5800
5873
|
var makeVariableStatementVisitor = (sourceFile, variableStmtSourceFile, variableStmt) => (ctx) => (node) => {
|
|
5801
|
-
if (
|
|
5874
|
+
if (ts2.isSourceFile(node)) {
|
|
5802
5875
|
const newStatements = [...node.statements];
|
|
5803
5876
|
let encounteredImports = false;
|
|
5804
5877
|
let firstNonImportStatementIdx = -1;
|
|
@@ -5806,7 +5879,7 @@ var makeVariableStatementVisitor = (sourceFile, variableStmtSourceFile, variable
|
|
|
5806
5879
|
const [newVarDec] = variableStmt.declarationList.declarations;
|
|
5807
5880
|
const newVarDecName = newVarDec.name.getText(variableStmtSourceFile);
|
|
5808
5881
|
for (let i = 0; i < newStatements.length; i++) {
|
|
5809
|
-
const isImport =
|
|
5882
|
+
const isImport = ts2.isImportDeclaration(newStatements[i]);
|
|
5810
5883
|
if (isImport && !encounteredImports) {
|
|
5811
5884
|
encounteredImports = true;
|
|
5812
5885
|
}
|
|
@@ -5814,9 +5887,9 @@ var makeVariableStatementVisitor = (sourceFile, variableStmtSourceFile, variable
|
|
|
5814
5887
|
firstNonImportStatementIdx = i;
|
|
5815
5888
|
}
|
|
5816
5889
|
const stmt = newStatements[i];
|
|
5817
|
-
if (
|
|
5890
|
+
if (ts2.isVariableStatement(stmt)) {
|
|
5818
5891
|
const [dec] = stmt.declarationList.declarations;
|
|
5819
|
-
if (dec.name &&
|
|
5892
|
+
if (dec.name && ts2.isIdentifier(dec.name) && dec.name.getText(sourceFile) === newVarDecName) {
|
|
5820
5893
|
existingStatementIdx = i;
|
|
5821
5894
|
}
|
|
5822
5895
|
}
|
|
@@ -5830,19 +5903,19 @@ var makeVariableStatementVisitor = (sourceFile, variableStmtSourceFile, variable
|
|
|
5830
5903
|
if (existingStatementIdx === -1) {
|
|
5831
5904
|
newStatements.splice(firstNonImportStatementIdx, 0, variableStmt);
|
|
5832
5905
|
}
|
|
5833
|
-
return
|
|
5906
|
+
return ts2.factory.updateSourceFile(node, newStatements);
|
|
5834
5907
|
}
|
|
5835
5908
|
};
|
|
5836
5909
|
var makeImportsVisitor = (sourceFile, importMap) => (ctx) => (node) => {
|
|
5837
|
-
if (
|
|
5910
|
+
if (ts2.isSourceFile(node)) {
|
|
5838
5911
|
const newStatements = [...node.statements];
|
|
5839
5912
|
let changed = false;
|
|
5840
5913
|
for (const [moduleName, imports] of Object.entries(importMap)) {
|
|
5841
5914
|
let foundImportStatement = false;
|
|
5842
5915
|
for (const statement of newStatements) {
|
|
5843
|
-
if (
|
|
5916
|
+
if (ts2.isImportDeclaration(statement) && ts2.isStringLiteral(statement.moduleSpecifier) && statement.moduleSpecifier.text === moduleName) {
|
|
5844
5917
|
foundImportStatement = true;
|
|
5845
|
-
const existingImports = statement.importClause?.namedBindings &&
|
|
5918
|
+
const existingImports = statement.importClause?.namedBindings && ts2.isNamedImports(statement.importClause.namedBindings) ? statement.importClause.namedBindings.elements.map(
|
|
5846
5919
|
(e) => e.name.text
|
|
5847
5920
|
) : [];
|
|
5848
5921
|
const newImports = [
|
|
@@ -5853,22 +5926,22 @@ var makeImportsVisitor = (sourceFile, importMap) => (ctx) => (node) => {
|
|
|
5853
5926
|
])
|
|
5854
5927
|
];
|
|
5855
5928
|
const importSpecifiers = newImports.map(
|
|
5856
|
-
(i) =>
|
|
5929
|
+
(i) => ts2.factory.createImportSpecifier(
|
|
5857
5930
|
void 0,
|
|
5858
|
-
|
|
5859
|
-
|
|
5931
|
+
ts2.factory.createIdentifier(i),
|
|
5932
|
+
ts2.factory.createIdentifier(i)
|
|
5860
5933
|
)
|
|
5861
5934
|
);
|
|
5862
|
-
const namedImports =
|
|
5863
|
-
const importClause =
|
|
5935
|
+
const namedImports = ts2.factory.createNamedImports(importSpecifiers);
|
|
5936
|
+
const importClause = ts2.factory.createImportClause(
|
|
5864
5937
|
false,
|
|
5865
5938
|
void 0,
|
|
5866
5939
|
namedImports
|
|
5867
5940
|
);
|
|
5868
|
-
const importDec =
|
|
5941
|
+
const importDec = ts2.factory.createImportDeclaration(
|
|
5869
5942
|
void 0,
|
|
5870
5943
|
importClause,
|
|
5871
|
-
|
|
5944
|
+
ts2.factory.createStringLiteral(moduleName)
|
|
5872
5945
|
);
|
|
5873
5946
|
newStatements[newStatements.indexOf(statement)] = importDec;
|
|
5874
5947
|
changed = true;
|
|
@@ -5876,45 +5949,45 @@ var makeImportsVisitor = (sourceFile, importMap) => (ctx) => (node) => {
|
|
|
5876
5949
|
}
|
|
5877
5950
|
if (!foundImportStatement) {
|
|
5878
5951
|
const importSpecifiers = imports.map(
|
|
5879
|
-
(i) =>
|
|
5952
|
+
(i) => ts2.factory.createImportSpecifier(
|
|
5880
5953
|
void 0,
|
|
5881
|
-
|
|
5882
|
-
|
|
5954
|
+
ts2.factory.createIdentifier(i),
|
|
5955
|
+
ts2.factory.createIdentifier(i)
|
|
5883
5956
|
)
|
|
5884
5957
|
);
|
|
5885
|
-
const namedImports =
|
|
5886
|
-
const importClause =
|
|
5958
|
+
const namedImports = ts2.factory.createNamedImports(importSpecifiers);
|
|
5959
|
+
const importClause = ts2.factory.createImportClause(
|
|
5887
5960
|
false,
|
|
5888
5961
|
void 0,
|
|
5889
5962
|
namedImports
|
|
5890
5963
|
);
|
|
5891
|
-
const importDec =
|
|
5964
|
+
const importDec = ts2.factory.createImportDeclaration(
|
|
5892
5965
|
void 0,
|
|
5893
5966
|
importClause,
|
|
5894
|
-
|
|
5967
|
+
ts2.factory.createStringLiteral(moduleName)
|
|
5895
5968
|
);
|
|
5896
5969
|
newStatements.unshift(importDec);
|
|
5897
5970
|
changed = true;
|
|
5898
5971
|
}
|
|
5899
5972
|
}
|
|
5900
5973
|
if (changed) {
|
|
5901
|
-
return
|
|
5974
|
+
return ts2.factory.updateSourceFile(node, newStatements);
|
|
5902
5975
|
}
|
|
5903
5976
|
}
|
|
5904
5977
|
};
|
|
5905
5978
|
var makeAddExpressionToSchemaCollectionVisitor = (sourceFile, functionName, newExpressionSourceFile, newExpression) => (ctx) => {
|
|
5906
5979
|
const visit2 = (node) => {
|
|
5907
|
-
if (
|
|
5980
|
+
if (ts2.isCallExpression(node) && ts2.isIdentifier(node.expression) && node.expression.text === functionName && node.arguments.length > 0 && ts2.isObjectLiteralExpression(node.arguments[0])) {
|
|
5908
5981
|
const configObject = node.arguments[0];
|
|
5909
5982
|
const updateProperties = configObject.properties.map((property) => {
|
|
5910
|
-
if (
|
|
5983
|
+
if (ts2.isPropertyAssignment(property)) {
|
|
5911
5984
|
const thisPropertyName = property.name.getText(sourceFile);
|
|
5912
|
-
if (thisPropertyName === "schema" &&
|
|
5985
|
+
if (thisPropertyName === "schema" && ts2.isPropertyAssignment(property) && ts2.isObjectLiteralExpression(property.initializer)) {
|
|
5913
5986
|
const schemaObject = property.initializer;
|
|
5914
5987
|
const collectionsProperty = schemaObject.properties.find(
|
|
5915
|
-
(p) =>
|
|
5988
|
+
(p) => ts2.isPropertyAssignment(p) && p.name.getText(sourceFile) === "collections"
|
|
5916
5989
|
);
|
|
5917
|
-
if (collectionsProperty &&
|
|
5990
|
+
if (collectionsProperty && ts2.isPropertyAssignment(collectionsProperty) && ts2.isArrayLiteralExpression(collectionsProperty.initializer)) {
|
|
5918
5991
|
const collectionsArray = collectionsProperty.initializer;
|
|
5919
5992
|
const collectionItems = collectionsArray.elements.map(
|
|
5920
5993
|
(e) => e.getText(sourceFile)
|
|
@@ -5924,16 +5997,16 @@ var makeAddExpressionToSchemaCollectionVisitor = (sourceFile, functionName, newE
|
|
|
5924
5997
|
)) {
|
|
5925
5998
|
return property;
|
|
5926
5999
|
}
|
|
5927
|
-
return
|
|
6000
|
+
return ts2.factory.updatePropertyAssignment(
|
|
5928
6001
|
property,
|
|
5929
6002
|
property.name,
|
|
5930
|
-
|
|
6003
|
+
ts2.factory.createObjectLiteralExpression(
|
|
5931
6004
|
schemaObject.properties.map((subProp) => {
|
|
5932
|
-
if (
|
|
5933
|
-
return
|
|
6005
|
+
if (ts2.isPropertyAssignment(subProp) && subProp.name.getText(sourceFile) === "collections" && ts2.isArrayLiteralExpression(subProp.initializer)) {
|
|
6006
|
+
return ts2.factory.updatePropertyAssignment(
|
|
5934
6007
|
subProp,
|
|
5935
6008
|
subProp.name,
|
|
5936
|
-
|
|
6009
|
+
ts2.factory.createArrayLiteralExpression(
|
|
5937
6010
|
[newExpression, ...subProp.initializer.elements],
|
|
5938
6011
|
true
|
|
5939
6012
|
)
|
|
@@ -5949,56 +6022,56 @@ var makeAddExpressionToSchemaCollectionVisitor = (sourceFile, functionName, newE
|
|
|
5949
6022
|
}
|
|
5950
6023
|
return property;
|
|
5951
6024
|
});
|
|
5952
|
-
return
|
|
6025
|
+
return ts2.factory.createCallExpression(
|
|
5953
6026
|
node.expression,
|
|
5954
6027
|
node.typeArguments,
|
|
5955
|
-
[
|
|
6028
|
+
[ts2.factory.createObjectLiteralExpression(updateProperties, true)]
|
|
5956
6029
|
);
|
|
5957
6030
|
}
|
|
5958
|
-
return
|
|
6031
|
+
return ts2.visitEachChild(node, visit2, ctx);
|
|
5959
6032
|
};
|
|
5960
6033
|
return (sourceFile2) => {
|
|
5961
|
-
return
|
|
6034
|
+
return ts2.visitEachChild(sourceFile2, visit2, ctx);
|
|
5962
6035
|
};
|
|
5963
6036
|
};
|
|
5964
6037
|
var makeUpdateObjectLiteralPropertyVisitor = (sourceFile, functionName, propertyName, propertyValueExpressionSourceFile, propertyValue) => (ctx) => {
|
|
5965
6038
|
const visitor = (node) => {
|
|
5966
|
-
if (
|
|
6039
|
+
if (ts2.isCallExpression(node) && ts2.isIdentifier(node.expression) && node.expression.text === functionName && node.arguments.length > 0 && ts2.isObjectLiteralExpression(node.arguments[0])) {
|
|
5967
6040
|
let foundProperty = false;
|
|
5968
6041
|
const configObject = node.arguments[0];
|
|
5969
6042
|
const updateProperties = configObject.properties.map((property) => {
|
|
5970
|
-
if (
|
|
6043
|
+
if (ts2.isPropertyAssignment(property) || ts2.isShorthandPropertyAssignment(property)) {
|
|
5971
6044
|
const name2 = property.name.getText(sourceFile);
|
|
5972
6045
|
if (name2 === propertyName) {
|
|
5973
6046
|
foundProperty = true;
|
|
5974
|
-
return
|
|
6047
|
+
return ts2.factory.createPropertyAssignment(name2, propertyValue);
|
|
5975
6048
|
}
|
|
5976
6049
|
}
|
|
5977
6050
|
return property;
|
|
5978
6051
|
});
|
|
5979
6052
|
if (!foundProperty) {
|
|
5980
6053
|
updateProperties.unshift(
|
|
5981
|
-
|
|
6054
|
+
ts2.factory.createPropertyAssignment(propertyName, propertyValue)
|
|
5982
6055
|
);
|
|
5983
6056
|
}
|
|
5984
|
-
return
|
|
6057
|
+
return ts2.factory.createCallExpression(
|
|
5985
6058
|
node.expression,
|
|
5986
6059
|
node.typeArguments,
|
|
5987
|
-
[
|
|
6060
|
+
[ts2.factory.createObjectLiteralExpression(updateProperties, true)]
|
|
5988
6061
|
);
|
|
5989
6062
|
}
|
|
5990
|
-
return
|
|
6063
|
+
return ts2.visitEachChild(node, visitor, ctx);
|
|
5991
6064
|
};
|
|
5992
6065
|
return (sourceFile2) => {
|
|
5993
|
-
return
|
|
6066
|
+
return ts2.visitNode(sourceFile2, visitor);
|
|
5994
6067
|
};
|
|
5995
6068
|
};
|
|
5996
6069
|
var addSelfHostedTinaAuthToConfig = async (config2, configFile) => {
|
|
5997
6070
|
const pathToConfig = configFile.resolve(config2.typescript).path;
|
|
5998
|
-
const sourceFile =
|
|
6071
|
+
const sourceFile = ts2.createSourceFile(
|
|
5999
6072
|
pathToConfig,
|
|
6000
|
-
|
|
6001
|
-
config2.typescript ?
|
|
6073
|
+
fs13.readFileSync(pathToConfig, "utf8"),
|
|
6074
|
+
config2.typescript ? ts2.ScriptTarget.Latest : ts2.ScriptTarget.ESNext
|
|
6002
6075
|
);
|
|
6003
6076
|
const { configImports, configAuthProviderClass, extraTinaCollections } = config2.authProvider;
|
|
6004
6077
|
const importMap = {
|
|
@@ -6011,7 +6084,7 @@ var addSelfHostedTinaAuthToConfig = async (config2, configFile) => {
|
|
|
6011
6084
|
{}
|
|
6012
6085
|
)
|
|
6013
6086
|
};
|
|
6014
|
-
const transformedSourceFileResult =
|
|
6087
|
+
const transformedSourceFileResult = ts2.transform(
|
|
6015
6088
|
sourceFile,
|
|
6016
6089
|
[
|
|
6017
6090
|
makeImportsVisitor(sourceFile, {
|
|
@@ -6047,9 +6120,9 @@ var addSelfHostedTinaAuthToConfig = async (config2, configFile) => {
|
|
|
6047
6120
|
)
|
|
6048
6121
|
].map((visitor) => makeTransformer(visitor))
|
|
6049
6122
|
);
|
|
6050
|
-
return
|
|
6123
|
+
return fs13.writeFile(
|
|
6051
6124
|
pathToConfig,
|
|
6052
|
-
|
|
6125
|
+
ts2.createPrinter({ omitTrailingSemicolon: true }).printFile(transformedSourceFileResult.transformed[0])
|
|
6053
6126
|
);
|
|
6054
6127
|
};
|
|
6055
6128
|
|
|
@@ -6164,8 +6237,8 @@ async function apply({
|
|
|
6164
6237
|
await addConfigFile({
|
|
6165
6238
|
configArgs: {
|
|
6166
6239
|
config: config2,
|
|
6167
|
-
publicFolder:
|
|
6168
|
-
|
|
6240
|
+
publicFolder: path14.join(
|
|
6241
|
+
path14.relative(process.cwd(), pathToForestryConfig),
|
|
6169
6242
|
config2.publicFolder
|
|
6170
6243
|
),
|
|
6171
6244
|
collections,
|
|
@@ -6222,7 +6295,7 @@ var reportTelemetry = async ({
|
|
|
6222
6295
|
if (noTelemetry) {
|
|
6223
6296
|
logger.info(logText("Telemetry disabled"));
|
|
6224
6297
|
}
|
|
6225
|
-
const telemetry = new
|
|
6298
|
+
const telemetry = new Telemetry2({ disabled: noTelemetry });
|
|
6226
6299
|
const schemaFileType = usingTypescript ? "ts" : "js";
|
|
6227
6300
|
await telemetry.submitRecord({
|
|
6228
6301
|
event: {
|
|
@@ -6238,18 +6311,18 @@ var createPackageJSON = async () => {
|
|
|
6238
6311
|
};
|
|
6239
6312
|
var createGitignore = async ({ baseDir }) => {
|
|
6240
6313
|
logger.info(logText("No .gitignore found, creating one"));
|
|
6241
|
-
|
|
6314
|
+
fs14.outputFileSync(path14.join(baseDir, ".gitignore"), "node_modules");
|
|
6242
6315
|
};
|
|
6243
6316
|
var updateGitIgnore = async ({
|
|
6244
6317
|
baseDir,
|
|
6245
6318
|
items
|
|
6246
6319
|
}) => {
|
|
6247
6320
|
logger.info(logText(`Adding ${items.join(",")} to .gitignore`));
|
|
6248
|
-
const gitignoreContent =
|
|
6321
|
+
const gitignoreContent = fs14.readFileSync(path14.join(baseDir, ".gitignore")).toString();
|
|
6249
6322
|
const newGitignoreContent = [...gitignoreContent.split("\n"), ...items].join(
|
|
6250
6323
|
"\n"
|
|
6251
6324
|
);
|
|
6252
|
-
await
|
|
6325
|
+
await fs14.writeFile(path14.join(baseDir, ".gitignore"), newGitignoreContent);
|
|
6253
6326
|
};
|
|
6254
6327
|
var addDependencies = async (config2, env, params) => {
|
|
6255
6328
|
const { packageManager } = config2;
|
|
@@ -6290,7 +6363,8 @@ var addDependencies = async (config2, env, params) => {
|
|
|
6290
6363
|
let packageManagers = {
|
|
6291
6364
|
pnpm: process.env.USE_WORKSPACE ? `pnpm add ${deps.join(" ")} --workspace` : `pnpm add ${deps.join(" ")}`,
|
|
6292
6365
|
npm: `npm install ${deps.join(" ")}`,
|
|
6293
|
-
yarn: `yarn add ${deps.join(" ")}
|
|
6366
|
+
yarn: `yarn add ${deps.join(" ")}`,
|
|
6367
|
+
bun: `bun add ${deps.join(" ")}`
|
|
6294
6368
|
};
|
|
6295
6369
|
if (packageManagers[packageManager] && deps.length > 0) {
|
|
6296
6370
|
logger.info(logText("Adding dependencies, this might take a moment..."));
|
|
@@ -6301,7 +6375,8 @@ var addDependencies = async (config2, env, params) => {
|
|
|
6301
6375
|
packageManagers = {
|
|
6302
6376
|
pnpm: process.env.USE_WORKSPACE ? `pnpm add -D ${devDeps.join(" ")} --workspace` : `pnpm add -D ${devDeps.join(" ")}`,
|
|
6303
6377
|
npm: `npm install -D ${devDeps.join(" ")}`,
|
|
6304
|
-
yarn: `yarn add -D ${devDeps.join(" ")}
|
|
6378
|
+
yarn: `yarn add -D ${devDeps.join(" ")}`,
|
|
6379
|
+
bun: `bun add -D ${devDeps.join(" ")}`
|
|
6305
6380
|
};
|
|
6306
6381
|
if (packageManagers[packageManager]) {
|
|
6307
6382
|
logger.info(
|
|
@@ -6318,22 +6393,22 @@ var writeGeneratedFile = async ({
|
|
|
6318
6393
|
content,
|
|
6319
6394
|
typescript
|
|
6320
6395
|
}) => {
|
|
6321
|
-
const { exists, path:
|
|
6396
|
+
const { exists, path: path15, parentPath } = generatedFile.resolve(typescript);
|
|
6322
6397
|
if (exists) {
|
|
6323
6398
|
if (overwrite) {
|
|
6324
|
-
logger.info(`Overwriting file at ${
|
|
6325
|
-
|
|
6399
|
+
logger.info(`Overwriting file at ${path15}... \u2705`);
|
|
6400
|
+
fs14.outputFileSync(path15, content);
|
|
6326
6401
|
} else {
|
|
6327
|
-
logger.info(`Not overwriting file at ${
|
|
6402
|
+
logger.info(`Not overwriting file at ${path15}.`);
|
|
6328
6403
|
logger.info(
|
|
6329
|
-
logText(`Please add the following to ${
|
|
6404
|
+
logText(`Please add the following to ${path15}:
|
|
6330
6405
|
${indentText(content)}}`)
|
|
6331
6406
|
);
|
|
6332
6407
|
}
|
|
6333
6408
|
} else {
|
|
6334
|
-
logger.info(`Adding file at ${
|
|
6335
|
-
await
|
|
6336
|
-
|
|
6409
|
+
logger.info(`Adding file at ${path15}... \u2705`);
|
|
6410
|
+
await fs14.ensureDir(parentPath);
|
|
6411
|
+
fs14.outputFileSync(path15, content);
|
|
6337
6412
|
}
|
|
6338
6413
|
};
|
|
6339
6414
|
var addConfigFile = async ({
|
|
@@ -6342,7 +6417,7 @@ var addConfigFile = async ({
|
|
|
6342
6417
|
generatedFile,
|
|
6343
6418
|
config: config2
|
|
6344
6419
|
}) => {
|
|
6345
|
-
const content = (
|
|
6420
|
+
const content = format2(generateConfig(configArgs), {
|
|
6346
6421
|
parser: "babel"
|
|
6347
6422
|
});
|
|
6348
6423
|
await writeGeneratedFile({
|
|
@@ -6372,7 +6447,7 @@ var addNextApiRoute = async ({
|
|
|
6372
6447
|
generatedFile,
|
|
6373
6448
|
env
|
|
6374
6449
|
}) => {
|
|
6375
|
-
const content = (
|
|
6450
|
+
const content = format2(nextApiRouteTemplate({ config: config2, env }), {
|
|
6376
6451
|
parser: "babel"
|
|
6377
6452
|
});
|
|
6378
6453
|
await writeGeneratedFile({
|
|
@@ -6411,7 +6486,7 @@ var addContentFile = async ({
|
|
|
6411
6486
|
return () => ({
|
|
6412
6487
|
exists: env.sampleContentExists,
|
|
6413
6488
|
path: env.sampleContentPath,
|
|
6414
|
-
parentPath:
|
|
6489
|
+
parentPath: path14.dirname(env.sampleContentPath)
|
|
6415
6490
|
});
|
|
6416
6491
|
}
|
|
6417
6492
|
},
|
|
@@ -6434,10 +6509,10 @@ ${titleText(" TinaCMS ")} backend initialized!`));
|
|
|
6434
6509
|
return `${x.key}=${x.value || "***"}`;
|
|
6435
6510
|
}).join("\n") + `
|
|
6436
6511
|
TINA_PUBLIC_IS_LOCAL=true`;
|
|
6437
|
-
const envFile =
|
|
6438
|
-
if (!
|
|
6512
|
+
const envFile = path14.join(process.cwd(), ".env");
|
|
6513
|
+
if (!fs14.existsSync(envFile)) {
|
|
6439
6514
|
logger.info(`Adding .env file to your project... \u2705`);
|
|
6440
|
-
|
|
6515
|
+
fs14.writeFileSync(envFile, envFileText);
|
|
6441
6516
|
} else {
|
|
6442
6517
|
logger.info(
|
|
6443
6518
|
"Please add the following environment variables to your .env file"
|
|
@@ -6480,7 +6555,8 @@ var other = ({ packageManager }) => {
|
|
|
6480
6555
|
pnpm: `pnpm`,
|
|
6481
6556
|
npm: `npx`,
|
|
6482
6557
|
// npx is the way to run executables that aren't in your "scripts"
|
|
6483
|
-
yarn: `yarn
|
|
6558
|
+
yarn: `yarn`,
|
|
6559
|
+
bun: `bun run`
|
|
6484
6560
|
};
|
|
6485
6561
|
return `${packageManagers[packageManager]} tinacms dev -c "<your dev command>"`;
|
|
6486
6562
|
};
|
|
@@ -6493,7 +6569,8 @@ var frameworkDevCmds = {
|
|
|
6493
6569
|
pnpm: `pnpm`,
|
|
6494
6570
|
npm: `npm run`,
|
|
6495
6571
|
// npx is the way to run executables that aren't in your "scripts"
|
|
6496
|
-
yarn: `yarn
|
|
6572
|
+
yarn: `yarn`,
|
|
6573
|
+
bun: `bun run`
|
|
6497
6574
|
};
|
|
6498
6575
|
return `${packageManagers[packageManager]} dev`;
|
|
6499
6576
|
}
|
|
@@ -6506,7 +6583,7 @@ var addReactiveFile = {
|
|
|
6506
6583
|
baseDir,
|
|
6507
6584
|
dataLayer
|
|
6508
6585
|
}) => {
|
|
6509
|
-
const packageJsonPath =
|
|
6586
|
+
const packageJsonPath = path14.join(baseDir, "package.json");
|
|
6510
6587
|
await writeGeneratedFile({
|
|
6511
6588
|
generatedFile,
|
|
6512
6589
|
typescript: config2.typescript,
|
|
@@ -6519,7 +6596,7 @@ var addReactiveFile = {
|
|
|
6519
6596
|
})
|
|
6520
6597
|
});
|
|
6521
6598
|
logger.info("Adding a nextjs example... \u2705");
|
|
6522
|
-
const packageJson = JSON.parse(
|
|
6599
|
+
const packageJson = JSON.parse(fs14.readFileSync(packageJsonPath).toString());
|
|
6523
6600
|
const scripts = packageJson.scripts || {};
|
|
6524
6601
|
const updatedPackageJson = JSON.stringify(
|
|
6525
6602
|
{
|
|
@@ -6532,11 +6609,11 @@ var addReactiveFile = {
|
|
|
6532
6609
|
null,
|
|
6533
6610
|
2
|
|
6534
6611
|
);
|
|
6535
|
-
|
|
6612
|
+
fs14.writeFileSync(packageJsonPath, updatedPackageJson);
|
|
6536
6613
|
}
|
|
6537
6614
|
};
|
|
6538
6615
|
function execShellCommand(cmd) {
|
|
6539
|
-
const exec =
|
|
6616
|
+
const exec = __require("child_process").exec;
|
|
6540
6617
|
return new Promise((resolve2, reject) => {
|
|
6541
6618
|
exec(cmd, (error, stdout, stderr) => {
|
|
6542
6619
|
if (error) {
|
|
@@ -6582,34 +6659,27 @@ var command = new CLICommand({
|
|
|
6582
6659
|
});
|
|
6583
6660
|
|
|
6584
6661
|
// src/next/commands/init-command/index.ts
|
|
6585
|
-
var InitCommand = class extends
|
|
6586
|
-
|
|
6587
|
-
|
|
6588
|
-
|
|
6589
|
-
|
|
6590
|
-
|
|
6591
|
-
|
|
6592
|
-
|
|
6593
|
-
|
|
6594
|
-
|
|
6595
|
-
|
|
6596
|
-
|
|
6597
|
-
|
|
6598
|
-
|
|
6599
|
-
|
|
6600
|
-
|
|
6601
|
-
|
|
6602
|
-
|
|
6603
|
-
|
|
6604
|
-
|
|
6605
|
-
|
|
6606
|
-
}
|
|
6607
|
-
static {
|
|
6608
|
-
this.usage = import_clipanion6.Command.Usage({
|
|
6609
|
-
category: `Commands`,
|
|
6610
|
-
description: `Add Tina to an existing project`
|
|
6611
|
-
});
|
|
6612
|
-
}
|
|
6662
|
+
var InitCommand = class extends Command6 {
|
|
6663
|
+
static paths = [["init"], ["init", "backend"]];
|
|
6664
|
+
pathToForestryConfig = Option6.String("--forestryPath", {
|
|
6665
|
+
description: "Specify the relative path to the .forestry directory, if importing an existing forestry site."
|
|
6666
|
+
});
|
|
6667
|
+
rootPath = Option6.String("--rootPath", {
|
|
6668
|
+
description: "Specify the root directory to run the CLI from (defaults to current working directory)"
|
|
6669
|
+
});
|
|
6670
|
+
debug = Option6.Boolean("--debug", false, {
|
|
6671
|
+
description: "Enable debug logging"
|
|
6672
|
+
});
|
|
6673
|
+
noTelemetry = Option6.Boolean("--noTelemetry", false, {
|
|
6674
|
+
description: "Disable anonymous telemetry that is collected"
|
|
6675
|
+
});
|
|
6676
|
+
tinaVersion = Option6.String("--tinaVersion", {
|
|
6677
|
+
description: "Specify a version for tina dependencies"
|
|
6678
|
+
});
|
|
6679
|
+
static usage = Command6.Usage({
|
|
6680
|
+
category: `Commands`,
|
|
6681
|
+
description: `Add Tina to an existing project`
|
|
6682
|
+
});
|
|
6613
6683
|
async catch(error) {
|
|
6614
6684
|
logger.error("Error occured during tinacms init");
|
|
6615
6685
|
console.error(error);
|
|
@@ -6631,28 +6701,24 @@ var InitCommand = class extends import_clipanion6.Command {
|
|
|
6631
6701
|
};
|
|
6632
6702
|
|
|
6633
6703
|
// src/next/commands/searchindex-command/index.ts
|
|
6634
|
-
|
|
6635
|
-
|
|
6636
|
-
|
|
6637
|
-
|
|
6638
|
-
|
|
6639
|
-
|
|
6640
|
-
|
|
6641
|
-
|
|
6642
|
-
|
|
6643
|
-
|
|
6644
|
-
|
|
6645
|
-
|
|
6646
|
-
|
|
6647
|
-
|
|
6648
|
-
|
|
6649
|
-
|
|
6650
|
-
|
|
6651
|
-
|
|
6652
|
-
category: `Commands`,
|
|
6653
|
-
description: `Index the site for search`
|
|
6654
|
-
});
|
|
6655
|
-
}
|
|
6704
|
+
import { Command as Command7, Option as Option7 } from "clipanion";
|
|
6705
|
+
import { createSchema, FilesystemBridge as FilesystemBridge4 } from "@tinacms/graphql";
|
|
6706
|
+
import {
|
|
6707
|
+
SearchIndexer as SearchIndexer3,
|
|
6708
|
+
TinaCMSSearchIndexClient as TinaCMSSearchIndexClient2
|
|
6709
|
+
} from "@tinacms/search";
|
|
6710
|
+
var SearchIndexCommand = class extends Command7 {
|
|
6711
|
+
static paths = [["search-index"]];
|
|
6712
|
+
rootPath = Option7.String("--rootPath", {
|
|
6713
|
+
description: "Specify the root directory to run the CLI from (defaults to current working directory)"
|
|
6714
|
+
});
|
|
6715
|
+
verbose = Option7.Boolean("-v,--verbose", false, {
|
|
6716
|
+
description: "increase verbosity of logged output"
|
|
6717
|
+
});
|
|
6718
|
+
static usage = Command7.Usage({
|
|
6719
|
+
category: `Commands`,
|
|
6720
|
+
description: `Index the site for search`
|
|
6721
|
+
});
|
|
6656
6722
|
async catch(error) {
|
|
6657
6723
|
logger.error("Error occured during tinacms search-index");
|
|
6658
6724
|
console.error(error);
|
|
@@ -6674,7 +6740,7 @@ var SearchIndexCommand = class extends import_clipanion7.Command {
|
|
|
6674
6740
|
process.exit(1);
|
|
6675
6741
|
}
|
|
6676
6742
|
const { schema } = configManager.config;
|
|
6677
|
-
const tinaSchema = await
|
|
6743
|
+
const tinaSchema = await createSchema({
|
|
6678
6744
|
schema: { ...schema, config: configManager.config }
|
|
6679
6745
|
});
|
|
6680
6746
|
let client;
|
|
@@ -6702,7 +6768,7 @@ var SearchIndexCommand = class extends import_clipanion7.Command {
|
|
|
6702
6768
|
"indexerToken not configured in tina search configuration."
|
|
6703
6769
|
);
|
|
6704
6770
|
}
|
|
6705
|
-
client = new
|
|
6771
|
+
client = new TinaCMSSearchIndexClient2({
|
|
6706
6772
|
apiUrl: `${configManager.config.tinaioConfig?.contentApiUrlOverride || "https://content.tinajs.io"}/searchIndex/${configManager.config?.clientId}`,
|
|
6707
6773
|
branch: configManager.config?.branch,
|
|
6708
6774
|
indexerToken: configManager.config?.search?.tina?.indexerToken,
|
|
@@ -6711,9 +6777,9 @@ var SearchIndexCommand = class extends import_clipanion7.Command {
|
|
|
6711
6777
|
} else {
|
|
6712
6778
|
client = configManager.config?.search?.searchClient;
|
|
6713
6779
|
}
|
|
6714
|
-
const searchIndexer = new
|
|
6780
|
+
const searchIndexer = new SearchIndexer3({
|
|
6715
6781
|
batchSize: configManager.config.search?.indexBatchSize || 100,
|
|
6716
|
-
bridge: new
|
|
6782
|
+
bridge: new FilesystemBridge4(
|
|
6717
6783
|
configManager.rootPath,
|
|
6718
6784
|
configManager.contentRootPath
|
|
6719
6785
|
),
|
|
@@ -6741,7 +6807,7 @@ var SearchIndexCommand = class extends import_clipanion7.Command {
|
|
|
6741
6807
|
};
|
|
6742
6808
|
|
|
6743
6809
|
// src/index.ts
|
|
6744
|
-
var cli = new
|
|
6810
|
+
var cli = new Cli({
|
|
6745
6811
|
binaryName: `tinacms`,
|
|
6746
6812
|
binaryLabel: `TinaCMS`,
|
|
6747
6813
|
binaryVersion: version
|
|
@@ -6752,7 +6818,10 @@ cli.register(AuditCommand);
|
|
|
6752
6818
|
cli.register(InitCommand);
|
|
6753
6819
|
cli.register(CodemodCommand);
|
|
6754
6820
|
cli.register(SearchIndexCommand);
|
|
6755
|
-
cli.register(
|
|
6756
|
-
cli.register(
|
|
6757
|
-
cli.register(
|
|
6821
|
+
cli.register(Builtins.DefinitionsCommand);
|
|
6822
|
+
cli.register(Builtins.HelpCommand);
|
|
6823
|
+
cli.register(Builtins.VersionCommand);
|
|
6758
6824
|
var index_default = cli;
|
|
6825
|
+
export {
|
|
6826
|
+
index_default as default
|
|
6827
|
+
};
|