@tinacms/cli 0.0.0-9c781c0-20250801015431 → 0.0.0-9d35253-20251202065744
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 +916 -848
- 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,14 +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
|
},
|
|
1930
2013
|
fastRefresh: false
|
|
1931
2014
|
}),
|
|
1932
|
-
|
|
2015
|
+
splitVendorChunkPlugin(),
|
|
1933
2016
|
tinaTailwind(configManager.spaRootPath, configManager.prebuildFilePath),
|
|
1934
2017
|
...plugins
|
|
1935
2018
|
]
|
|
@@ -1938,21 +2021,21 @@ var createConfig = async ({
|
|
|
1938
2021
|
};
|
|
1939
2022
|
|
|
1940
2023
|
// src/next/vite/plugins.ts
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
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";
|
|
1949
2032
|
|
|
1950
2033
|
// src/next/commands/dev-command/server/media.ts
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
2034
|
+
import fs5 from "fs-extra";
|
|
2035
|
+
import path6, { join } from "path";
|
|
2036
|
+
import busboy from "busboy";
|
|
1954
2037
|
var createMediaRouter = (config2) => {
|
|
1955
|
-
const mediaFolder =
|
|
2038
|
+
const mediaFolder = path6.join(
|
|
1956
2039
|
config2.rootPath,
|
|
1957
2040
|
config2.publicFolder,
|
|
1958
2041
|
config2.mediaRoot
|
|
@@ -1976,12 +2059,12 @@ var createMediaRouter = (config2) => {
|
|
|
1976
2059
|
res.end(JSON.stringify(didDelete));
|
|
1977
2060
|
};
|
|
1978
2061
|
const handlePost = async function(req, res) {
|
|
1979
|
-
const bb = (
|
|
2062
|
+
const bb = busboy({ headers: req.headers });
|
|
1980
2063
|
bb.on("file", async (_name, file, _info) => {
|
|
1981
2064
|
const fullPath = decodeURI(req.url?.slice("/media/upload/".length));
|
|
1982
|
-
const saveTo =
|
|
1983
|
-
await
|
|
1984
|
-
file.pipe(
|
|
2065
|
+
const saveTo = path6.join(mediaFolder, ...fullPath.split("/"));
|
|
2066
|
+
await fs5.ensureDir(path6.dirname(saveTo));
|
|
2067
|
+
file.pipe(fs5.createWriteStream(saveTo));
|
|
1985
2068
|
});
|
|
1986
2069
|
bb.on("error", (error) => {
|
|
1987
2070
|
res.statusCode = 500;
|
|
@@ -2007,6 +2090,9 @@ var parseMediaFolder = (str) => {
|
|
|
2007
2090
|
return returnString;
|
|
2008
2091
|
};
|
|
2009
2092
|
var MediaModel = class {
|
|
2093
|
+
rootPath;
|
|
2094
|
+
publicFolder;
|
|
2095
|
+
mediaRoot;
|
|
2010
2096
|
constructor({ rootPath, publicFolder, mediaRoot }) {
|
|
2011
2097
|
this.rootPath = rootPath;
|
|
2012
2098
|
this.mediaRoot = mediaRoot;
|
|
@@ -2014,23 +2100,23 @@ var MediaModel = class {
|
|
|
2014
2100
|
}
|
|
2015
2101
|
async listMedia(args) {
|
|
2016
2102
|
try {
|
|
2017
|
-
const folderPath =
|
|
2103
|
+
const folderPath = join(
|
|
2018
2104
|
this.rootPath,
|
|
2019
2105
|
this.publicFolder,
|
|
2020
2106
|
this.mediaRoot,
|
|
2021
2107
|
decodeURIComponent(args.searchPath)
|
|
2022
2108
|
);
|
|
2023
2109
|
const searchPath = parseMediaFolder(args.searchPath);
|
|
2024
|
-
if (!await
|
|
2110
|
+
if (!await fs5.pathExists(folderPath)) {
|
|
2025
2111
|
return {
|
|
2026
2112
|
files: [],
|
|
2027
2113
|
directories: []
|
|
2028
2114
|
};
|
|
2029
2115
|
}
|
|
2030
|
-
const filesStr = await
|
|
2116
|
+
const filesStr = await fs5.readdir(folderPath);
|
|
2031
2117
|
const filesProm = filesStr.map(async (file) => {
|
|
2032
|
-
const filePath =
|
|
2033
|
-
const stat = await
|
|
2118
|
+
const filePath = join(folderPath, file);
|
|
2119
|
+
const stat = await fs5.stat(filePath);
|
|
2034
2120
|
let src = `/${file}`;
|
|
2035
2121
|
const isFile = stat.isFile();
|
|
2036
2122
|
if (!isFile) {
|
|
@@ -2086,14 +2172,14 @@ var MediaModel = class {
|
|
|
2086
2172
|
}
|
|
2087
2173
|
async deleteMedia(args) {
|
|
2088
2174
|
try {
|
|
2089
|
-
const file =
|
|
2175
|
+
const file = join(
|
|
2090
2176
|
this.rootPath,
|
|
2091
2177
|
this.publicFolder,
|
|
2092
2178
|
this.mediaRoot,
|
|
2093
2179
|
decodeURIComponent(args.searchPath)
|
|
2094
2180
|
);
|
|
2095
|
-
await
|
|
2096
|
-
await
|
|
2181
|
+
await fs5.stat(file);
|
|
2182
|
+
await fs5.remove(file);
|
|
2097
2183
|
return { ok: true };
|
|
2098
2184
|
} catch (error) {
|
|
2099
2185
|
console.error(error);
|
|
@@ -2151,9 +2237,9 @@ var transformTsxPlugin = ({
|
|
|
2151
2237
|
const plug = {
|
|
2152
2238
|
name: "transform-tsx",
|
|
2153
2239
|
async transform(code, id) {
|
|
2154
|
-
const extName =
|
|
2240
|
+
const extName = path7.extname(id);
|
|
2155
2241
|
if (extName.startsWith(".tsx") || extName.startsWith(".ts")) {
|
|
2156
|
-
const result = await (
|
|
2242
|
+
const result = await esbuildTransform(code, { loader: "tsx" });
|
|
2157
2243
|
return {
|
|
2158
2244
|
code: result.code
|
|
2159
2245
|
};
|
|
@@ -2172,8 +2258,8 @@ var devServerEndPointsPlugin = ({
|
|
|
2172
2258
|
const plug = {
|
|
2173
2259
|
name: "graphql-endpoints",
|
|
2174
2260
|
configureServer(server) {
|
|
2175
|
-
server.middlewares.use((
|
|
2176
|
-
server.middlewares.use(
|
|
2261
|
+
server.middlewares.use(cors());
|
|
2262
|
+
server.middlewares.use(bodyParser.json({ limit: "5mb" }));
|
|
2177
2263
|
server.middlewares.use(async (req, res, next) => {
|
|
2178
2264
|
const mediaPaths = configManager.config.media?.tina;
|
|
2179
2265
|
const mediaRouter = createMediaRouter({
|
|
@@ -2212,7 +2298,7 @@ var devServerEndPointsPlugin = ({
|
|
|
2212
2298
|
const { query, variables } = req.body;
|
|
2213
2299
|
let result;
|
|
2214
2300
|
await databaseLock(async () => {
|
|
2215
|
-
result = await (
|
|
2301
|
+
result = await gqlResolve({
|
|
2216
2302
|
config: {
|
|
2217
2303
|
useRelativeMedia: true
|
|
2218
2304
|
},
|
|
@@ -2248,13 +2334,13 @@ function viteTransformExtension({
|
|
|
2248
2334
|
include = "**/*.svg",
|
|
2249
2335
|
exclude
|
|
2250
2336
|
} = {}) {
|
|
2251
|
-
const filter =
|
|
2337
|
+
const filter = createFilter(include, exclude);
|
|
2252
2338
|
return {
|
|
2253
2339
|
name: "vite-plugin-svgr",
|
|
2254
2340
|
async transform(code, id) {
|
|
2255
2341
|
if (filter(id)) {
|
|
2256
2342
|
const { transform: transform2 } = await import("@svgr/core");
|
|
2257
|
-
const svgCode = await
|
|
2343
|
+
const svgCode = await fs6.promises.readFile(
|
|
2258
2344
|
id.replace(/\?.*$/, ""),
|
|
2259
2345
|
"utf8"
|
|
2260
2346
|
);
|
|
@@ -2264,7 +2350,7 @@ function viteTransformExtension({
|
|
|
2264
2350
|
previousExport: exportAsDefault ? null : code
|
|
2265
2351
|
}
|
|
2266
2352
|
});
|
|
2267
|
-
const res = await
|
|
2353
|
+
const res = await transformWithEsbuild(componentCode, id, {
|
|
2268
2354
|
loader: "jsx",
|
|
2269
2355
|
...esbuildOptions
|
|
2270
2356
|
});
|
|
@@ -2291,7 +2377,7 @@ var createDevServer = async (configManager, database, searchIndex, apiURL, noWat
|
|
|
2291
2377
|
}),
|
|
2292
2378
|
viteTransformExtension()
|
|
2293
2379
|
];
|
|
2294
|
-
return (
|
|
2380
|
+
return createViteServer(
|
|
2295
2381
|
await createConfig({
|
|
2296
2382
|
configManager,
|
|
2297
2383
|
database,
|
|
@@ -2321,37 +2407,30 @@ var createDevServer = async (configManager, database, searchIndex, apiURL, noWat
|
|
|
2321
2407
|
|
|
2322
2408
|
// src/next/commands/dev-command/index.ts
|
|
2323
2409
|
var DevCommand = class extends BaseCommand {
|
|
2324
|
-
|
|
2325
|
-
|
|
2326
|
-
|
|
2327
|
-
this
|
|
2328
|
-
|
|
2329
|
-
|
|
2330
|
-
|
|
2331
|
-
|
|
2332
|
-
|
|
2333
|
-
|
|
2334
|
-
|
|
2335
|
-
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
-
|
|
2344
|
-
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
|
|
2348
|
-
description: `Builds Tina and starts the dev server`,
|
|
2349
|
-
examples: [
|
|
2350
|
-
[`A basic example`, `$0 dev`],
|
|
2351
|
-
[`A second example`, `$0 dev --rootPath`]
|
|
2352
|
-
]
|
|
2353
|
-
});
|
|
2354
|
-
}
|
|
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
|
+
});
|
|
2355
2434
|
async catch(error) {
|
|
2356
2435
|
logger.error("Error occured during tinacms dev");
|
|
2357
2436
|
console.error(error);
|
|
@@ -2388,7 +2467,7 @@ var DevCommand = class extends BaseCommand {
|
|
|
2388
2467
|
} else {
|
|
2389
2468
|
database.clearCache();
|
|
2390
2469
|
}
|
|
2391
|
-
const { tinaSchema: tinaSchema2, graphQLSchema: graphQLSchema2, lookup, queryDoc, fragDoc } = await
|
|
2470
|
+
const { tinaSchema: tinaSchema2, graphQLSchema: graphQLSchema2, lookup, queryDoc, fragDoc } = await buildSchema(configManager.config);
|
|
2392
2471
|
const codegen2 = new Codegen({
|
|
2393
2472
|
isLocal: true,
|
|
2394
2473
|
configManager,
|
|
@@ -2402,29 +2481,32 @@ var DevCommand = class extends BaseCommand {
|
|
|
2402
2481
|
});
|
|
2403
2482
|
const apiURL2 = await codegen2.execute();
|
|
2404
2483
|
if (!configManager.isUsingLegacyFolder) {
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
|
|
2408
|
-
const
|
|
2409
|
-
|
|
2410
|
-
|
|
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
|
+
);
|
|
2411
2493
|
const tinaLockFilename = "tina-lock.json";
|
|
2412
2494
|
const tinaLockContent = JSON.stringify({
|
|
2413
2495
|
schema: schemaObject,
|
|
2414
2496
|
lookup: lookupObject,
|
|
2415
2497
|
graphql: graphqlSchemaObject
|
|
2416
2498
|
});
|
|
2417
|
-
|
|
2418
|
-
|
|
2499
|
+
fs7.writeFileSync(
|
|
2500
|
+
path8.join(configManager.tinaFolderPath, tinaLockFilename),
|
|
2419
2501
|
tinaLockContent
|
|
2420
2502
|
);
|
|
2421
2503
|
if (configManager.hasSeparateContentRoot()) {
|
|
2422
2504
|
const rootPath = await configManager.getTinaFolderPath(
|
|
2423
2505
|
configManager.contentRootPath
|
|
2424
2506
|
);
|
|
2425
|
-
const filePath =
|
|
2426
|
-
await
|
|
2427
|
-
await
|
|
2507
|
+
const filePath = path8.join(rootPath, tinaLockFilename);
|
|
2508
|
+
await fs7.ensureFile(filePath);
|
|
2509
|
+
await fs7.outputFile(filePath, tinaLockContent);
|
|
2428
2510
|
}
|
|
2429
2511
|
}
|
|
2430
2512
|
await this.indexContentWithSpinner({
|
|
@@ -2467,19 +2549,19 @@ ${dangerText(e.message)}
|
|
|
2467
2549
|
const { apiURL, graphQLSchema, tinaSchema } = await setup({
|
|
2468
2550
|
firstTime: true
|
|
2469
2551
|
});
|
|
2470
|
-
await
|
|
2471
|
-
await
|
|
2552
|
+
await fs7.outputFile(configManager.outputHTMLFilePath, devHTML(this.port));
|
|
2553
|
+
await fs7.outputFile(
|
|
2472
2554
|
configManager.outputGitignorePath,
|
|
2473
2555
|
"index.html\nassets/"
|
|
2474
2556
|
);
|
|
2475
|
-
const searchIndexClient = new
|
|
2557
|
+
const searchIndexClient = new LocalSearchIndexClient({
|
|
2476
2558
|
stopwordLanguages: configManager.config.search?.tina?.stopwordLanguages,
|
|
2477
2559
|
tokenSplitRegex: configManager.config.search?.tina?.tokenSplitRegex
|
|
2478
2560
|
});
|
|
2479
2561
|
await searchIndexClient.onStartIndexing();
|
|
2480
|
-
const searchIndexer = new
|
|
2562
|
+
const searchIndexer = new SearchIndexer({
|
|
2481
2563
|
batchSize: configManager.config.search?.indexBatchSize || 100,
|
|
2482
|
-
bridge: new
|
|
2564
|
+
bridge: new FilesystemBridge2(
|
|
2483
2565
|
configManager.rootPath,
|
|
2484
2566
|
configManager.contentRootPath
|
|
2485
2567
|
),
|
|
@@ -2520,7 +2602,7 @@ ${dangerText(e.message)}
|
|
|
2520
2602
|
);
|
|
2521
2603
|
await server.listen(Number(this.port));
|
|
2522
2604
|
if (!this.noWatch) {
|
|
2523
|
-
|
|
2605
|
+
chokidar.watch(configManager.watchList).on("change", async () => {
|
|
2524
2606
|
await dbLock(async () => {
|
|
2525
2607
|
logger.info(`Tina config change detected, rebuilding`);
|
|
2526
2608
|
await setup({ firstTime: false });
|
|
@@ -2582,11 +2664,11 @@ ${dangerText(e.message)}
|
|
|
2582
2664
|
// subItems: [
|
|
2583
2665
|
// {
|
|
2584
2666
|
// key: 'Custom queries',
|
|
2585
|
-
// value: 'https://tina.io/
|
|
2667
|
+
// value: 'https://tina.io/docs/r/content-api-overview',
|
|
2586
2668
|
// },
|
|
2587
2669
|
// {
|
|
2588
2670
|
// key: 'Visual editing',
|
|
2589
|
-
// value: 'https://tina.io/visual-editing',
|
|
2671
|
+
// value: 'https://tina.io/docs/r/visual-editing-setup',
|
|
2590
2672
|
// },
|
|
2591
2673
|
// ],
|
|
2592
2674
|
// },
|
|
@@ -2597,14 +2679,14 @@ ${dangerText(e.message)}
|
|
|
2597
2679
|
watchContentFiles(configManager, database, databaseLock, searchIndexer) {
|
|
2598
2680
|
const collectionContentFiles = [];
|
|
2599
2681
|
configManager.config.schema.collections.forEach((collection) => {
|
|
2600
|
-
const collectionGlob = `${
|
|
2682
|
+
const collectionGlob = `${path8.join(
|
|
2601
2683
|
configManager.contentRootPath,
|
|
2602
2684
|
collection.path
|
|
2603
2685
|
)}/**/*.${collection.format || "md"}`;
|
|
2604
2686
|
collectionContentFiles.push(collectionGlob);
|
|
2605
2687
|
});
|
|
2606
2688
|
let ready = false;
|
|
2607
|
-
|
|
2689
|
+
chokidar.watch(collectionContentFiles).on("ready", () => {
|
|
2608
2690
|
ready = true;
|
|
2609
2691
|
}).on("add", async (addedFile) => {
|
|
2610
2692
|
if (!ready) {
|
|
@@ -2641,28 +2723,35 @@ ${dangerText(e.message)}
|
|
|
2641
2723
|
await callback();
|
|
2642
2724
|
});
|
|
2643
2725
|
};
|
|
2644
|
-
|
|
2726
|
+
chokidar.watch(configManager.userQueriesAndFragmentsGlob).on("add", executeCallback).on("change", executeCallback).on("unlink", executeCallback);
|
|
2645
2727
|
}
|
|
2646
2728
|
};
|
|
2647
2729
|
|
|
2648
2730
|
// src/next/commands/build-command/index.ts
|
|
2649
|
-
|
|
2650
|
-
|
|
2651
|
-
|
|
2652
|
-
|
|
2653
|
-
|
|
2654
|
-
|
|
2655
|
-
|
|
2656
|
-
|
|
2657
|
-
|
|
2658
|
-
|
|
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";
|
|
2659
2748
|
|
|
2660
2749
|
// src/utils/index.ts
|
|
2661
|
-
|
|
2750
|
+
import { ChangeType } from "@graphql-inspector/core";
|
|
2662
2751
|
var getFaqLink = (type) => {
|
|
2663
2752
|
switch (type) {
|
|
2664
|
-
case
|
|
2665
|
-
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";
|
|
2666
2755
|
}
|
|
2667
2756
|
default:
|
|
2668
2757
|
return null;
|
|
@@ -2683,7 +2772,7 @@ async function sleepAndCallFunc({
|
|
|
2683
2772
|
}
|
|
2684
2773
|
|
|
2685
2774
|
// src/next/commands/build-command/server.ts
|
|
2686
|
-
|
|
2775
|
+
import { build as build2 } from "vite";
|
|
2687
2776
|
var buildProductionSpa = async (configManager, database, apiURL) => {
|
|
2688
2777
|
const publicEnv = {};
|
|
2689
2778
|
Object.keys(process.env).forEach((key) => {
|
|
@@ -2717,12 +2806,12 @@ var buildProductionSpa = async (configManager, database, apiURL) => {
|
|
|
2717
2806
|
}
|
|
2718
2807
|
}
|
|
2719
2808
|
});
|
|
2720
|
-
return (
|
|
2809
|
+
return build2(config2);
|
|
2721
2810
|
};
|
|
2722
2811
|
|
|
2723
2812
|
// src/next/commands/build-command/waitForDB.ts
|
|
2724
|
-
|
|
2725
|
-
|
|
2813
|
+
import { parseURL } from "@tinacms/schema-tools";
|
|
2814
|
+
import Progress from "progress";
|
|
2726
2815
|
var POLLING_INTERVAL = 5e3;
|
|
2727
2816
|
var STATUS_INPROGRESS = "inprogress";
|
|
2728
2817
|
var STATUS_COMPLETE = "complete";
|
|
@@ -2735,14 +2824,14 @@ var IndexFailedError = class extends Error {
|
|
|
2735
2824
|
};
|
|
2736
2825
|
var waitForDB = async (config2, apiUrl, previewName, verbose) => {
|
|
2737
2826
|
const token = config2.token;
|
|
2738
|
-
const { clientId, branch, isLocalClient, host } =
|
|
2827
|
+
const { clientId, branch, isLocalClient, host } = parseURL(apiUrl);
|
|
2739
2828
|
if (isLocalClient || !host || !clientId || !branch) {
|
|
2740
2829
|
if (verbose) {
|
|
2741
2830
|
logger.info(logText("Not using TinaCloud, skipping DB check"));
|
|
2742
2831
|
}
|
|
2743
2832
|
return;
|
|
2744
2833
|
}
|
|
2745
|
-
const bar2 = new
|
|
2834
|
+
const bar2 = new Progress(
|
|
2746
2835
|
"Checking indexing process in TinaCloud... :prog",
|
|
2747
2836
|
1
|
|
2748
2837
|
);
|
|
@@ -2805,51 +2894,44 @@ var waitForDB = async (config2, apiUrl, previewName, verbose) => {
|
|
|
2805
2894
|
|
|
2806
2895
|
// src/next/commands/build-command/index.ts
|
|
2807
2896
|
var BuildCommand = class extends BaseCommand {
|
|
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
|
-
}
|
|
2847
|
-
static {
|
|
2848
|
-
this.usage = import_clipanion3.Command.Usage({
|
|
2849
|
-
category: `Commands`,
|
|
2850
|
-
description: `Build the CMS and autogenerated modules for usage with TinaCloud`
|
|
2851
|
-
});
|
|
2852
|
-
}
|
|
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
|
+
});
|
|
2853
2935
|
async catch(error) {
|
|
2854
2936
|
console.error(error);
|
|
2855
2937
|
process.exit(1);
|
|
@@ -2894,7 +2976,7 @@ ${dangerText(e.message)}`);
|
|
|
2894
2976
|
configManager,
|
|
2895
2977
|
Number(this.datalayerPort)
|
|
2896
2978
|
);
|
|
2897
|
-
const { queryDoc, fragDoc, graphQLSchema, tinaSchema, lookup } = await (
|
|
2979
|
+
const { queryDoc, fragDoc, graphQLSchema, tinaSchema, lookup } = await buildSchema2(configManager.config);
|
|
2898
2980
|
const codegen2 = new Codegen({
|
|
2899
2981
|
configManager,
|
|
2900
2982
|
port: this.localOption ? Number(this.port) : void 0,
|
|
@@ -3002,7 +3084,7 @@ ${dangerText(e.message)}
|
|
|
3002
3084
|
}
|
|
3003
3085
|
}
|
|
3004
3086
|
await buildProductionSpa(configManager, database, codegen2.productionUrl);
|
|
3005
|
-
await
|
|
3087
|
+
await fs8.outputFile(
|
|
3006
3088
|
configManager.outputGitignorePath,
|
|
3007
3089
|
"index.html\nassets/"
|
|
3008
3090
|
);
|
|
@@ -3034,7 +3116,7 @@ ${dangerText(e.message)}
|
|
|
3034
3116
|
"indexerToken not configured in tina search configuration."
|
|
3035
3117
|
);
|
|
3036
3118
|
}
|
|
3037
|
-
client = new
|
|
3119
|
+
client = new TinaCMSSearchIndexClient({
|
|
3038
3120
|
apiUrl: `${configManager.config.tinaioConfig?.contentApiUrlOverride || "https://content.tinajs.io"}/searchIndex/${configManager.config?.clientId}`,
|
|
3039
3121
|
branch: configManager.config?.branch,
|
|
3040
3122
|
indexerToken: configManager.config?.search?.tina?.indexerToken,
|
|
@@ -3043,9 +3125,9 @@ ${dangerText(e.message)}
|
|
|
3043
3125
|
} else {
|
|
3044
3126
|
client = configManager.config?.search?.searchClient;
|
|
3045
3127
|
}
|
|
3046
|
-
const searchIndexer = new
|
|
3128
|
+
const searchIndexer = new SearchIndexer2({
|
|
3047
3129
|
batchSize: configManager.config.search?.indexBatchSize || 100,
|
|
3048
|
-
bridge: new
|
|
3130
|
+
bridge: new FilesystemBridge3(
|
|
3049
3131
|
configManager.rootPath,
|
|
3050
3132
|
configManager.contentRootPath
|
|
3051
3133
|
),
|
|
@@ -3115,8 +3197,8 @@ ${dangerText(e.message)}
|
|
|
3115
3197
|
const MAX_RETRIES = 5;
|
|
3116
3198
|
const { config: config2 } = configManager;
|
|
3117
3199
|
const token = config2.token;
|
|
3118
|
-
const { clientId, branch, host } = (
|
|
3119
|
-
const bar2 = new
|
|
3200
|
+
const { clientId, branch, host } = parseURL2(apiURL);
|
|
3201
|
+
const bar2 = new Progress2("Checking clientId and token. :prog", 1);
|
|
3120
3202
|
const getBranchInfo = async () => {
|
|
3121
3203
|
const url = `https://${host}/db/${clientId}/status/${previewBaseBranch || branch}`;
|
|
3122
3204
|
const branchInfo2 = {
|
|
@@ -3170,7 +3252,7 @@ ${dangerText(e.message)}
|
|
|
3170
3252
|
bar2.tick({
|
|
3171
3253
|
prog: "\u2705"
|
|
3172
3254
|
});
|
|
3173
|
-
const branchBar = new
|
|
3255
|
+
const branchBar = new Progress2(
|
|
3174
3256
|
`Checking branch '${config2.branch}' is on TinaCloud. :prog`,
|
|
3175
3257
|
1
|
|
3176
3258
|
);
|
|
@@ -3210,7 +3292,7 @@ ${dangerText(e.message)}
|
|
|
3210
3292
|
async syncProject(configManager, apiURL, options) {
|
|
3211
3293
|
const { config: config2 } = configManager;
|
|
3212
3294
|
const token = config2.token;
|
|
3213
|
-
const { clientId, branch, host } = (
|
|
3295
|
+
const { clientId, branch, host } = parseURL2(apiURL);
|
|
3214
3296
|
const { previewName, previewBaseBranch, upstreamBranch } = options || {};
|
|
3215
3297
|
let url = `https://${host}/db/${clientId}/reset/${branch}?refreshSchema=true&skipIfSchemaCurrent=true`;
|
|
3216
3298
|
if (upstreamBranch && previewBaseBranch && previewName) {
|
|
@@ -3220,7 +3302,7 @@ ${dangerText(e.message)}
|
|
|
3220
3302
|
} else if (upstreamBranch && !previewBaseBranch && !previewName) {
|
|
3221
3303
|
url = `https://${host}/db/${clientId}/reset/${branch}?refreshSchema=true&skipIfSchemaCurrent=true&upstreamBranch=${upstreamBranch}`;
|
|
3222
3304
|
}
|
|
3223
|
-
const bar2 = new
|
|
3305
|
+
const bar2 = new Progress2("Syncing Project. :prog", 1);
|
|
3224
3306
|
try {
|
|
3225
3307
|
const res = await request({
|
|
3226
3308
|
token,
|
|
@@ -3261,7 +3343,7 @@ ${dangerText(e.message)}
|
|
|
3261
3343
|
}
|
|
3262
3344
|
}
|
|
3263
3345
|
async checkGraphqlSchema(configManager, database, apiURL, timestamp) {
|
|
3264
|
-
const bar2 = new
|
|
3346
|
+
const bar2 = new Progress2(
|
|
3265
3347
|
"Checking local GraphQL Schema matches server. :prog",
|
|
3266
3348
|
1
|
|
3267
3349
|
);
|
|
@@ -3283,11 +3365,11 @@ Additional info: Branch: ${config2.branch}, Client ID: ${config2.clientId} `;
|
|
|
3283
3365
|
}
|
|
3284
3366
|
throw new Error(errorMessage);
|
|
3285
3367
|
}
|
|
3286
|
-
const remoteGqlSchema =
|
|
3368
|
+
const remoteGqlSchema = buildClientSchema(remoteSchema);
|
|
3287
3369
|
const localSchemaDocument = await database.getGraphQLSchemaFromBridge();
|
|
3288
|
-
const localGraphqlSchema = (
|
|
3370
|
+
const localGraphqlSchema = buildASTSchema2(localSchemaDocument);
|
|
3289
3371
|
try {
|
|
3290
|
-
const diffResult = await
|
|
3372
|
+
const diffResult = await diff(remoteGqlSchema, localGraphqlSchema);
|
|
3291
3373
|
if (diffResult.length === 0) {
|
|
3292
3374
|
bar2.tick({
|
|
3293
3375
|
prog: "\u2705"
|
|
@@ -3335,13 +3417,13 @@ Additional info:
|
|
|
3335
3417
|
}
|
|
3336
3418
|
}
|
|
3337
3419
|
async checkTinaSchema(configManager, database, apiURL, previewName, verbose, timestamp) {
|
|
3338
|
-
const bar2 = new
|
|
3420
|
+
const bar2 = new Progress2(
|
|
3339
3421
|
"Checking local Tina Schema matches server. :prog",
|
|
3340
3422
|
1
|
|
3341
3423
|
);
|
|
3342
3424
|
const { config: config2 } = configManager;
|
|
3343
3425
|
const token = config2.token;
|
|
3344
|
-
const { clientId, branch, isLocalClient, host } = (
|
|
3426
|
+
const { clientId, branch, isLocalClient, host } = parseURL2(apiURL);
|
|
3345
3427
|
if (isLocalClient || !host || !clientId || !branch) {
|
|
3346
3428
|
if (verbose) {
|
|
3347
3429
|
logger.info(logText("Not using TinaCloud, skipping Tina Schema check"));
|
|
@@ -3369,11 +3451,11 @@ Additional info: Branch: ${config2.branch}, Client ID: ${config2.clientId} `;
|
|
|
3369
3451
|
}
|
|
3370
3452
|
const localTinaSchema = JSON.parse(
|
|
3371
3453
|
await database.bridge.get(
|
|
3372
|
-
|
|
3454
|
+
path9.join(database.tinaDirectory, "__generated__", "_schema.json")
|
|
3373
3455
|
)
|
|
3374
3456
|
);
|
|
3375
3457
|
localTinaSchema.version = void 0;
|
|
3376
|
-
const localTinaSchemaSha =
|
|
3458
|
+
const localTinaSchemaSha = crypto.createHash("sha256").update(JSON.stringify(localTinaSchema)).digest("hex");
|
|
3377
3459
|
if (localTinaSchemaSha === remoteTinaSchemaSha) {
|
|
3378
3460
|
bar2.tick({
|
|
3379
3461
|
prog: "\u2705"
|
|
@@ -3424,12 +3506,12 @@ async function request(args) {
|
|
|
3424
3506
|
Message from server: ${json.message}`;
|
|
3425
3507
|
}
|
|
3426
3508
|
throw new Error(
|
|
3427
|
-
`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/`
|
|
3428
3510
|
);
|
|
3429
3511
|
}
|
|
3430
3512
|
if (json.errors) {
|
|
3431
3513
|
throw new Error(
|
|
3432
|
-
`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/
|
|
3433
3515
|
|
|
3434
3516
|
Errors:
|
|
3435
3517
|
${json.errors.map((error) => error.message).join("\n")}`
|
|
@@ -3451,7 +3533,7 @@ var fetchRemoteGraphqlSchema = async ({
|
|
|
3451
3533
|
headers.append("X-API-KEY", token);
|
|
3452
3534
|
}
|
|
3453
3535
|
const body = JSON.stringify({
|
|
3454
|
-
query:
|
|
3536
|
+
query: getIntrospectionQuery(),
|
|
3455
3537
|
variables: {}
|
|
3456
3538
|
});
|
|
3457
3539
|
headers.append("Content-Type", "application/json");
|
|
@@ -3484,14 +3566,14 @@ var fetchSchemaSha = async ({
|
|
|
3484
3566
|
};
|
|
3485
3567
|
|
|
3486
3568
|
// src/next/commands/audit-command/index.ts
|
|
3487
|
-
|
|
3488
|
-
|
|
3569
|
+
import { Command as Command4, Option as Option4 } from "clipanion";
|
|
3570
|
+
import { buildSchema as buildSchema3 } from "@tinacms/graphql";
|
|
3489
3571
|
|
|
3490
3572
|
// src/next/commands/audit-command/audit.ts
|
|
3491
|
-
|
|
3492
|
-
|
|
3493
|
-
|
|
3494
|
-
|
|
3573
|
+
import prompts from "prompts";
|
|
3574
|
+
import { Telemetry } from "@tinacms/metrics";
|
|
3575
|
+
import { resolve } from "@tinacms/graphql";
|
|
3576
|
+
import chalk5 from "chalk";
|
|
3495
3577
|
var audit = async ({
|
|
3496
3578
|
database,
|
|
3497
3579
|
clean,
|
|
@@ -3499,7 +3581,7 @@ var audit = async ({
|
|
|
3499
3581
|
noTelemetry,
|
|
3500
3582
|
verbose
|
|
3501
3583
|
}) => {
|
|
3502
|
-
const telemetry = new
|
|
3584
|
+
const telemetry = new Telemetry({ disabled: noTelemetry });
|
|
3503
3585
|
await telemetry.submitRecord({
|
|
3504
3586
|
event: {
|
|
3505
3587
|
name: "tinacms:cli:audit:invoke",
|
|
@@ -3509,25 +3591,25 @@ var audit = async ({
|
|
|
3509
3591
|
});
|
|
3510
3592
|
if (clean) {
|
|
3511
3593
|
logger.info(
|
|
3512
|
-
`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(
|
|
3513
3595
|
"clean git tree"
|
|
3514
3596
|
)} so unwanted changes can be undone.
|
|
3515
3597
|
|
|
3516
3598
|
`
|
|
3517
3599
|
);
|
|
3518
|
-
const res = await (
|
|
3600
|
+
const res = await prompts({
|
|
3519
3601
|
name: "useClean",
|
|
3520
3602
|
type: "confirm",
|
|
3521
3603
|
message: `Do you want to continue?`
|
|
3522
3604
|
});
|
|
3523
3605
|
if (!res.useClean) {
|
|
3524
|
-
logger.warn(
|
|
3606
|
+
logger.warn(chalk5.yellowBright("\u26A0\uFE0F Audit not complete"));
|
|
3525
3607
|
process.exit(0);
|
|
3526
3608
|
}
|
|
3527
3609
|
}
|
|
3528
3610
|
if (useDefaultValues && !clean) {
|
|
3529
3611
|
logger.warn(
|
|
3530
|
-
|
|
3612
|
+
chalk5.yellowBright(
|
|
3531
3613
|
"WARNING: using the `--useDefaultValues` without the `--clean` flag has no effect. Please re-run audit and add the `--clean` flag"
|
|
3532
3614
|
)
|
|
3533
3615
|
);
|
|
@@ -3555,10 +3637,10 @@ var audit = async ({
|
|
|
3555
3637
|
}
|
|
3556
3638
|
if (error) {
|
|
3557
3639
|
logger.error(
|
|
3558
|
-
|
|
3640
|
+
chalk5.redBright(`\u203C\uFE0F Audit ${chalk5.bold("failed")} with errors`)
|
|
3559
3641
|
);
|
|
3560
3642
|
} else {
|
|
3561
|
-
logger.info(
|
|
3643
|
+
logger.info(chalk5.greenBright("\u2705 Audit passed"));
|
|
3562
3644
|
}
|
|
3563
3645
|
};
|
|
3564
3646
|
var auditDocuments = async (args) => {
|
|
@@ -3575,7 +3657,7 @@ var auditDocuments = async (args) => {
|
|
|
3575
3657
|
}
|
|
3576
3658
|
}
|
|
3577
3659
|
}`;
|
|
3578
|
-
const docResult = await
|
|
3660
|
+
const docResult = await resolve({
|
|
3579
3661
|
database,
|
|
3580
3662
|
query: documentQuery,
|
|
3581
3663
|
variables: {},
|
|
@@ -3586,11 +3668,11 @@ var auditDocuments = async (args) => {
|
|
|
3586
3668
|
if (docResult.errors) {
|
|
3587
3669
|
error = true;
|
|
3588
3670
|
docResult.errors.forEach((err) => {
|
|
3589
|
-
logger.error(
|
|
3671
|
+
logger.error(chalk5.red(err.message));
|
|
3590
3672
|
if (err.originalError.originalError) {
|
|
3591
3673
|
logger.error(
|
|
3592
3674
|
// @ts-ignore FIXME: this doesn't seem right
|
|
3593
|
-
|
|
3675
|
+
chalk5.red(` ${err.originalError.originalError.message}`)
|
|
3594
3676
|
);
|
|
3595
3677
|
}
|
|
3596
3678
|
});
|
|
@@ -3617,7 +3699,7 @@ var auditDocuments = async (args) => {
|
|
|
3617
3699
|
params: $params
|
|
3618
3700
|
){__typename}
|
|
3619
3701
|
}`;
|
|
3620
|
-
const mutationRes = await
|
|
3702
|
+
const mutationRes = await resolve({
|
|
3621
3703
|
database,
|
|
3622
3704
|
query: mutation,
|
|
3623
3705
|
variables: {
|
|
@@ -3632,7 +3714,7 @@ var auditDocuments = async (args) => {
|
|
|
3632
3714
|
if (mutationRes.errors) {
|
|
3633
3715
|
mutationRes.errors.forEach((err) => {
|
|
3634
3716
|
error = true;
|
|
3635
|
-
logger.error(
|
|
3717
|
+
logger.error(chalk5.red(err.message));
|
|
3636
3718
|
});
|
|
3637
3719
|
}
|
|
3638
3720
|
}
|
|
@@ -3649,38 +3731,31 @@ function filterObject(obj) {
|
|
|
3649
3731
|
}
|
|
3650
3732
|
|
|
3651
3733
|
// src/next/commands/audit-command/index.ts
|
|
3652
|
-
|
|
3653
|
-
var AuditCommand = class extends
|
|
3654
|
-
|
|
3655
|
-
|
|
3656
|
-
|
|
3657
|
-
|
|
3658
|
-
|
|
3659
|
-
|
|
3660
|
-
|
|
3661
|
-
|
|
3662
|
-
|
|
3663
|
-
|
|
3664
|
-
|
|
3665
|
-
|
|
3666
|
-
|
|
3667
|
-
|
|
3668
|
-
|
|
3669
|
-
|
|
3670
|
-
|
|
3671
|
-
|
|
3672
|
-
|
|
3673
|
-
|
|
3674
|
-
|
|
3675
|
-
|
|
3676
|
-
|
|
3677
|
-
}
|
|
3678
|
-
static {
|
|
3679
|
-
this.usage = import_clipanion4.Command.Usage({
|
|
3680
|
-
category: `Commands`,
|
|
3681
|
-
description: `Audit config and content files`
|
|
3682
|
-
});
|
|
3683
|
-
}
|
|
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
|
+
});
|
|
3684
3759
|
async catch(error) {
|
|
3685
3760
|
logger.error("Error occured during tinacms audit");
|
|
3686
3761
|
if (this.verbose) {
|
|
@@ -3701,9 +3776,9 @@ var AuditCommand = class extends import_clipanion4.Command {
|
|
|
3701
3776
|
const database = await createAndInitializeDatabase(
|
|
3702
3777
|
configManager,
|
|
3703
3778
|
Number(this.datalayerPort),
|
|
3704
|
-
this.clean ? void 0 : new
|
|
3779
|
+
this.clean ? void 0 : new AuditFileSystemBridge(configManager.rootPath)
|
|
3705
3780
|
);
|
|
3706
|
-
const { tinaSchema, graphQLSchema, lookup } = await (
|
|
3781
|
+
const { tinaSchema, graphQLSchema, lookup } = await buildSchema3(
|
|
3707
3782
|
configManager.config
|
|
3708
3783
|
);
|
|
3709
3784
|
const warnings = [];
|
|
@@ -3736,29 +3811,29 @@ var AuditCommand = class extends import_clipanion4.Command {
|
|
|
3736
3811
|
};
|
|
3737
3812
|
|
|
3738
3813
|
// src/next/commands/init-command/index.ts
|
|
3739
|
-
|
|
3814
|
+
import { Command as Command6, Option as Option6 } from "clipanion";
|
|
3740
3815
|
|
|
3741
3816
|
// src/cmds/init/detectEnvironment.ts
|
|
3742
|
-
|
|
3743
|
-
|
|
3817
|
+
import fs9 from "fs-extra";
|
|
3818
|
+
import path10 from "path";
|
|
3744
3819
|
var checkGitignoreForItem = async ({
|
|
3745
3820
|
baseDir,
|
|
3746
3821
|
line
|
|
3747
3822
|
}) => {
|
|
3748
|
-
const gitignoreContent =
|
|
3823
|
+
const gitignoreContent = fs9.readFileSync(path10.join(baseDir, ".gitignore")).toString();
|
|
3749
3824
|
return gitignoreContent.split("\n").some((item) => item === line);
|
|
3750
3825
|
};
|
|
3751
3826
|
var makeGeneratedFile = async (name2, generatedFileType, parentPath, opts) => {
|
|
3752
3827
|
const result = {
|
|
3753
|
-
fullPathTS:
|
|
3828
|
+
fullPathTS: path10.join(
|
|
3754
3829
|
parentPath,
|
|
3755
3830
|
`${name2}.${opts?.typescriptSuffix || opts?.extensionOverride || "ts"}`
|
|
3756
3831
|
),
|
|
3757
|
-
fullPathJS:
|
|
3832
|
+
fullPathJS: path10.join(
|
|
3758
3833
|
parentPath,
|
|
3759
3834
|
`${name2}.${opts?.extensionOverride || "js"}`
|
|
3760
3835
|
),
|
|
3761
|
-
fullPathOverride: opts?.extensionOverride ?
|
|
3836
|
+
fullPathOverride: opts?.extensionOverride ? path10.join(parentPath, `${name2}.${opts?.extensionOverride}`) : "",
|
|
3762
3837
|
generatedFileType,
|
|
3763
3838
|
name: name2,
|
|
3764
3839
|
parentPath,
|
|
@@ -3776,8 +3851,8 @@ var makeGeneratedFile = async (name2, generatedFileType, parentPath, opts) => {
|
|
|
3776
3851
|
};
|
|
3777
3852
|
}
|
|
3778
3853
|
};
|
|
3779
|
-
result.typescriptExists = await
|
|
3780
|
-
result.javascriptExists = await
|
|
3854
|
+
result.typescriptExists = await fs9.pathExists(result.fullPathTS);
|
|
3855
|
+
result.javascriptExists = await fs9.pathExists(result.fullPathJS);
|
|
3781
3856
|
return result;
|
|
3782
3857
|
};
|
|
3783
3858
|
var detectEnvironment = async ({
|
|
@@ -3786,21 +3861,21 @@ var detectEnvironment = async ({
|
|
|
3786
3861
|
rootPath,
|
|
3787
3862
|
debug = false
|
|
3788
3863
|
}) => {
|
|
3789
|
-
const hasForestryConfig = await
|
|
3790
|
-
|
|
3864
|
+
const hasForestryConfig = await fs9.pathExists(
|
|
3865
|
+
path10.join(pathToForestryConfig, ".forestry", "settings.yml")
|
|
3791
3866
|
);
|
|
3792
|
-
const sampleContentPath =
|
|
3867
|
+
const sampleContentPath = path10.join(
|
|
3793
3868
|
baseDir,
|
|
3794
3869
|
"content",
|
|
3795
3870
|
"posts",
|
|
3796
3871
|
"hello-world.md"
|
|
3797
3872
|
);
|
|
3798
|
-
const usingSrc =
|
|
3799
|
-
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");
|
|
3800
3875
|
const tinaConfigExists = Boolean(
|
|
3801
3876
|
// Does the tina folder exist?
|
|
3802
|
-
await
|
|
3803
|
-
(await
|
|
3877
|
+
await fs9.pathExists(tinaFolder) && // Does the tina folder contain a config file?
|
|
3878
|
+
(await fs9.readdir(tinaFolder)).find((x) => x.includes("config"))
|
|
3804
3879
|
);
|
|
3805
3880
|
const pagesDir = [baseDir, usingSrc ? "src" : false, "pages"].filter(
|
|
3806
3881
|
Boolean
|
|
@@ -3812,12 +3887,12 @@ var detectEnvironment = async ({
|
|
|
3812
3887
|
"next-api-handler": await makeGeneratedFile(
|
|
3813
3888
|
"[...routes]",
|
|
3814
3889
|
"next-api-handler",
|
|
3815
|
-
|
|
3890
|
+
path10.join(...pagesDir, "api", "tina")
|
|
3816
3891
|
),
|
|
3817
3892
|
"reactive-example": await makeGeneratedFile(
|
|
3818
3893
|
"[filename]",
|
|
3819
3894
|
"reactive-example",
|
|
3820
|
-
|
|
3895
|
+
path10.join(...pagesDir, "demo", "blog"),
|
|
3821
3896
|
{
|
|
3822
3897
|
typescriptSuffix: "tsx"
|
|
3823
3898
|
}
|
|
@@ -3825,22 +3900,22 @@ var detectEnvironment = async ({
|
|
|
3825
3900
|
"users-json": await makeGeneratedFile(
|
|
3826
3901
|
"index",
|
|
3827
3902
|
"users-json",
|
|
3828
|
-
|
|
3903
|
+
path10.join(baseDir, "content", "users"),
|
|
3829
3904
|
{ extensionOverride: "json" }
|
|
3830
3905
|
),
|
|
3831
3906
|
"sample-content": await makeGeneratedFile(
|
|
3832
3907
|
"hello-world",
|
|
3833
3908
|
"sample-content",
|
|
3834
|
-
|
|
3909
|
+
path10.join(baseDir, "content", "posts"),
|
|
3835
3910
|
{ extensionOverride: "md" }
|
|
3836
3911
|
)
|
|
3837
3912
|
};
|
|
3838
|
-
const hasSampleContent = await
|
|
3839
|
-
const hasPackageJSON = await
|
|
3913
|
+
const hasSampleContent = await fs9.pathExists(sampleContentPath);
|
|
3914
|
+
const hasPackageJSON = await fs9.pathExists("package.json");
|
|
3840
3915
|
let hasTinaDeps = false;
|
|
3841
3916
|
if (hasPackageJSON) {
|
|
3842
3917
|
try {
|
|
3843
|
-
const packageJSON = await
|
|
3918
|
+
const packageJSON = await fs9.readJSON("package.json");
|
|
3844
3919
|
const deps = [];
|
|
3845
3920
|
if (packageJSON?.dependencies) {
|
|
3846
3921
|
deps.push(...Object.keys(packageJSON.dependencies));
|
|
@@ -3857,15 +3932,15 @@ var detectEnvironment = async ({
|
|
|
3857
3932
|
);
|
|
3858
3933
|
}
|
|
3859
3934
|
}
|
|
3860
|
-
const hasGitIgnore = await
|
|
3935
|
+
const hasGitIgnore = await fs9.pathExists(path10.join(".gitignore"));
|
|
3861
3936
|
const hasGitIgnoreNodeModules = hasGitIgnore && await checkGitignoreForItem({ baseDir, line: "node_modules" });
|
|
3862
3937
|
const hasEnvTina = hasGitIgnore && await checkGitignoreForItem({ baseDir, line: ".env.tina" });
|
|
3863
3938
|
const hasGitIgnoreEnv = hasGitIgnore && await checkGitignoreForItem({ baseDir, line: ".env" });
|
|
3864
3939
|
let frontMatterFormat;
|
|
3865
3940
|
if (hasForestryConfig) {
|
|
3866
|
-
const hugoConfigPath =
|
|
3867
|
-
if (await
|
|
3868
|
-
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");
|
|
3869
3944
|
const metaDataFormat = hugoConfig.toString().match(/metaDataFormat = "(.*)"/)?.[1];
|
|
3870
3945
|
if (metaDataFormat && (metaDataFormat === "yaml" || metaDataFormat === "toml" || metaDataFormat === "json")) {
|
|
3871
3946
|
frontMatterFormat = metaDataFormat;
|
|
@@ -3896,10 +3971,10 @@ var detectEnvironment = async ({
|
|
|
3896
3971
|
var detectEnvironment_default = detectEnvironment;
|
|
3897
3972
|
|
|
3898
3973
|
// src/cmds/init/prompts/index.ts
|
|
3899
|
-
|
|
3974
|
+
import prompts6 from "prompts";
|
|
3900
3975
|
|
|
3901
3976
|
// src/cmds/init/prompts/askTinaCloudSetup.ts
|
|
3902
|
-
|
|
3977
|
+
import prompts2 from "prompts";
|
|
3903
3978
|
var tinaCloudSetupQuestions = [
|
|
3904
3979
|
{
|
|
3905
3980
|
name: "clientId",
|
|
@@ -3921,7 +3996,7 @@ ${logText(
|
|
|
3921
3996
|
}
|
|
3922
3997
|
];
|
|
3923
3998
|
var askTinaCloudSetup = async ({ config: config2 }) => {
|
|
3924
|
-
const { clientId, token } = await (
|
|
3999
|
+
const { clientId, token } = await prompts2(tinaCloudSetupQuestions);
|
|
3925
4000
|
config2.envVars.push(
|
|
3926
4001
|
{
|
|
3927
4002
|
key: "NEXT_PUBLIC_TINA_CLIENT_ID",
|
|
@@ -3935,7 +4010,7 @@ var askTinaCloudSetup = async ({ config: config2 }) => {
|
|
|
3935
4010
|
};
|
|
3936
4011
|
|
|
3937
4012
|
// src/cmds/init/prompts/gitProvider.ts
|
|
3938
|
-
|
|
4013
|
+
import prompts3 from "prompts";
|
|
3939
4014
|
var supportedGitProviders = {
|
|
3940
4015
|
github: {
|
|
3941
4016
|
imports: [
|
|
@@ -3957,7 +4032,7 @@ var supportedGitProviders = {
|
|
|
3957
4032
|
}
|
|
3958
4033
|
};
|
|
3959
4034
|
var chooseGitProvider = async ({ config: config2 }) => {
|
|
3960
|
-
const result = await (
|
|
4035
|
+
const result = await prompts3([
|
|
3961
4036
|
{
|
|
3962
4037
|
name: "githubToken",
|
|
3963
4038
|
type: "text",
|
|
@@ -3965,7 +4040,7 @@ var chooseGitProvider = async ({ config: config2 }) => {
|
|
|
3965
4040
|
${logText(
|
|
3966
4041
|
"Learn more here: "
|
|
3967
4042
|
)}${linkText(
|
|
3968
|
-
"https://tina.io/docs/self-
|
|
4043
|
+
"https://tina.io/docs/r/self-hosting-nextjs/#github-personal-access-token"
|
|
3969
4044
|
)}`,
|
|
3970
4045
|
initial: process.env.GITHUB_PERSONAL_ACCESS_TOKEN
|
|
3971
4046
|
},
|
|
@@ -4002,7 +4077,7 @@ ${logText(
|
|
|
4002
4077
|
};
|
|
4003
4078
|
|
|
4004
4079
|
// src/cmds/init/prompts/databaseAdapter.ts
|
|
4005
|
-
|
|
4080
|
+
import prompts4 from "prompts";
|
|
4006
4081
|
var supportedDatabaseAdapters = {
|
|
4007
4082
|
["upstash-redis"]: {
|
|
4008
4083
|
databaseAdapterClassText: `new RedisLevel({
|
|
@@ -4048,7 +4123,7 @@ var databaseAdapterUpdateConfig = {
|
|
|
4048
4123
|
other: async (_args) => {
|
|
4049
4124
|
},
|
|
4050
4125
|
mongodb: async ({ config: config2 }) => {
|
|
4051
|
-
const result = await (
|
|
4126
|
+
const result = await prompts4([
|
|
4052
4127
|
{
|
|
4053
4128
|
name: "mongoDBUri",
|
|
4054
4129
|
type: "text",
|
|
@@ -4063,7 +4138,7 @@ var databaseAdapterUpdateConfig = {
|
|
|
4063
4138
|
});
|
|
4064
4139
|
},
|
|
4065
4140
|
"upstash-redis": async ({ config: config2 }) => {
|
|
4066
|
-
const result = await (
|
|
4141
|
+
const result = await prompts4([
|
|
4067
4142
|
{
|
|
4068
4143
|
name: "kvRestApiUrl",
|
|
4069
4144
|
type: "text",
|
|
@@ -4094,7 +4169,7 @@ var chooseDatabaseAdapter = async ({
|
|
|
4094
4169
|
framework,
|
|
4095
4170
|
config: config2
|
|
4096
4171
|
}) => {
|
|
4097
|
-
const answers = await (
|
|
4172
|
+
const answers = await prompts4([
|
|
4098
4173
|
{
|
|
4099
4174
|
name: "dataLayerAdapter",
|
|
4100
4175
|
message: "Select a self-hosted Database Adapter",
|
|
@@ -4124,8 +4199,8 @@ var chooseDatabaseAdapter = async ({
|
|
|
4124
4199
|
};
|
|
4125
4200
|
|
|
4126
4201
|
// src/cmds/init/prompts/authProvider.ts
|
|
4127
|
-
|
|
4128
|
-
|
|
4202
|
+
import crypto2 from "crypto-js";
|
|
4203
|
+
import prompts5 from "prompts";
|
|
4129
4204
|
var supportedAuthProviders = {
|
|
4130
4205
|
other: {
|
|
4131
4206
|
name: "other"
|
|
@@ -4174,12 +4249,12 @@ var authProviderUpdateConfig = {
|
|
|
4174
4249
|
},
|
|
4175
4250
|
"tina-cloud": askTinaCloudSetup,
|
|
4176
4251
|
"next-auth": async ({ config: config2 }) => {
|
|
4177
|
-
const result = await (
|
|
4252
|
+
const result = await prompts5([
|
|
4178
4253
|
{
|
|
4179
4254
|
name: "nextAuthSecret",
|
|
4180
4255
|
type: "text",
|
|
4181
4256
|
message: `What is the NextAuth.js Secret? (Hit enter to use a randomly generated secret)`,
|
|
4182
|
-
initial: process.env.NEXTAUTH_SECRET ||
|
|
4257
|
+
initial: process.env.NEXTAUTH_SECRET || crypto2.lib.WordArray.random(16).toString()
|
|
4183
4258
|
}
|
|
4184
4259
|
]);
|
|
4185
4260
|
config2.envVars.push({
|
|
@@ -4204,7 +4279,7 @@ var forestryDisclaimer = logText(
|
|
|
4204
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)`
|
|
4205
4280
|
);
|
|
4206
4281
|
var askCommonSetUp = async () => {
|
|
4207
|
-
const answers = await (
|
|
4282
|
+
const answers = await prompts6([
|
|
4208
4283
|
{
|
|
4209
4284
|
name: "framework",
|
|
4210
4285
|
type: "select",
|
|
@@ -4226,7 +4301,8 @@ var askCommonSetUp = async () => {
|
|
|
4226
4301
|
choices: [
|
|
4227
4302
|
{ title: "PNPM", value: "pnpm" },
|
|
4228
4303
|
{ title: "Yarn", value: "yarn" },
|
|
4229
|
-
{ title: "NPM", value: "npm" }
|
|
4304
|
+
{ title: "NPM", value: "npm" },
|
|
4305
|
+
{ title: "Bun", value: "bun" }
|
|
4230
4306
|
]
|
|
4231
4307
|
}
|
|
4232
4308
|
]);
|
|
@@ -4267,7 +4343,7 @@ ${forestryDisclaimer}`
|
|
|
4267
4343
|
message: `What format are you using in your frontmatter?`
|
|
4268
4344
|
});
|
|
4269
4345
|
}
|
|
4270
|
-
const answers = await (
|
|
4346
|
+
const answers = await prompts6(questions);
|
|
4271
4347
|
return answers;
|
|
4272
4348
|
};
|
|
4273
4349
|
var askTinaSetupPrompts = async (params) => {
|
|
@@ -4287,16 +4363,16 @@ var askTinaSetupPrompts = async (params) => {
|
|
|
4287
4363
|
message: `Where are public assets stored? (default: "public")
|
|
4288
4364
|
` + logText(
|
|
4289
4365
|
`Not sure what value to use? Refer to our "Frameworks" doc: ${linkText(
|
|
4290
|
-
"https://tina.io/docs/
|
|
4366
|
+
"https://tina.io/docs/r/framework-guides-overview"
|
|
4291
4367
|
)}`
|
|
4292
4368
|
)
|
|
4293
4369
|
});
|
|
4294
4370
|
}
|
|
4295
|
-
const answers = await (
|
|
4371
|
+
const answers = await prompts6(questions);
|
|
4296
4372
|
return answers;
|
|
4297
4373
|
};
|
|
4298
4374
|
var askIfUsingSelfHosted = async () => {
|
|
4299
|
-
const answers = await (
|
|
4375
|
+
const answers = await prompts6([
|
|
4300
4376
|
{
|
|
4301
4377
|
name: "hosting",
|
|
4302
4378
|
type: "select",
|
|
@@ -4329,20 +4405,20 @@ var makeImportString = (imports) => {
|
|
|
4329
4405
|
};
|
|
4330
4406
|
|
|
4331
4407
|
// src/cmds/init/prompts/generatedFiles.ts
|
|
4332
|
-
|
|
4408
|
+
import prompts7 from "prompts";
|
|
4333
4409
|
var askIfOverride = async ({
|
|
4334
4410
|
generatedFile,
|
|
4335
4411
|
usingTypescript
|
|
4336
4412
|
}) => {
|
|
4337
4413
|
if (usingTypescript) {
|
|
4338
|
-
const result = await (
|
|
4414
|
+
const result = await prompts7({
|
|
4339
4415
|
name: `override`,
|
|
4340
4416
|
type: "confirm",
|
|
4341
4417
|
message: `Found existing file at ${generatedFile.fullPathTS}. Would you like to overwrite?`
|
|
4342
4418
|
});
|
|
4343
4419
|
return Boolean(result.override);
|
|
4344
4420
|
} else {
|
|
4345
|
-
const result = await (
|
|
4421
|
+
const result = await prompts7({
|
|
4346
4422
|
name: `override`,
|
|
4347
4423
|
type: "confirm",
|
|
4348
4424
|
message: `Found existing file at ${generatedFile.fullPathJS}. Would you like to overwrite?`
|
|
@@ -4477,24 +4553,25 @@ var CLICommand = class {
|
|
|
4477
4553
|
};
|
|
4478
4554
|
|
|
4479
4555
|
// src/cmds/init/apply.ts
|
|
4480
|
-
|
|
4556
|
+
import path14 from "path";
|
|
4481
4557
|
|
|
4482
4558
|
// src/cmds/forestry-migrate/index.ts
|
|
4483
|
-
|
|
4484
|
-
|
|
4485
|
-
|
|
4486
|
-
|
|
4487
|
-
|
|
4488
|
-
|
|
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";
|
|
4489
4565
|
|
|
4490
4566
|
// src/cmds/forestry-migrate/util/index.ts
|
|
4491
|
-
|
|
4492
|
-
|
|
4493
|
-
|
|
4494
|
-
|
|
4567
|
+
import fs10 from "fs-extra";
|
|
4568
|
+
import path11 from "path";
|
|
4569
|
+
import yaml from "js-yaml";
|
|
4570
|
+
import z from "zod";
|
|
4495
4571
|
|
|
4496
4572
|
// src/cmds/forestry-migrate/util/errorSingleton.ts
|
|
4497
4573
|
var ErrorSingleton = class _ErrorSingleton {
|
|
4574
|
+
static instance;
|
|
4498
4575
|
/**
|
|
4499
4576
|
* The Singleton's constructor should always be private to prevent direct
|
|
4500
4577
|
* construction calls with the `new` operator.
|
|
@@ -4514,6 +4591,7 @@ var ErrorSingleton = class _ErrorSingleton {
|
|
|
4514
4591
|
}
|
|
4515
4592
|
return _ErrorSingleton.instance;
|
|
4516
4593
|
}
|
|
4594
|
+
collectionNameErrors;
|
|
4517
4595
|
addErrorName(error) {
|
|
4518
4596
|
this.collectionNameErrors.push(error);
|
|
4519
4597
|
}
|
|
@@ -4536,8 +4614,8 @@ var ErrorSingleton = class _ErrorSingleton {
|
|
|
4536
4614
|
};
|
|
4537
4615
|
|
|
4538
4616
|
// src/cmds/forestry-migrate/util/codeTransformer.ts
|
|
4539
|
-
|
|
4540
|
-
|
|
4617
|
+
import { format } from "prettier";
|
|
4618
|
+
import TsParser from "prettier/parser-typescript.js";
|
|
4541
4619
|
var addVariablesToCode = (codeWithTinaPrefix) => {
|
|
4542
4620
|
const code = codeWithTinaPrefix.replace(
|
|
4543
4621
|
/"__TINA_INTERNAL__:::(.*?):::"/g,
|
|
@@ -4574,7 +4652,7 @@ var makeTemplateFile = async ({
|
|
|
4574
4652
|
`export function ${stringifyLabelWithField(
|
|
4575
4653
|
template.templateObj.label
|
|
4576
4654
|
)} (){
|
|
4577
|
-
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[]" : ""}
|
|
4578
4656
|
} `
|
|
4579
4657
|
);
|
|
4580
4658
|
}
|
|
@@ -4582,9 +4660,9 @@ var makeTemplateFile = async ({
|
|
|
4582
4660
|
${usingTypescript ? "import type { TinaField } from 'tinacms'" : ""}
|
|
4583
4661
|
${templateCodeText.join("\n")}
|
|
4584
4662
|
`;
|
|
4585
|
-
const formattedCode =
|
|
4663
|
+
const formattedCode = format(templateCode, {
|
|
4586
4664
|
parser: "typescript",
|
|
4587
|
-
plugins: [
|
|
4665
|
+
plugins: [TsParser]
|
|
4588
4666
|
});
|
|
4589
4667
|
return { importStatements, templateCodeText: formattedCode };
|
|
4590
4668
|
};
|
|
@@ -4616,82 +4694,82 @@ var stringifyTemplateName = (name2, template) => {
|
|
|
4616
4694
|
return newName;
|
|
4617
4695
|
}
|
|
4618
4696
|
};
|
|
4619
|
-
var forestryConfigSchema =
|
|
4620
|
-
sections:
|
|
4621
|
-
|
|
4622
|
-
type:
|
|
4623
|
-
|
|
4624
|
-
|
|
4625
|
-
|
|
4626
|
-
|
|
4627
|
-
|
|
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")
|
|
4628
4706
|
]),
|
|
4629
|
-
label:
|
|
4630
|
-
path:
|
|
4631
|
-
match:
|
|
4632
|
-
exclude:
|
|
4633
|
-
create:
|
|
4634
|
-
templates:
|
|
4635
|
-
new_doc_ext:
|
|
4636
|
-
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()
|
|
4637
4715
|
})
|
|
4638
4716
|
)
|
|
4639
4717
|
});
|
|
4640
|
-
var forestryFieldWithoutField =
|
|
4718
|
+
var forestryFieldWithoutField = z.object({
|
|
4641
4719
|
// TODO: maybe better type this?
|
|
4642
|
-
type:
|
|
4643
|
-
|
|
4644
|
-
|
|
4645
|
-
|
|
4646
|
-
|
|
4647
|
-
|
|
4648
|
-
|
|
4649
|
-
|
|
4650
|
-
|
|
4651
|
-
|
|
4652
|
-
|
|
4653
|
-
|
|
4654
|
-
|
|
4655
|
-
|
|
4656
|
-
|
|
4657
|
-
|
|
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")
|
|
4658
4736
|
]),
|
|
4659
|
-
template_types:
|
|
4660
|
-
name:
|
|
4661
|
-
label:
|
|
4662
|
-
default:
|
|
4663
|
-
template:
|
|
4664
|
-
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({
|
|
4665
4743
|
// min and max are used for lists
|
|
4666
|
-
min:
|
|
4667
|
-
max:
|
|
4668
|
-
required:
|
|
4669
|
-
use_select:
|
|
4670
|
-
date_format:
|
|
4671
|
-
time_format:
|
|
4672
|
-
options:
|
|
4673
|
-
source:
|
|
4674
|
-
type:
|
|
4675
|
-
|
|
4676
|
-
|
|
4677
|
-
|
|
4678
|
-
|
|
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"),
|
|
4679
4757
|
// TODO: I want to ignore this key if its invalid
|
|
4680
|
-
|
|
4758
|
+
z.string()
|
|
4681
4759
|
]).optional().nullable(),
|
|
4682
|
-
section:
|
|
4760
|
+
section: z.string().optional().nullable()
|
|
4683
4761
|
}).optional()
|
|
4684
4762
|
}).optional()
|
|
4685
4763
|
});
|
|
4686
|
-
var forestryField =
|
|
4764
|
+
var forestryField = z.lazy(
|
|
4687
4765
|
() => forestryFieldWithoutField.extend({
|
|
4688
|
-
fields:
|
|
4766
|
+
fields: z.array(forestryField).optional()
|
|
4689
4767
|
})
|
|
4690
4768
|
);
|
|
4691
|
-
var FrontmatterTemplateSchema =
|
|
4692
|
-
label:
|
|
4693
|
-
hide_body:
|
|
4694
|
-
fields:
|
|
4769
|
+
var FrontmatterTemplateSchema = z.object({
|
|
4770
|
+
label: z.string(),
|
|
4771
|
+
hide_body: z.boolean().optional(),
|
|
4772
|
+
fields: z.array(forestryField).optional()
|
|
4695
4773
|
});
|
|
4696
4774
|
var transformForestryFieldsToTinaFields = ({
|
|
4697
4775
|
fields,
|
|
@@ -4914,7 +4992,7 @@ var transformForestryFieldsToTinaFields = ({
|
|
|
4914
4992
|
return tinaFields;
|
|
4915
4993
|
};
|
|
4916
4994
|
var getFieldsFromTemplates = ({ tem, pathToForestryConfig, skipBlocks = false }) => {
|
|
4917
|
-
const templatePath =
|
|
4995
|
+
const templatePath = path11.join(
|
|
4918
4996
|
pathToForestryConfig,
|
|
4919
4997
|
".forestry",
|
|
4920
4998
|
"front_matter",
|
|
@@ -4923,7 +5001,7 @@ var getFieldsFromTemplates = ({ tem, pathToForestryConfig, skipBlocks = false })
|
|
|
4923
5001
|
);
|
|
4924
5002
|
let templateString = "";
|
|
4925
5003
|
try {
|
|
4926
|
-
templateString =
|
|
5004
|
+
templateString = fs10.readFileSync(templatePath).toString();
|
|
4927
5005
|
} catch {
|
|
4928
5006
|
throw new Error(
|
|
4929
5007
|
`Could not find template ${tem} at ${templatePath}
|
|
@@ -4931,7 +5009,7 @@ var getFieldsFromTemplates = ({ tem, pathToForestryConfig, skipBlocks = false })
|
|
|
4931
5009
|
This will require manual migration.`
|
|
4932
5010
|
);
|
|
4933
5011
|
}
|
|
4934
|
-
const templateObj =
|
|
5012
|
+
const templateObj = yaml.load(templateString);
|
|
4935
5013
|
const template = parseTemplates({ val: templateObj });
|
|
4936
5014
|
const fields = transformForestryFieldsToTinaFields({
|
|
4937
5015
|
fields: template.fields,
|
|
@@ -4951,6 +5029,7 @@ var parseSections = ({ val }) => {
|
|
|
4951
5029
|
};
|
|
4952
5030
|
|
|
4953
5031
|
// src/cmds/forestry-migrate/index.ts
|
|
5032
|
+
var { minimatch } = pkg;
|
|
4954
5033
|
var BODY_FIELD = {
|
|
4955
5034
|
// This is the body field
|
|
4956
5035
|
type: "rich-text",
|
|
@@ -4979,7 +5058,7 @@ var transformForestryMatchToTinaMatch = (match) => {
|
|
|
4979
5058
|
};
|
|
4980
5059
|
function checkExt(ext) {
|
|
4981
5060
|
const extReal = ext.replace(".", "");
|
|
4982
|
-
if (
|
|
5061
|
+
if (CONTENT_FORMATS.includes(extReal)) {
|
|
4983
5062
|
return extReal;
|
|
4984
5063
|
} else {
|
|
4985
5064
|
return false;
|
|
@@ -4988,9 +5067,9 @@ function checkExt(ext) {
|
|
|
4988
5067
|
var generateAllTemplates = async ({
|
|
4989
5068
|
pathToForestryConfig
|
|
4990
5069
|
}) => {
|
|
4991
|
-
const allTemplates = (await
|
|
4992
|
-
|
|
4993
|
-
)).map((tem) =>
|
|
5070
|
+
const allTemplates = (await fs11.readdir(
|
|
5071
|
+
path12.join(pathToForestryConfig, ".forestry", "front_matter", "templates")
|
|
5072
|
+
)).map((tem) => path12.basename(tem, ".yml"));
|
|
4994
5073
|
const templateMap = /* @__PURE__ */ new Map();
|
|
4995
5074
|
const proms = allTemplates.map(async (tem) => {
|
|
4996
5075
|
try {
|
|
@@ -5065,7 +5144,7 @@ var generateCollectionFromForestrySection = (args) => {
|
|
|
5065
5144
|
glob = section.path + "/" + section.match;
|
|
5066
5145
|
}
|
|
5067
5146
|
if (pages.some((page) => {
|
|
5068
|
-
return (
|
|
5147
|
+
return minimatch(page, glob);
|
|
5069
5148
|
})) {
|
|
5070
5149
|
forestryTemplates.push(templateKey);
|
|
5071
5150
|
}
|
|
@@ -5135,9 +5214,9 @@ var generateCollectionFromForestrySection = (args) => {
|
|
|
5135
5214
|
return c;
|
|
5136
5215
|
} else if (section.type === "document") {
|
|
5137
5216
|
const filePath = section.path;
|
|
5138
|
-
const extname =
|
|
5139
|
-
const fileName =
|
|
5140
|
-
const dir =
|
|
5217
|
+
const extname = path12.extname(filePath);
|
|
5218
|
+
const fileName = path12.basename(filePath, extname);
|
|
5219
|
+
const dir = path12.dirname(filePath);
|
|
5141
5220
|
const ext = checkExt(extname);
|
|
5142
5221
|
if (ext) {
|
|
5143
5222
|
const fields = [];
|
|
@@ -5157,7 +5236,7 @@ var generateCollectionFromForestrySection = (args) => {
|
|
|
5157
5236
|
name: "dummy",
|
|
5158
5237
|
label: "Dummy field",
|
|
5159
5238
|
type: "string",
|
|
5160
|
-
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"
|
|
5161
5240
|
});
|
|
5162
5241
|
logger.warn(
|
|
5163
5242
|
warnText(
|
|
@@ -5199,8 +5278,8 @@ var generateCollections = async ({
|
|
|
5199
5278
|
templateMap,
|
|
5200
5279
|
usingTypescript
|
|
5201
5280
|
});
|
|
5202
|
-
const forestryConfig = await
|
|
5203
|
-
|
|
5281
|
+
const forestryConfig = await fs11.readFile(
|
|
5282
|
+
path12.join(pathToForestryConfig, ".forestry", "settings.yml")
|
|
5204
5283
|
);
|
|
5205
5284
|
rewriteTemplateKeysInDocs({
|
|
5206
5285
|
templateMap,
|
|
@@ -5210,7 +5289,7 @@ var generateCollections = async ({
|
|
|
5210
5289
|
}
|
|
5211
5290
|
});
|
|
5212
5291
|
const collections = parseSections({
|
|
5213
|
-
val:
|
|
5292
|
+
val: yaml2.load(forestryConfig.toString())
|
|
5214
5293
|
}).sections.map(
|
|
5215
5294
|
(section) => generateCollectionFromForestrySection({
|
|
5216
5295
|
section,
|
|
@@ -5230,13 +5309,13 @@ var rewriteTemplateKeysInDocs = (args) => {
|
|
|
5230
5309
|
const { templateObj } = templateMap.get(templateKey);
|
|
5231
5310
|
templateObj?.pages?.forEach((page) => {
|
|
5232
5311
|
try {
|
|
5233
|
-
const filePath =
|
|
5234
|
-
if (
|
|
5312
|
+
const filePath = path12.join(page);
|
|
5313
|
+
if (fs11.lstatSync(filePath).isDirectory()) {
|
|
5235
5314
|
return;
|
|
5236
5315
|
}
|
|
5237
|
-
const extname =
|
|
5238
|
-
const fileContent =
|
|
5239
|
-
const content =
|
|
5316
|
+
const extname = path12.extname(filePath);
|
|
5317
|
+
const fileContent = fs11.readFileSync(filePath).toString();
|
|
5318
|
+
const content = parseFile(
|
|
5240
5319
|
fileContent,
|
|
5241
5320
|
extname,
|
|
5242
5321
|
(yup) => yup.object({}),
|
|
@@ -5246,9 +5325,9 @@ var rewriteTemplateKeysInDocs = (args) => {
|
|
|
5246
5325
|
_template: stringifyLabel(templateKey),
|
|
5247
5326
|
...content
|
|
5248
5327
|
};
|
|
5249
|
-
|
|
5328
|
+
fs11.writeFileSync(
|
|
5250
5329
|
filePath,
|
|
5251
|
-
|
|
5330
|
+
stringifyFile(newContent, extname, true, markdownParseConfig)
|
|
5252
5331
|
);
|
|
5253
5332
|
} catch (error) {
|
|
5254
5333
|
console.log(
|
|
@@ -5260,32 +5339,25 @@ var rewriteTemplateKeysInDocs = (args) => {
|
|
|
5260
5339
|
};
|
|
5261
5340
|
|
|
5262
5341
|
// src/cmds/init/apply.ts
|
|
5263
|
-
|
|
5264
|
-
|
|
5342
|
+
import { Telemetry as Telemetry2 } from "@tinacms/metrics";
|
|
5343
|
+
import fs14 from "fs-extra";
|
|
5265
5344
|
|
|
5266
5345
|
// src/next/commands/codemod-command/index.ts
|
|
5267
|
-
|
|
5268
|
-
|
|
5269
|
-
|
|
5270
|
-
var CodemodCommand = class extends
|
|
5271
|
-
|
|
5272
|
-
|
|
5273
|
-
|
|
5274
|
-
|
|
5275
|
-
|
|
5276
|
-
|
|
5277
|
-
|
|
5278
|
-
|
|
5279
|
-
|
|
5280
|
-
|
|
5281
|
-
|
|
5282
|
-
}
|
|
5283
|
-
static {
|
|
5284
|
-
this.usage = import_clipanion5.Command.Usage({
|
|
5285
|
-
category: `Commands`,
|
|
5286
|
-
description: `Use codemods for various Tina tasks`
|
|
5287
|
-
});
|
|
5288
|
-
}
|
|
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
|
+
});
|
|
5289
5361
|
async catch(error) {
|
|
5290
5362
|
console.log(error);
|
|
5291
5363
|
}
|
|
@@ -5314,13 +5386,13 @@ var moveTinaFolder = async (rootPath = process.cwd()) => {
|
|
|
5314
5386
|
logger.error(e.message);
|
|
5315
5387
|
process.exit(1);
|
|
5316
5388
|
}
|
|
5317
|
-
const tinaDestination =
|
|
5318
|
-
if (await
|
|
5389
|
+
const tinaDestination = path13.join(configManager.rootPath, "tina");
|
|
5390
|
+
if (await fs12.existsSync(tinaDestination)) {
|
|
5319
5391
|
logger.info(
|
|
5320
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.`
|
|
5321
5393
|
);
|
|
5322
5394
|
} else {
|
|
5323
|
-
await
|
|
5395
|
+
await fs12.moveSync(configManager.tinaFolderPath, tinaDestination);
|
|
5324
5396
|
await writeGitignore(configManager.rootPath);
|
|
5325
5397
|
logger.info(
|
|
5326
5398
|
"Move to 'tina' folder complete. Be sure to update any imports of the autogenerated client!"
|
|
@@ -5328,8 +5400,8 @@ var moveTinaFolder = async (rootPath = process.cwd()) => {
|
|
|
5328
5400
|
}
|
|
5329
5401
|
};
|
|
5330
5402
|
var writeGitignore = async (rootPath) => {
|
|
5331
|
-
await
|
|
5332
|
-
|
|
5403
|
+
await fs12.outputFileSync(
|
|
5404
|
+
path13.join(rootPath, "tina", ".gitignore"),
|
|
5333
5405
|
"__generated__"
|
|
5334
5406
|
);
|
|
5335
5407
|
};
|
|
@@ -5382,7 +5454,7 @@ const BlogPage = (props) => {
|
|
|
5382
5454
|
<div className='bg-green-100 text-center'>
|
|
5383
5455
|
Lost and looking for a place to start?
|
|
5384
5456
|
<a
|
|
5385
|
-
href='https://tina.io/
|
|
5457
|
+
href='https://tina.io/docs/r/beginner-series'
|
|
5386
5458
|
className='text-blue-500 underline'
|
|
5387
5459
|
>
|
|
5388
5460
|
{' '}
|
|
@@ -5664,7 +5736,7 @@ import { LocalAuthProvider } from "tinacms";`;
|
|
|
5664
5736
|
publicFolder: "${args.publicFolder}",
|
|
5665
5737
|
},
|
|
5666
5738
|
},
|
|
5667
|
-
// 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/
|
|
5668
5740
|
schema: {
|
|
5669
5741
|
collections: ${generateCollectionString(args)},
|
|
5670
5742
|
},
|
|
@@ -5737,7 +5809,7 @@ Suspendisse facilisis, mi ac scelerisque interdum, ligula ex imperdiet felis, a
|
|
|
5737
5809
|
`;
|
|
5738
5810
|
|
|
5739
5811
|
// src/cmds/init/apply.ts
|
|
5740
|
-
|
|
5812
|
+
import { format as format2 } from "prettier";
|
|
5741
5813
|
|
|
5742
5814
|
// src/utils/script-helpers.ts
|
|
5743
5815
|
function generateGqlScript(scriptValue, opts) {
|
|
@@ -5760,38 +5832,38 @@ function extendNextScripts(scripts, opts) {
|
|
|
5760
5832
|
}
|
|
5761
5833
|
|
|
5762
5834
|
// src/cmds/init/codegen/index.ts
|
|
5763
|
-
|
|
5764
|
-
|
|
5835
|
+
import ts2 from "typescript";
|
|
5836
|
+
import fs13 from "fs-extra";
|
|
5765
5837
|
|
|
5766
5838
|
// src/cmds/init/codegen/util.ts
|
|
5767
|
-
|
|
5768
|
-
var makeTransformer = (makeVisitor) => (ctx) => (node) =>
|
|
5839
|
+
import ts from "typescript";
|
|
5840
|
+
var makeTransformer = (makeVisitor) => (ctx) => (node) => ts.visitNode(node, makeVisitor(ctx));
|
|
5769
5841
|
function parseExpression(expression) {
|
|
5770
|
-
const sourceFile =
|
|
5842
|
+
const sourceFile = ts.createSourceFile(
|
|
5771
5843
|
"temp.ts",
|
|
5772
5844
|
expression,
|
|
5773
|
-
|
|
5845
|
+
ts.ScriptTarget.Latest
|
|
5774
5846
|
);
|
|
5775
5847
|
if (sourceFile.statements.length !== 1) {
|
|
5776
5848
|
throw new Error("Expected one statement");
|
|
5777
5849
|
}
|
|
5778
5850
|
const statement = sourceFile.statements[0];
|
|
5779
|
-
if (!
|
|
5851
|
+
if (!ts.isExpressionStatement(statement)) {
|
|
5780
5852
|
throw new Error("Expected an expression statement");
|
|
5781
5853
|
}
|
|
5782
5854
|
return [sourceFile, statement.expression];
|
|
5783
5855
|
}
|
|
5784
5856
|
function parseVariableStatement(stmt) {
|
|
5785
|
-
const sourceFile =
|
|
5857
|
+
const sourceFile = ts.createSourceFile(
|
|
5786
5858
|
"temp.ts",
|
|
5787
5859
|
stmt,
|
|
5788
|
-
|
|
5860
|
+
ts.ScriptTarget.Latest
|
|
5789
5861
|
);
|
|
5790
5862
|
if (sourceFile.statements.length !== 1) {
|
|
5791
5863
|
throw new Error("Expected one statement");
|
|
5792
5864
|
}
|
|
5793
5865
|
const statement = sourceFile.statements[0];
|
|
5794
|
-
if (!
|
|
5866
|
+
if (!ts.isVariableStatement(statement)) {
|
|
5795
5867
|
throw new Error("Expected a variable statement");
|
|
5796
5868
|
}
|
|
5797
5869
|
return [sourceFile, statement];
|
|
@@ -5799,7 +5871,7 @@ function parseVariableStatement(stmt) {
|
|
|
5799
5871
|
|
|
5800
5872
|
// src/cmds/init/codegen/index.ts
|
|
5801
5873
|
var makeVariableStatementVisitor = (sourceFile, variableStmtSourceFile, variableStmt) => (ctx) => (node) => {
|
|
5802
|
-
if (
|
|
5874
|
+
if (ts2.isSourceFile(node)) {
|
|
5803
5875
|
const newStatements = [...node.statements];
|
|
5804
5876
|
let encounteredImports = false;
|
|
5805
5877
|
let firstNonImportStatementIdx = -1;
|
|
@@ -5807,7 +5879,7 @@ var makeVariableStatementVisitor = (sourceFile, variableStmtSourceFile, variable
|
|
|
5807
5879
|
const [newVarDec] = variableStmt.declarationList.declarations;
|
|
5808
5880
|
const newVarDecName = newVarDec.name.getText(variableStmtSourceFile);
|
|
5809
5881
|
for (let i = 0; i < newStatements.length; i++) {
|
|
5810
|
-
const isImport =
|
|
5882
|
+
const isImport = ts2.isImportDeclaration(newStatements[i]);
|
|
5811
5883
|
if (isImport && !encounteredImports) {
|
|
5812
5884
|
encounteredImports = true;
|
|
5813
5885
|
}
|
|
@@ -5815,9 +5887,9 @@ var makeVariableStatementVisitor = (sourceFile, variableStmtSourceFile, variable
|
|
|
5815
5887
|
firstNonImportStatementIdx = i;
|
|
5816
5888
|
}
|
|
5817
5889
|
const stmt = newStatements[i];
|
|
5818
|
-
if (
|
|
5890
|
+
if (ts2.isVariableStatement(stmt)) {
|
|
5819
5891
|
const [dec] = stmt.declarationList.declarations;
|
|
5820
|
-
if (dec.name &&
|
|
5892
|
+
if (dec.name && ts2.isIdentifier(dec.name) && dec.name.getText(sourceFile) === newVarDecName) {
|
|
5821
5893
|
existingStatementIdx = i;
|
|
5822
5894
|
}
|
|
5823
5895
|
}
|
|
@@ -5831,19 +5903,19 @@ var makeVariableStatementVisitor = (sourceFile, variableStmtSourceFile, variable
|
|
|
5831
5903
|
if (existingStatementIdx === -1) {
|
|
5832
5904
|
newStatements.splice(firstNonImportStatementIdx, 0, variableStmt);
|
|
5833
5905
|
}
|
|
5834
|
-
return
|
|
5906
|
+
return ts2.factory.updateSourceFile(node, newStatements);
|
|
5835
5907
|
}
|
|
5836
5908
|
};
|
|
5837
5909
|
var makeImportsVisitor = (sourceFile, importMap) => (ctx) => (node) => {
|
|
5838
|
-
if (
|
|
5910
|
+
if (ts2.isSourceFile(node)) {
|
|
5839
5911
|
const newStatements = [...node.statements];
|
|
5840
5912
|
let changed = false;
|
|
5841
5913
|
for (const [moduleName, imports] of Object.entries(importMap)) {
|
|
5842
5914
|
let foundImportStatement = false;
|
|
5843
5915
|
for (const statement of newStatements) {
|
|
5844
|
-
if (
|
|
5916
|
+
if (ts2.isImportDeclaration(statement) && ts2.isStringLiteral(statement.moduleSpecifier) && statement.moduleSpecifier.text === moduleName) {
|
|
5845
5917
|
foundImportStatement = true;
|
|
5846
|
-
const existingImports = statement.importClause?.namedBindings &&
|
|
5918
|
+
const existingImports = statement.importClause?.namedBindings && ts2.isNamedImports(statement.importClause.namedBindings) ? statement.importClause.namedBindings.elements.map(
|
|
5847
5919
|
(e) => e.name.text
|
|
5848
5920
|
) : [];
|
|
5849
5921
|
const newImports = [
|
|
@@ -5854,22 +5926,22 @@ var makeImportsVisitor = (sourceFile, importMap) => (ctx) => (node) => {
|
|
|
5854
5926
|
])
|
|
5855
5927
|
];
|
|
5856
5928
|
const importSpecifiers = newImports.map(
|
|
5857
|
-
(i) =>
|
|
5929
|
+
(i) => ts2.factory.createImportSpecifier(
|
|
5858
5930
|
void 0,
|
|
5859
|
-
|
|
5860
|
-
|
|
5931
|
+
ts2.factory.createIdentifier(i),
|
|
5932
|
+
ts2.factory.createIdentifier(i)
|
|
5861
5933
|
)
|
|
5862
5934
|
);
|
|
5863
|
-
const namedImports =
|
|
5864
|
-
const importClause =
|
|
5935
|
+
const namedImports = ts2.factory.createNamedImports(importSpecifiers);
|
|
5936
|
+
const importClause = ts2.factory.createImportClause(
|
|
5865
5937
|
false,
|
|
5866
5938
|
void 0,
|
|
5867
5939
|
namedImports
|
|
5868
5940
|
);
|
|
5869
|
-
const importDec =
|
|
5941
|
+
const importDec = ts2.factory.createImportDeclaration(
|
|
5870
5942
|
void 0,
|
|
5871
5943
|
importClause,
|
|
5872
|
-
|
|
5944
|
+
ts2.factory.createStringLiteral(moduleName)
|
|
5873
5945
|
);
|
|
5874
5946
|
newStatements[newStatements.indexOf(statement)] = importDec;
|
|
5875
5947
|
changed = true;
|
|
@@ -5877,45 +5949,45 @@ var makeImportsVisitor = (sourceFile, importMap) => (ctx) => (node) => {
|
|
|
5877
5949
|
}
|
|
5878
5950
|
if (!foundImportStatement) {
|
|
5879
5951
|
const importSpecifiers = imports.map(
|
|
5880
|
-
(i) =>
|
|
5952
|
+
(i) => ts2.factory.createImportSpecifier(
|
|
5881
5953
|
void 0,
|
|
5882
|
-
|
|
5883
|
-
|
|
5954
|
+
ts2.factory.createIdentifier(i),
|
|
5955
|
+
ts2.factory.createIdentifier(i)
|
|
5884
5956
|
)
|
|
5885
5957
|
);
|
|
5886
|
-
const namedImports =
|
|
5887
|
-
const importClause =
|
|
5958
|
+
const namedImports = ts2.factory.createNamedImports(importSpecifiers);
|
|
5959
|
+
const importClause = ts2.factory.createImportClause(
|
|
5888
5960
|
false,
|
|
5889
5961
|
void 0,
|
|
5890
5962
|
namedImports
|
|
5891
5963
|
);
|
|
5892
|
-
const importDec =
|
|
5964
|
+
const importDec = ts2.factory.createImportDeclaration(
|
|
5893
5965
|
void 0,
|
|
5894
5966
|
importClause,
|
|
5895
|
-
|
|
5967
|
+
ts2.factory.createStringLiteral(moduleName)
|
|
5896
5968
|
);
|
|
5897
5969
|
newStatements.unshift(importDec);
|
|
5898
5970
|
changed = true;
|
|
5899
5971
|
}
|
|
5900
5972
|
}
|
|
5901
5973
|
if (changed) {
|
|
5902
|
-
return
|
|
5974
|
+
return ts2.factory.updateSourceFile(node, newStatements);
|
|
5903
5975
|
}
|
|
5904
5976
|
}
|
|
5905
5977
|
};
|
|
5906
5978
|
var makeAddExpressionToSchemaCollectionVisitor = (sourceFile, functionName, newExpressionSourceFile, newExpression) => (ctx) => {
|
|
5907
5979
|
const visit2 = (node) => {
|
|
5908
|
-
if (
|
|
5980
|
+
if (ts2.isCallExpression(node) && ts2.isIdentifier(node.expression) && node.expression.text === functionName && node.arguments.length > 0 && ts2.isObjectLiteralExpression(node.arguments[0])) {
|
|
5909
5981
|
const configObject = node.arguments[0];
|
|
5910
5982
|
const updateProperties = configObject.properties.map((property) => {
|
|
5911
|
-
if (
|
|
5983
|
+
if (ts2.isPropertyAssignment(property)) {
|
|
5912
5984
|
const thisPropertyName = property.name.getText(sourceFile);
|
|
5913
|
-
if (thisPropertyName === "schema" &&
|
|
5985
|
+
if (thisPropertyName === "schema" && ts2.isPropertyAssignment(property) && ts2.isObjectLiteralExpression(property.initializer)) {
|
|
5914
5986
|
const schemaObject = property.initializer;
|
|
5915
5987
|
const collectionsProperty = schemaObject.properties.find(
|
|
5916
|
-
(p) =>
|
|
5988
|
+
(p) => ts2.isPropertyAssignment(p) && p.name.getText(sourceFile) === "collections"
|
|
5917
5989
|
);
|
|
5918
|
-
if (collectionsProperty &&
|
|
5990
|
+
if (collectionsProperty && ts2.isPropertyAssignment(collectionsProperty) && ts2.isArrayLiteralExpression(collectionsProperty.initializer)) {
|
|
5919
5991
|
const collectionsArray = collectionsProperty.initializer;
|
|
5920
5992
|
const collectionItems = collectionsArray.elements.map(
|
|
5921
5993
|
(e) => e.getText(sourceFile)
|
|
@@ -5925,16 +5997,16 @@ var makeAddExpressionToSchemaCollectionVisitor = (sourceFile, functionName, newE
|
|
|
5925
5997
|
)) {
|
|
5926
5998
|
return property;
|
|
5927
5999
|
}
|
|
5928
|
-
return
|
|
6000
|
+
return ts2.factory.updatePropertyAssignment(
|
|
5929
6001
|
property,
|
|
5930
6002
|
property.name,
|
|
5931
|
-
|
|
6003
|
+
ts2.factory.createObjectLiteralExpression(
|
|
5932
6004
|
schemaObject.properties.map((subProp) => {
|
|
5933
|
-
if (
|
|
5934
|
-
return
|
|
6005
|
+
if (ts2.isPropertyAssignment(subProp) && subProp.name.getText(sourceFile) === "collections" && ts2.isArrayLiteralExpression(subProp.initializer)) {
|
|
6006
|
+
return ts2.factory.updatePropertyAssignment(
|
|
5935
6007
|
subProp,
|
|
5936
6008
|
subProp.name,
|
|
5937
|
-
|
|
6009
|
+
ts2.factory.createArrayLiteralExpression(
|
|
5938
6010
|
[newExpression, ...subProp.initializer.elements],
|
|
5939
6011
|
true
|
|
5940
6012
|
)
|
|
@@ -5950,56 +6022,56 @@ var makeAddExpressionToSchemaCollectionVisitor = (sourceFile, functionName, newE
|
|
|
5950
6022
|
}
|
|
5951
6023
|
return property;
|
|
5952
6024
|
});
|
|
5953
|
-
return
|
|
6025
|
+
return ts2.factory.createCallExpression(
|
|
5954
6026
|
node.expression,
|
|
5955
6027
|
node.typeArguments,
|
|
5956
|
-
[
|
|
6028
|
+
[ts2.factory.createObjectLiteralExpression(updateProperties, true)]
|
|
5957
6029
|
);
|
|
5958
6030
|
}
|
|
5959
|
-
return
|
|
6031
|
+
return ts2.visitEachChild(node, visit2, ctx);
|
|
5960
6032
|
};
|
|
5961
6033
|
return (sourceFile2) => {
|
|
5962
|
-
return
|
|
6034
|
+
return ts2.visitEachChild(sourceFile2, visit2, ctx);
|
|
5963
6035
|
};
|
|
5964
6036
|
};
|
|
5965
6037
|
var makeUpdateObjectLiteralPropertyVisitor = (sourceFile, functionName, propertyName, propertyValueExpressionSourceFile, propertyValue) => (ctx) => {
|
|
5966
6038
|
const visitor = (node) => {
|
|
5967
|
-
if (
|
|
6039
|
+
if (ts2.isCallExpression(node) && ts2.isIdentifier(node.expression) && node.expression.text === functionName && node.arguments.length > 0 && ts2.isObjectLiteralExpression(node.arguments[0])) {
|
|
5968
6040
|
let foundProperty = false;
|
|
5969
6041
|
const configObject = node.arguments[0];
|
|
5970
6042
|
const updateProperties = configObject.properties.map((property) => {
|
|
5971
|
-
if (
|
|
6043
|
+
if (ts2.isPropertyAssignment(property) || ts2.isShorthandPropertyAssignment(property)) {
|
|
5972
6044
|
const name2 = property.name.getText(sourceFile);
|
|
5973
6045
|
if (name2 === propertyName) {
|
|
5974
6046
|
foundProperty = true;
|
|
5975
|
-
return
|
|
6047
|
+
return ts2.factory.createPropertyAssignment(name2, propertyValue);
|
|
5976
6048
|
}
|
|
5977
6049
|
}
|
|
5978
6050
|
return property;
|
|
5979
6051
|
});
|
|
5980
6052
|
if (!foundProperty) {
|
|
5981
6053
|
updateProperties.unshift(
|
|
5982
|
-
|
|
6054
|
+
ts2.factory.createPropertyAssignment(propertyName, propertyValue)
|
|
5983
6055
|
);
|
|
5984
6056
|
}
|
|
5985
|
-
return
|
|
6057
|
+
return ts2.factory.createCallExpression(
|
|
5986
6058
|
node.expression,
|
|
5987
6059
|
node.typeArguments,
|
|
5988
|
-
[
|
|
6060
|
+
[ts2.factory.createObjectLiteralExpression(updateProperties, true)]
|
|
5989
6061
|
);
|
|
5990
6062
|
}
|
|
5991
|
-
return
|
|
6063
|
+
return ts2.visitEachChild(node, visitor, ctx);
|
|
5992
6064
|
};
|
|
5993
6065
|
return (sourceFile2) => {
|
|
5994
|
-
return
|
|
6066
|
+
return ts2.visitNode(sourceFile2, visitor);
|
|
5995
6067
|
};
|
|
5996
6068
|
};
|
|
5997
6069
|
var addSelfHostedTinaAuthToConfig = async (config2, configFile) => {
|
|
5998
6070
|
const pathToConfig = configFile.resolve(config2.typescript).path;
|
|
5999
|
-
const sourceFile =
|
|
6071
|
+
const sourceFile = ts2.createSourceFile(
|
|
6000
6072
|
pathToConfig,
|
|
6001
|
-
|
|
6002
|
-
config2.typescript ?
|
|
6073
|
+
fs13.readFileSync(pathToConfig, "utf8"),
|
|
6074
|
+
config2.typescript ? ts2.ScriptTarget.Latest : ts2.ScriptTarget.ESNext
|
|
6003
6075
|
);
|
|
6004
6076
|
const { configImports, configAuthProviderClass, extraTinaCollections } = config2.authProvider;
|
|
6005
6077
|
const importMap = {
|
|
@@ -6012,7 +6084,7 @@ var addSelfHostedTinaAuthToConfig = async (config2, configFile) => {
|
|
|
6012
6084
|
{}
|
|
6013
6085
|
)
|
|
6014
6086
|
};
|
|
6015
|
-
const transformedSourceFileResult =
|
|
6087
|
+
const transformedSourceFileResult = ts2.transform(
|
|
6016
6088
|
sourceFile,
|
|
6017
6089
|
[
|
|
6018
6090
|
makeImportsVisitor(sourceFile, {
|
|
@@ -6048,9 +6120,9 @@ var addSelfHostedTinaAuthToConfig = async (config2, configFile) => {
|
|
|
6048
6120
|
)
|
|
6049
6121
|
].map((visitor) => makeTransformer(visitor))
|
|
6050
6122
|
);
|
|
6051
|
-
return
|
|
6123
|
+
return fs13.writeFile(
|
|
6052
6124
|
pathToConfig,
|
|
6053
|
-
|
|
6125
|
+
ts2.createPrinter({ omitTrailingSemicolon: true }).printFile(transformedSourceFileResult.transformed[0])
|
|
6054
6126
|
);
|
|
6055
6127
|
};
|
|
6056
6128
|
|
|
@@ -6165,8 +6237,8 @@ async function apply({
|
|
|
6165
6237
|
await addConfigFile({
|
|
6166
6238
|
configArgs: {
|
|
6167
6239
|
config: config2,
|
|
6168
|
-
publicFolder:
|
|
6169
|
-
|
|
6240
|
+
publicFolder: path14.join(
|
|
6241
|
+
path14.relative(process.cwd(), pathToForestryConfig),
|
|
6170
6242
|
config2.publicFolder
|
|
6171
6243
|
),
|
|
6172
6244
|
collections,
|
|
@@ -6223,7 +6295,7 @@ var reportTelemetry = async ({
|
|
|
6223
6295
|
if (noTelemetry) {
|
|
6224
6296
|
logger.info(logText("Telemetry disabled"));
|
|
6225
6297
|
}
|
|
6226
|
-
const telemetry = new
|
|
6298
|
+
const telemetry = new Telemetry2({ disabled: noTelemetry });
|
|
6227
6299
|
const schemaFileType = usingTypescript ? "ts" : "js";
|
|
6228
6300
|
await telemetry.submitRecord({
|
|
6229
6301
|
event: {
|
|
@@ -6239,18 +6311,18 @@ var createPackageJSON = async () => {
|
|
|
6239
6311
|
};
|
|
6240
6312
|
var createGitignore = async ({ baseDir }) => {
|
|
6241
6313
|
logger.info(logText("No .gitignore found, creating one"));
|
|
6242
|
-
|
|
6314
|
+
fs14.outputFileSync(path14.join(baseDir, ".gitignore"), "node_modules");
|
|
6243
6315
|
};
|
|
6244
6316
|
var updateGitIgnore = async ({
|
|
6245
6317
|
baseDir,
|
|
6246
6318
|
items
|
|
6247
6319
|
}) => {
|
|
6248
6320
|
logger.info(logText(`Adding ${items.join(",")} to .gitignore`));
|
|
6249
|
-
const gitignoreContent =
|
|
6321
|
+
const gitignoreContent = fs14.readFileSync(path14.join(baseDir, ".gitignore")).toString();
|
|
6250
6322
|
const newGitignoreContent = [...gitignoreContent.split("\n"), ...items].join(
|
|
6251
6323
|
"\n"
|
|
6252
6324
|
);
|
|
6253
|
-
await
|
|
6325
|
+
await fs14.writeFile(path14.join(baseDir, ".gitignore"), newGitignoreContent);
|
|
6254
6326
|
};
|
|
6255
6327
|
var addDependencies = async (config2, env, params) => {
|
|
6256
6328
|
const { packageManager } = config2;
|
|
@@ -6291,7 +6363,8 @@ var addDependencies = async (config2, env, params) => {
|
|
|
6291
6363
|
let packageManagers = {
|
|
6292
6364
|
pnpm: process.env.USE_WORKSPACE ? `pnpm add ${deps.join(" ")} --workspace` : `pnpm add ${deps.join(" ")}`,
|
|
6293
6365
|
npm: `npm install ${deps.join(" ")}`,
|
|
6294
|
-
yarn: `yarn add ${deps.join(" ")}
|
|
6366
|
+
yarn: `yarn add ${deps.join(" ")}`,
|
|
6367
|
+
bun: `bun add ${deps.join(" ")}`
|
|
6295
6368
|
};
|
|
6296
6369
|
if (packageManagers[packageManager] && deps.length > 0) {
|
|
6297
6370
|
logger.info(logText("Adding dependencies, this might take a moment..."));
|
|
@@ -6302,7 +6375,8 @@ var addDependencies = async (config2, env, params) => {
|
|
|
6302
6375
|
packageManagers = {
|
|
6303
6376
|
pnpm: process.env.USE_WORKSPACE ? `pnpm add -D ${devDeps.join(" ")} --workspace` : `pnpm add -D ${devDeps.join(" ")}`,
|
|
6304
6377
|
npm: `npm install -D ${devDeps.join(" ")}`,
|
|
6305
|
-
yarn: `yarn add -D ${devDeps.join(" ")}
|
|
6378
|
+
yarn: `yarn add -D ${devDeps.join(" ")}`,
|
|
6379
|
+
bun: `bun add -D ${devDeps.join(" ")}`
|
|
6306
6380
|
};
|
|
6307
6381
|
if (packageManagers[packageManager]) {
|
|
6308
6382
|
logger.info(
|
|
@@ -6319,22 +6393,22 @@ var writeGeneratedFile = async ({
|
|
|
6319
6393
|
content,
|
|
6320
6394
|
typescript
|
|
6321
6395
|
}) => {
|
|
6322
|
-
const { exists, path:
|
|
6396
|
+
const { exists, path: path15, parentPath } = generatedFile.resolve(typescript);
|
|
6323
6397
|
if (exists) {
|
|
6324
6398
|
if (overwrite) {
|
|
6325
|
-
logger.info(`Overwriting file at ${
|
|
6326
|
-
|
|
6399
|
+
logger.info(`Overwriting file at ${path15}... \u2705`);
|
|
6400
|
+
fs14.outputFileSync(path15, content);
|
|
6327
6401
|
} else {
|
|
6328
|
-
logger.info(`Not overwriting file at ${
|
|
6402
|
+
logger.info(`Not overwriting file at ${path15}.`);
|
|
6329
6403
|
logger.info(
|
|
6330
|
-
logText(`Please add the following to ${
|
|
6404
|
+
logText(`Please add the following to ${path15}:
|
|
6331
6405
|
${indentText(content)}}`)
|
|
6332
6406
|
);
|
|
6333
6407
|
}
|
|
6334
6408
|
} else {
|
|
6335
|
-
logger.info(`Adding file at ${
|
|
6336
|
-
await
|
|
6337
|
-
|
|
6409
|
+
logger.info(`Adding file at ${path15}... \u2705`);
|
|
6410
|
+
await fs14.ensureDir(parentPath);
|
|
6411
|
+
fs14.outputFileSync(path15, content);
|
|
6338
6412
|
}
|
|
6339
6413
|
};
|
|
6340
6414
|
var addConfigFile = async ({
|
|
@@ -6343,7 +6417,7 @@ var addConfigFile = async ({
|
|
|
6343
6417
|
generatedFile,
|
|
6344
6418
|
config: config2
|
|
6345
6419
|
}) => {
|
|
6346
|
-
const content = (
|
|
6420
|
+
const content = format2(generateConfig(configArgs), {
|
|
6347
6421
|
parser: "babel"
|
|
6348
6422
|
});
|
|
6349
6423
|
await writeGeneratedFile({
|
|
@@ -6373,7 +6447,7 @@ var addNextApiRoute = async ({
|
|
|
6373
6447
|
generatedFile,
|
|
6374
6448
|
env
|
|
6375
6449
|
}) => {
|
|
6376
|
-
const content = (
|
|
6450
|
+
const content = format2(nextApiRouteTemplate({ config: config2, env }), {
|
|
6377
6451
|
parser: "babel"
|
|
6378
6452
|
});
|
|
6379
6453
|
await writeGeneratedFile({
|
|
@@ -6412,7 +6486,7 @@ var addContentFile = async ({
|
|
|
6412
6486
|
return () => ({
|
|
6413
6487
|
exists: env.sampleContentExists,
|
|
6414
6488
|
path: env.sampleContentPath,
|
|
6415
|
-
parentPath:
|
|
6489
|
+
parentPath: path14.dirname(env.sampleContentPath)
|
|
6416
6490
|
});
|
|
6417
6491
|
}
|
|
6418
6492
|
},
|
|
@@ -6435,10 +6509,10 @@ ${titleText(" TinaCMS ")} backend initialized!`));
|
|
|
6435
6509
|
return `${x.key}=${x.value || "***"}`;
|
|
6436
6510
|
}).join("\n") + `
|
|
6437
6511
|
TINA_PUBLIC_IS_LOCAL=true`;
|
|
6438
|
-
const envFile =
|
|
6439
|
-
if (!
|
|
6512
|
+
const envFile = path14.join(process.cwd(), ".env");
|
|
6513
|
+
if (!fs14.existsSync(envFile)) {
|
|
6440
6514
|
logger.info(`Adding .env file to your project... \u2705`);
|
|
6441
|
-
|
|
6515
|
+
fs14.writeFileSync(envFile, envFileText);
|
|
6442
6516
|
} else {
|
|
6443
6517
|
logger.info(
|
|
6444
6518
|
"Please add the following environment variables to your .env file"
|
|
@@ -6481,7 +6555,8 @@ var other = ({ packageManager }) => {
|
|
|
6481
6555
|
pnpm: `pnpm`,
|
|
6482
6556
|
npm: `npx`,
|
|
6483
6557
|
// npx is the way to run executables that aren't in your "scripts"
|
|
6484
|
-
yarn: `yarn
|
|
6558
|
+
yarn: `yarn`,
|
|
6559
|
+
bun: `bun run`
|
|
6485
6560
|
};
|
|
6486
6561
|
return `${packageManagers[packageManager]} tinacms dev -c "<your dev command>"`;
|
|
6487
6562
|
};
|
|
@@ -6494,7 +6569,8 @@ var frameworkDevCmds = {
|
|
|
6494
6569
|
pnpm: `pnpm`,
|
|
6495
6570
|
npm: `npm run`,
|
|
6496
6571
|
// npx is the way to run executables that aren't in your "scripts"
|
|
6497
|
-
yarn: `yarn
|
|
6572
|
+
yarn: `yarn`,
|
|
6573
|
+
bun: `bun run`
|
|
6498
6574
|
};
|
|
6499
6575
|
return `${packageManagers[packageManager]} dev`;
|
|
6500
6576
|
}
|
|
@@ -6507,7 +6583,7 @@ var addReactiveFile = {
|
|
|
6507
6583
|
baseDir,
|
|
6508
6584
|
dataLayer
|
|
6509
6585
|
}) => {
|
|
6510
|
-
const packageJsonPath =
|
|
6586
|
+
const packageJsonPath = path14.join(baseDir, "package.json");
|
|
6511
6587
|
await writeGeneratedFile({
|
|
6512
6588
|
generatedFile,
|
|
6513
6589
|
typescript: config2.typescript,
|
|
@@ -6520,7 +6596,7 @@ var addReactiveFile = {
|
|
|
6520
6596
|
})
|
|
6521
6597
|
});
|
|
6522
6598
|
logger.info("Adding a nextjs example... \u2705");
|
|
6523
|
-
const packageJson = JSON.parse(
|
|
6599
|
+
const packageJson = JSON.parse(fs14.readFileSync(packageJsonPath).toString());
|
|
6524
6600
|
const scripts = packageJson.scripts || {};
|
|
6525
6601
|
const updatedPackageJson = JSON.stringify(
|
|
6526
6602
|
{
|
|
@@ -6533,11 +6609,11 @@ var addReactiveFile = {
|
|
|
6533
6609
|
null,
|
|
6534
6610
|
2
|
|
6535
6611
|
);
|
|
6536
|
-
|
|
6612
|
+
fs14.writeFileSync(packageJsonPath, updatedPackageJson);
|
|
6537
6613
|
}
|
|
6538
6614
|
};
|
|
6539
6615
|
function execShellCommand(cmd) {
|
|
6540
|
-
const exec =
|
|
6616
|
+
const exec = __require("child_process").exec;
|
|
6541
6617
|
return new Promise((resolve2, reject) => {
|
|
6542
6618
|
exec(cmd, (error, stdout, stderr) => {
|
|
6543
6619
|
if (error) {
|
|
@@ -6583,34 +6659,27 @@ var command = new CLICommand({
|
|
|
6583
6659
|
});
|
|
6584
6660
|
|
|
6585
6661
|
// src/next/commands/init-command/index.ts
|
|
6586
|
-
var InitCommand = class extends
|
|
6587
|
-
|
|
6588
|
-
|
|
6589
|
-
|
|
6590
|
-
|
|
6591
|
-
|
|
6592
|
-
|
|
6593
|
-
|
|
6594
|
-
|
|
6595
|
-
|
|
6596
|
-
|
|
6597
|
-
|
|
6598
|
-
|
|
6599
|
-
|
|
6600
|
-
|
|
6601
|
-
|
|
6602
|
-
|
|
6603
|
-
|
|
6604
|
-
|
|
6605
|
-
|
|
6606
|
-
|
|
6607
|
-
}
|
|
6608
|
-
static {
|
|
6609
|
-
this.usage = import_clipanion6.Command.Usage({
|
|
6610
|
-
category: `Commands`,
|
|
6611
|
-
description: `Add Tina to an existing project`
|
|
6612
|
-
});
|
|
6613
|
-
}
|
|
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
|
+
});
|
|
6614
6683
|
async catch(error) {
|
|
6615
6684
|
logger.error("Error occured during tinacms init");
|
|
6616
6685
|
console.error(error);
|
|
@@ -6632,28 +6701,24 @@ var InitCommand = class extends import_clipanion6.Command {
|
|
|
6632
6701
|
};
|
|
6633
6702
|
|
|
6634
6703
|
// src/next/commands/searchindex-command/index.ts
|
|
6635
|
-
|
|
6636
|
-
|
|
6637
|
-
|
|
6638
|
-
|
|
6639
|
-
|
|
6640
|
-
|
|
6641
|
-
|
|
6642
|
-
|
|
6643
|
-
|
|
6644
|
-
|
|
6645
|
-
|
|
6646
|
-
|
|
6647
|
-
|
|
6648
|
-
|
|
6649
|
-
|
|
6650
|
-
|
|
6651
|
-
|
|
6652
|
-
|
|
6653
|
-
category: `Commands`,
|
|
6654
|
-
description: `Index the site for search`
|
|
6655
|
-
});
|
|
6656
|
-
}
|
|
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
|
+
});
|
|
6657
6722
|
async catch(error) {
|
|
6658
6723
|
logger.error("Error occured during tinacms search-index");
|
|
6659
6724
|
console.error(error);
|
|
@@ -6675,7 +6740,7 @@ var SearchIndexCommand = class extends import_clipanion7.Command {
|
|
|
6675
6740
|
process.exit(1);
|
|
6676
6741
|
}
|
|
6677
6742
|
const { schema } = configManager.config;
|
|
6678
|
-
const tinaSchema = await
|
|
6743
|
+
const tinaSchema = await createSchema({
|
|
6679
6744
|
schema: { ...schema, config: configManager.config }
|
|
6680
6745
|
});
|
|
6681
6746
|
let client;
|
|
@@ -6703,7 +6768,7 @@ var SearchIndexCommand = class extends import_clipanion7.Command {
|
|
|
6703
6768
|
"indexerToken not configured in tina search configuration."
|
|
6704
6769
|
);
|
|
6705
6770
|
}
|
|
6706
|
-
client = new
|
|
6771
|
+
client = new TinaCMSSearchIndexClient2({
|
|
6707
6772
|
apiUrl: `${configManager.config.tinaioConfig?.contentApiUrlOverride || "https://content.tinajs.io"}/searchIndex/${configManager.config?.clientId}`,
|
|
6708
6773
|
branch: configManager.config?.branch,
|
|
6709
6774
|
indexerToken: configManager.config?.search?.tina?.indexerToken,
|
|
@@ -6712,9 +6777,9 @@ var SearchIndexCommand = class extends import_clipanion7.Command {
|
|
|
6712
6777
|
} else {
|
|
6713
6778
|
client = configManager.config?.search?.searchClient;
|
|
6714
6779
|
}
|
|
6715
|
-
const searchIndexer = new
|
|
6780
|
+
const searchIndexer = new SearchIndexer3({
|
|
6716
6781
|
batchSize: configManager.config.search?.indexBatchSize || 100,
|
|
6717
|
-
bridge: new
|
|
6782
|
+
bridge: new FilesystemBridge4(
|
|
6718
6783
|
configManager.rootPath,
|
|
6719
6784
|
configManager.contentRootPath
|
|
6720
6785
|
),
|
|
@@ -6742,7 +6807,7 @@ var SearchIndexCommand = class extends import_clipanion7.Command {
|
|
|
6742
6807
|
};
|
|
6743
6808
|
|
|
6744
6809
|
// src/index.ts
|
|
6745
|
-
var cli = new
|
|
6810
|
+
var cli = new Cli({
|
|
6746
6811
|
binaryName: `tinacms`,
|
|
6747
6812
|
binaryLabel: `TinaCMS`,
|
|
6748
6813
|
binaryVersion: version
|
|
@@ -6753,7 +6818,10 @@ cli.register(AuditCommand);
|
|
|
6753
6818
|
cli.register(InitCommand);
|
|
6754
6819
|
cli.register(CodemodCommand);
|
|
6755
6820
|
cli.register(SearchIndexCommand);
|
|
6756
|
-
cli.register(
|
|
6757
|
-
cli.register(
|
|
6758
|
-
cli.register(
|
|
6821
|
+
cli.register(Builtins.DefinitionsCommand);
|
|
6822
|
+
cli.register(Builtins.HelpCommand);
|
|
6823
|
+
cli.register(Builtins.VersionCommand);
|
|
6759
6824
|
var index_default = cli;
|
|
6825
|
+
export {
|
|
6826
|
+
index_default as default
|
|
6827
|
+
};
|