@tinacms/cli 0.0.0-f00f07f-20241216063323 → 0.0.0-f322e12-20250327003611

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -4,9 +4,6 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
5
  var __getProtoOf = Object.getPrototypeOf;
6
6
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __commonJS = (cb, mod) => function __require() {
8
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
9
- };
10
7
  var __export = (target, all) => {
11
8
  for (var name2 in all)
12
9
  __defProp(target, name2, { get: all[name2], enumerable: true });
@@ -20,2093 +17,625 @@ var __copyProps = (to, from, except, desc) => {
20
17
  return to;
21
18
  };
22
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.
23
24
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
24
25
  mod
25
26
  ));
26
27
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
27
28
 
28
- // ../../../node_modules/.pnpm/tsconfig-paths@4.2.0/node_modules/tsconfig-paths/lib/filesystem.js
29
- var require_filesystem = __commonJS({
30
- "../../../node_modules/.pnpm/tsconfig-paths@4.2.0/node_modules/tsconfig-paths/lib/filesystem.js"(exports) {
31
- "use strict";
32
- Object.defineProperty(exports, "__esModule", { value: true });
33
- exports.removeExtension = exports.fileExistsAsync = exports.readJsonFromDiskAsync = exports.readJsonFromDiskSync = exports.fileExistsSync = void 0;
34
- var fs15 = require("fs");
35
- function fileExistsSync(path15) {
36
- if (!fs15.existsSync(path15)) {
37
- return false;
38
- }
39
- try {
40
- var stats = fs15.statSync(path15);
41
- return stats.isFile();
42
- } catch (err) {
43
- return false;
44
- }
45
- }
46
- exports.fileExistsSync = fileExistsSync;
47
- function readJsonFromDiskSync(packageJsonPath) {
48
- if (!fs15.existsSync(packageJsonPath)) {
49
- return void 0;
50
- }
51
- return require(packageJsonPath);
52
- }
53
- exports.readJsonFromDiskSync = readJsonFromDiskSync;
54
- function readJsonFromDiskAsync(path15, callback) {
55
- fs15.readFile(path15, "utf8", function(err, result) {
56
- if (err || !result) {
57
- return callback();
58
- }
59
- var json = JSON.parse(result);
60
- return callback(void 0, json);
61
- });
62
- }
63
- exports.readJsonFromDiskAsync = readJsonFromDiskAsync;
64
- function fileExistsAsync(path22, callback2) {
65
- fs15.stat(path22, function(err, stats) {
66
- if (err) {
67
- return callback2(void 0, false);
68
- }
69
- callback2(void 0, stats ? stats.isFile() : false);
70
- });
71
- }
72
- exports.fileExistsAsync = fileExistsAsync;
73
- function removeExtension(path15) {
74
- return path15.substring(0, path15.lastIndexOf(".")) || path15;
75
- }
76
- exports.removeExtension = removeExtension;
77
- }
29
+ // src/index.ts
30
+ var index_exports = {};
31
+ __export(index_exports, {
32
+ default: () => index_default
78
33
  });
34
+ module.exports = __toCommonJS(index_exports);
35
+ var import_clipanion8 = require("clipanion");
79
36
 
80
- // ../../../node_modules/.pnpm/tsconfig-paths@4.2.0/node_modules/tsconfig-paths/lib/mapping-entry.js
81
- var require_mapping_entry = __commonJS({
82
- "../../../node_modules/.pnpm/tsconfig-paths@4.2.0/node_modules/tsconfig-paths/lib/mapping-entry.js"(exports) {
83
- "use strict";
84
- Object.defineProperty(exports, "__esModule", { value: true });
85
- exports.getAbsoluteMappingEntries = void 0;
86
- var path15 = require("path");
87
- function getAbsoluteMappingEntries(absoluteBaseUrl, paths, addMatchAll) {
88
- var sortedKeys = sortByLongestPrefix(Object.keys(paths));
89
- var absolutePaths = [];
90
- for (var _i = 0, sortedKeys_1 = sortedKeys; _i < sortedKeys_1.length; _i++) {
91
- var key = sortedKeys_1[_i];
92
- absolutePaths.push({
93
- pattern: key,
94
- paths: paths[key].map(function(pathToResolve) {
95
- return path15.resolve(absoluteBaseUrl, pathToResolve);
96
- })
97
- });
98
- }
99
- if (!paths["*"] && addMatchAll) {
100
- absolutePaths.push({
101
- pattern: "*",
102
- paths: ["".concat(absoluteBaseUrl.replace(/\/$/, ""), "/*")]
103
- });
104
- }
105
- return absolutePaths;
106
- }
107
- exports.getAbsoluteMappingEntries = getAbsoluteMappingEntries;
108
- function sortByLongestPrefix(arr) {
109
- return arr.concat().sort(function(a, b) {
110
- return getPrefixLength(b) - getPrefixLength(a);
111
- });
112
- }
113
- function getPrefixLength(pattern) {
114
- var prefixLength = pattern.indexOf("*");
115
- return pattern.substr(0, prefixLength).length;
116
- }
117
- }
118
- });
37
+ // package.json
38
+ var version = "1.9.4";
119
39
 
120
- // ../../../node_modules/.pnpm/tsconfig-paths@4.2.0/node_modules/tsconfig-paths/lib/try-path.js
121
- var require_try_path = __commonJS({
122
- "../../../node_modules/.pnpm/tsconfig-paths@4.2.0/node_modules/tsconfig-paths/lib/try-path.js"(exports) {
123
- "use strict";
124
- Object.defineProperty(exports, "__esModule", { value: true });
125
- exports.exhaustiveTypeException = exports.getStrippedPath = exports.getPathsToTry = void 0;
126
- var path15 = require("path");
127
- var path_1 = require("path");
128
- var filesystem_1 = require_filesystem();
129
- function getPathsToTry(extensions, absolutePathMappings, requestedModule) {
130
- if (!absolutePathMappings || !requestedModule || requestedModule[0] === ".") {
131
- return void 0;
132
- }
133
- var pathsToTry = [];
134
- for (var _i = 0, absolutePathMappings_1 = absolutePathMappings; _i < absolutePathMappings_1.length; _i++) {
135
- var entry = absolutePathMappings_1[_i];
136
- var starMatch = entry.pattern === requestedModule ? "" : matchStar(entry.pattern, requestedModule);
137
- if (starMatch !== void 0) {
138
- var _loop_1 = function(physicalPathPattern2) {
139
- var physicalPath = physicalPathPattern2.replace("*", starMatch);
140
- pathsToTry.push({ type: "file", path: physicalPath });
141
- pathsToTry.push.apply(pathsToTry, extensions.map(function(e) {
142
- return { type: "extension", path: physicalPath + e };
143
- }));
144
- pathsToTry.push({
145
- type: "package",
146
- path: path15.join(physicalPath, "/package.json")
147
- });
148
- var indexPath = path15.join(physicalPath, "/index");
149
- pathsToTry.push.apply(pathsToTry, extensions.map(function(e) {
150
- return { type: "index", path: indexPath + e };
151
- }));
152
- };
153
- for (var _a = 0, _b = entry.paths; _a < _b.length; _a++) {
154
- var physicalPathPattern = _b[_a];
155
- _loop_1(physicalPathPattern);
156
- }
157
- }
158
- }
159
- return pathsToTry.length === 0 ? void 0 : pathsToTry;
160
- }
161
- exports.getPathsToTry = getPathsToTry;
162
- function getStrippedPath(tryPath) {
163
- return tryPath.type === "index" ? (0, path_1.dirname)(tryPath.path) : tryPath.type === "file" ? tryPath.path : tryPath.type === "extension" ? (0, filesystem_1.removeExtension)(tryPath.path) : tryPath.type === "package" ? tryPath.path : exhaustiveTypeException(tryPath.type);
164
- }
165
- exports.getStrippedPath = getStrippedPath;
166
- function exhaustiveTypeException(check) {
167
- throw new Error("Unknown type ".concat(check));
168
- }
169
- exports.exhaustiveTypeException = exhaustiveTypeException;
170
- function matchStar(pattern, search) {
171
- if (search.length < pattern.length) {
172
- return void 0;
173
- }
174
- if (pattern === "*") {
175
- return search;
176
- }
177
- var star = pattern.indexOf("*");
178
- if (star === -1) {
179
- return void 0;
180
- }
181
- var part1 = pattern.substring(0, star);
182
- var part2 = pattern.substring(star + 1);
183
- if (search.substr(0, star) !== part1) {
184
- return void 0;
185
- }
186
- if (search.substr(search.length - part2.length) !== part2) {
187
- return void 0;
188
- }
189
- return search.substr(star, search.length - part2.length);
190
- }
191
- }
192
- });
40
+ // src/next/commands/dev-command/index.ts
41
+ var import_async_lock = __toESM(require("async-lock"));
42
+ var import_clipanion2 = require("clipanion");
43
+ var import_fs_extra6 = __toESM(require("fs-extra"));
44
+ var import_path5 = __toESM(require("path"));
45
+ var import_chokidar = __toESM(require("chokidar"));
46
+ var import_graphql10 = require("@tinacms/graphql");
193
47
 
194
- // ../../../node_modules/.pnpm/tsconfig-paths@4.2.0/node_modules/tsconfig-paths/lib/match-path-sync.js
195
- var require_match_path_sync = __commonJS({
196
- "../../../node_modules/.pnpm/tsconfig-paths@4.2.0/node_modules/tsconfig-paths/lib/match-path-sync.js"(exports) {
197
- "use strict";
198
- Object.defineProperty(exports, "__esModule", { value: true });
199
- exports.matchFromAbsolutePaths = exports.createMatchPath = void 0;
200
- var path15 = require("path");
201
- var Filesystem = require_filesystem();
202
- var MappingEntry = require_mapping_entry();
203
- var TryPath = require_try_path();
204
- function createMatchPath(absoluteBaseUrl, paths, mainFields, addMatchAll) {
205
- if (mainFields === void 0) {
206
- mainFields = ["main"];
207
- }
208
- if (addMatchAll === void 0) {
209
- addMatchAll = true;
210
- }
211
- var absolutePaths = MappingEntry.getAbsoluteMappingEntries(absoluteBaseUrl, paths, addMatchAll);
212
- return function(requestedModule, readJson, fileExists, extensions) {
213
- return matchFromAbsolutePaths(absolutePaths, requestedModule, readJson, fileExists, extensions, mainFields);
214
- };
215
- }
216
- exports.createMatchPath = createMatchPath;
217
- function matchFromAbsolutePaths(absolutePathMappings, requestedModule, readJson, fileExists, extensions, mainFields) {
218
- if (readJson === void 0) {
219
- readJson = Filesystem.readJsonFromDiskSync;
220
- }
221
- if (fileExists === void 0) {
222
- fileExists = Filesystem.fileExistsSync;
223
- }
224
- if (extensions === void 0) {
225
- extensions = Object.keys(require.extensions);
226
- }
227
- if (mainFields === void 0) {
228
- mainFields = ["main"];
229
- }
230
- var tryPaths = TryPath.getPathsToTry(extensions, absolutePathMappings, requestedModule);
231
- if (!tryPaths) {
232
- return void 0;
233
- }
234
- return findFirstExistingPath(tryPaths, readJson, fileExists, mainFields);
235
- }
236
- exports.matchFromAbsolutePaths = matchFromAbsolutePaths;
237
- function findFirstExistingMainFieldMappedFile(packageJson, mainFields, packageJsonPath, fileExists) {
238
- for (var index = 0; index < mainFields.length; index++) {
239
- var mainFieldSelector = mainFields[index];
240
- var candidateMapping = typeof mainFieldSelector === "string" ? packageJson[mainFieldSelector] : mainFieldSelector.reduce(function(obj, key) {
241
- return obj[key];
242
- }, packageJson);
243
- if (candidateMapping && typeof candidateMapping === "string") {
244
- var candidateFilePath = path15.join(path15.dirname(packageJsonPath), candidateMapping);
245
- if (fileExists(candidateFilePath)) {
246
- return candidateFilePath;
247
- }
248
- }
249
- }
250
- return void 0;
251
- }
252
- function findFirstExistingPath(tryPaths, readJson, fileExists, mainFields) {
253
- if (readJson === void 0) {
254
- readJson = Filesystem.readJsonFromDiskSync;
255
- }
256
- if (mainFields === void 0) {
257
- mainFields = ["main"];
258
- }
259
- for (var _i = 0, tryPaths_1 = tryPaths; _i < tryPaths_1.length; _i++) {
260
- var tryPath = tryPaths_1[_i];
261
- if (tryPath.type === "file" || tryPath.type === "extension" || tryPath.type === "index") {
262
- if (fileExists(tryPath.path)) {
263
- return TryPath.getStrippedPath(tryPath);
264
- }
265
- } else if (tryPath.type === "package") {
266
- var packageJson = readJson(tryPath.path);
267
- if (packageJson) {
268
- var mainFieldMappedFile = findFirstExistingMainFieldMappedFile(packageJson, mainFields, tryPath.path, fileExists);
269
- if (mainFieldMappedFile) {
270
- return mainFieldMappedFile;
271
- }
272
- }
273
- } else {
274
- TryPath.exhaustiveTypeException(tryPath.type);
275
- }
276
- }
277
- return void 0;
278
- }
279
- }
280
- });
48
+ // src/next/config-manager.ts
49
+ var import_fs_extra = __toESM(require("fs-extra"));
50
+ var import_path = __toESM(require("path"));
51
+ var import_os = __toESM(require("os"));
52
+ var esbuild = __toESM(require("esbuild"));
53
+ var dotenv = __toESM(require("dotenv"));
54
+ var import_normalize_path = __toESM(require("normalize-path"));
55
+ var import_chalk2 = __toESM(require("chalk"));
281
56
 
282
- // ../../../node_modules/.pnpm/tsconfig-paths@4.2.0/node_modules/tsconfig-paths/lib/match-path-async.js
283
- var require_match_path_async = __commonJS({
284
- "../../../node_modules/.pnpm/tsconfig-paths@4.2.0/node_modules/tsconfig-paths/lib/match-path-async.js"(exports) {
285
- "use strict";
286
- Object.defineProperty(exports, "__esModule", { value: true });
287
- exports.matchFromAbsolutePathsAsync = exports.createMatchPathAsync = void 0;
288
- var path15 = require("path");
289
- var TryPath = require_try_path();
290
- var MappingEntry = require_mapping_entry();
291
- var Filesystem = require_filesystem();
292
- function createMatchPathAsync(absoluteBaseUrl, paths, mainFields, addMatchAll) {
293
- if (mainFields === void 0) {
294
- mainFields = ["main"];
295
- }
296
- if (addMatchAll === void 0) {
297
- addMatchAll = true;
298
- }
299
- var absolutePaths = MappingEntry.getAbsoluteMappingEntries(absoluteBaseUrl, paths, addMatchAll);
300
- return function(requestedModule, readJson, fileExists, extensions, callback) {
301
- return matchFromAbsolutePathsAsync(absolutePaths, requestedModule, readJson, fileExists, extensions, callback, mainFields);
302
- };
303
- }
304
- exports.createMatchPathAsync = createMatchPathAsync;
305
- function matchFromAbsolutePathsAsync(absolutePathMappings, requestedModule, readJson, fileExists, extensions, callback, mainFields) {
306
- if (readJson === void 0) {
307
- readJson = Filesystem.readJsonFromDiskAsync;
308
- }
309
- if (fileExists === void 0) {
310
- fileExists = Filesystem.fileExistsAsync;
311
- }
312
- if (extensions === void 0) {
313
- extensions = Object.keys(require.extensions);
314
- }
315
- if (mainFields === void 0) {
316
- mainFields = ["main"];
317
- }
318
- var tryPaths = TryPath.getPathsToTry(extensions, absolutePathMappings, requestedModule);
319
- if (!tryPaths) {
320
- return callback();
321
- }
322
- findFirstExistingPath(tryPaths, readJson, fileExists, callback, 0, mainFields);
323
- }
324
- exports.matchFromAbsolutePathsAsync = matchFromAbsolutePathsAsync;
325
- function findFirstExistingMainFieldMappedFile(packageJson, mainFields, packageJsonPath, fileExistsAsync, doneCallback, index) {
326
- if (index === void 0) {
327
- index = 0;
328
- }
329
- if (index >= mainFields.length) {
330
- return doneCallback(void 0, void 0);
331
- }
332
- var tryNext = function() {
333
- return findFirstExistingMainFieldMappedFile(packageJson, mainFields, packageJsonPath, fileExistsAsync, doneCallback, index + 1);
334
- };
335
- var mainFieldSelector = mainFields[index];
336
- var mainFieldMapping = typeof mainFieldSelector === "string" ? packageJson[mainFieldSelector] : mainFieldSelector.reduce(function(obj, key) {
337
- return obj[key];
338
- }, packageJson);
339
- if (typeof mainFieldMapping !== "string") {
340
- return tryNext();
341
- }
342
- var mappedFilePath = path15.join(path15.dirname(packageJsonPath), mainFieldMapping);
343
- fileExistsAsync(mappedFilePath, function(err, exists) {
344
- if (err) {
345
- return doneCallback(err);
346
- }
347
- if (exists) {
348
- return doneCallback(void 0, mappedFilePath);
349
- }
350
- return tryNext();
351
- });
352
- }
353
- function findFirstExistingPath(tryPaths, readJson, fileExists, doneCallback, index, mainFields) {
354
- if (index === void 0) {
355
- index = 0;
356
- }
357
- if (mainFields === void 0) {
358
- mainFields = ["main"];
359
- }
360
- var tryPath = tryPaths[index];
361
- if (tryPath.type === "file" || tryPath.type === "extension" || tryPath.type === "index") {
362
- fileExists(tryPath.path, function(err, exists) {
363
- if (err) {
364
- return doneCallback(err);
365
- }
366
- if (exists) {
367
- return doneCallback(void 0, TryPath.getStrippedPath(tryPath));
368
- }
369
- if (index === tryPaths.length - 1) {
370
- return doneCallback();
371
- }
372
- return findFirstExistingPath(tryPaths, readJson, fileExists, doneCallback, index + 1, mainFields);
373
- });
374
- } else if (tryPath.type === "package") {
375
- readJson(tryPath.path, function(err, packageJson) {
376
- if (err) {
377
- return doneCallback(err);
378
- }
379
- if (packageJson) {
380
- return findFirstExistingMainFieldMappedFile(packageJson, mainFields, tryPath.path, fileExists, function(mainFieldErr, mainFieldMappedFile) {
381
- if (mainFieldErr) {
382
- return doneCallback(mainFieldErr);
383
- }
384
- if (mainFieldMappedFile) {
385
- return doneCallback(void 0, mainFieldMappedFile);
386
- }
387
- return findFirstExistingPath(tryPaths, readJson, fileExists, doneCallback, index + 1, mainFields);
388
- });
389
- }
390
- return findFirstExistingPath(tryPaths, readJson, fileExists, doneCallback, index + 1, mainFields);
391
- });
392
- } else {
393
- TryPath.exhaustiveTypeException(tryPath.type);
394
- }
395
- }
396
- }
397
- });
57
+ // src/logger/index.ts
58
+ var import_chalk = __toESM(require("chalk"));
398
59
 
399
- // ../../../node_modules/.pnpm/json5@2.2.3/node_modules/json5/lib/unicode.js
400
- var require_unicode = __commonJS({
401
- "../../../node_modules/.pnpm/json5@2.2.3/node_modules/json5/lib/unicode.js"(exports, module2) {
402
- module2.exports.Space_Separator = /[\u1680\u2000-\u200A\u202F\u205F\u3000]/;
403
- module2.exports.ID_Start = /[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u08A0-\u08B4\u08B6-\u08BD\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312E\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FEA\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF4A\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDF00-\uDF19]|\uD806[\uDCA0-\uDCDF\uDCFF\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE83\uDE86-\uDE89\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50\uDF93-\uDF9F\uDFE0\uDFE1]|\uD821[\uDC00-\uDFEC]|\uD822[\uDC00-\uDEF2]|\uD82C[\uDC00-\uDD1E\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]/;
404
- module2.exports.ID_Continue = /[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u0487\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u05D0-\u05EA\u05F0-\u05F2\u0610-\u061A\u0620-\u0669\u066E-\u06D3\u06D5-\u06DC\u06DF-\u06E8\u06EA-\u06FC\u06FF\u0710-\u074A\u074D-\u07B1\u07C0-\u07F5\u07FA\u0800-\u082D\u0840-\u085B\u0860-\u086A\u08A0-\u08B4\u08B6-\u08BD\u08D4-\u08E1\u08E3-\u0963\u0966-\u096F\u0971-\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7\u09C8\u09CB-\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E3\u09E6-\u09F1\u09FC\u0A01-\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A59-\u0A5C\u0A5E\u0A66-\u0A75\u0A81-\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABC-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AD0\u0AE0-\u0AE3\u0AE6-\u0AEF\u0AF9-\u0AFF\u0B01-\u0B03\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3C-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B5C\u0B5D\u0B5F-\u0B63\u0B66-\u0B6F\u0B71\u0B82\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD0\u0BD7\u0BE6-\u0BEF\u0C00-\u0C03\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C58-\u0C5A\u0C60-\u0C63\u0C66-\u0C6F\u0C80-\u0C83\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBC-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CDE\u0CE0-\u0CE3\u0CE6-\u0CEF\u0CF1\u0CF2\u0D00-\u0D03\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D44\u0D46-\u0D48\u0D4A-\u0D4E\u0D54-\u0D57\u0D5F-\u0D63\u0D66-\u0D6F\u0D7A-\u0D7F\u0D82\u0D83\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E01-\u0E3A\u0E40-\u0E4E\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB9\u0EBB-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECD\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E-\u0F47\u0F49-\u0F6C\u0F71-\u0F84\u0F86-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1049\u1050-\u109D\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u135D-\u135F\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772\u1773\u1780-\u17D3\u17D7\u17DC\u17DD\u17E0-\u17E9\u180B-\u180D\u1810-\u1819\u1820-\u1877\u1880-\u18AA\u18B0-\u18F5\u1900-\u191E\u1920-\u192B\u1930-\u193B\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19D9\u1A00-\u1A1B\u1A20-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AA7\u1AB0-\u1ABD\u1B00-\u1B4B\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BF3\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1C80-\u1C88\u1CD0-\u1CD2\u1CD4-\u1CF9\u1D00-\u1DF9\u1DFB-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u203F\u2040\u2054\u2071\u207F\u2090-\u209C\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D7F-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2DFF\u2E2F\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099\u309A\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312E\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FEA\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66F\uA674-\uA67D\uA67F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA827\uA840-\uA873\uA880-\uA8C5\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA8FD\uA900-\uA92D\uA930-\uA953\uA960-\uA97C\uA980-\uA9C0\uA9CF-\uA9D9\uA9E0-\uA9FE\uAA00-\uAA36\uAA40-\uAA4D\uAA50-\uAA59\uAA60-\uAA76\uAA7A-\uAAC2\uAADB-\uAADD\uAAE0-\uAAEF\uAAF2-\uAAF6\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABEA\uABEC\uABED\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE00-\uFE0F\uFE20-\uFE2F\uFE33\uFE34\uFE4D-\uFE4F\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF3F\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDDFD\uDE80-\uDE9C\uDEA0-\uDED0\uDEE0\uDF00-\uDF1F\uDF2D-\uDF4A\uDF50-\uDF7A\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCA0-\uDCA9\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00-\uDE03\uDE05\uDE06\uDE0C-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE38-\uDE3A\uDE3F\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE6\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC00-\uDC46\uDC66-\uDC6F\uDC7F-\uDCBA\uDCD0-\uDCE8\uDCF0-\uDCF9\uDD00-\uDD34\uDD36-\uDD3F\uDD50-\uDD73\uDD76\uDD80-\uDDC4\uDDCA-\uDDCC\uDDD0-\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE37\uDE3E\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEEA\uDEF0-\uDEF9\uDF00-\uDF03\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3C-\uDF44\uDF47\uDF48\uDF4B-\uDF4D\uDF50\uDF57\uDF5D-\uDF63\uDF66-\uDF6C\uDF70-\uDF74]|\uD805[\uDC00-\uDC4A\uDC50-\uDC59\uDC80-\uDCC5\uDCC7\uDCD0-\uDCD9\uDD80-\uDDB5\uDDB8-\uDDC0\uDDD8-\uDDDD\uDE00-\uDE40\uDE44\uDE50-\uDE59\uDE80-\uDEB7\uDEC0-\uDEC9\uDF00-\uDF19\uDF1D-\uDF2B\uDF30-\uDF39]|\uD806[\uDCA0-\uDCE9\uDCFF\uDE00-\uDE3E\uDE47\uDE50-\uDE83\uDE86-\uDE99\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC36\uDC38-\uDC40\uDC50-\uDC59\uDC72-\uDC8F\uDC92-\uDCA7\uDCA9-\uDCB6\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD36\uDD3A\uDD3C\uDD3D\uDD3F-\uDD47\uDD50-\uDD59]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE60-\uDE69\uDED0-\uDEED\uDEF0-\uDEF4\uDF00-\uDF36\uDF40-\uDF43\uDF50-\uDF59\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50-\uDF7E\uDF8F-\uDF9F\uDFE0\uDFE1]|\uD821[\uDC00-\uDFEC]|\uD822[\uDC00-\uDEF2]|\uD82C[\uDC00-\uDD1E\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99\uDC9D\uDC9E]|\uD834[\uDD65-\uDD69\uDD6D-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB\uDFCE-\uDFFF]|\uD836[\uDE00-\uDE36\uDE3B-\uDE6C\uDE75\uDE84\uDE9B-\uDE9F\uDEA1-\uDEAF]|\uD838[\uDC00-\uDC06\uDC08-\uDC18\uDC1B-\uDC21\uDC23\uDC24\uDC26-\uDC2A]|\uD83A[\uDC00-\uDCC4\uDCD0-\uDCD6\uDD00-\uDD4A\uDD50-\uDD59]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uDB40[\uDD00-\uDDEF]/;
60
+ // src/logger/is-unicode-supported.ts
61
+ function isUnicodeSupported() {
62
+ if (process.platform !== "win32") {
63
+ return process.env.TERM !== "linux";
405
64
  }
406
- });
65
+ return Boolean(process.env.CI) || Boolean(process.env.WT_SESSION) || // Windows Terminal
66
+ Boolean(process.env.TERMINUS_SUBLIME) || // Terminus (<0.2.27)
67
+ process.env.ConEmuTask === "{cmd::Cmder}" || // ConEmu and cmder
68
+ process.env.TERM_PROGRAM === "Terminus-Sublime" || process.env.TERM_PROGRAM === "vscode" || process.env.TERM === "xterm-256color" || process.env.TERM === "alacritty" || process.env.TERMINAL_EMULATOR === "JetBrains-JediTerm";
69
+ }
407
70
 
408
- // ../../../node_modules/.pnpm/json5@2.2.3/node_modules/json5/lib/util.js
409
- var require_util = __commonJS({
410
- "../../../node_modules/.pnpm/json5@2.2.3/node_modules/json5/lib/util.js"(exports, module2) {
411
- var unicode2 = require_unicode();
412
- module2.exports = {
413
- isSpaceSeparator(c) {
414
- return typeof c === "string" && unicode2.Space_Separator.test(c);
415
- },
416
- isIdStartChar(c) {
417
- return typeof c === "string" && (c >= "a" && c <= "z" || c >= "A" && c <= "Z" || c === "$" || c === "_" || unicode2.ID_Start.test(c));
418
- },
419
- isIdContinueChar(c) {
420
- return typeof c === "string" && (c >= "a" && c <= "z" || c >= "A" && c <= "Z" || c >= "0" && c <= "9" || c === "$" || c === "_" || c === "\u200C" || c === "\u200D" || unicode2.ID_Continue.test(c));
421
- },
422
- isDigit(c) {
423
- return typeof c === "string" && /[0-9]/.test(c);
424
- },
425
- isHexDigit(c) {
426
- return typeof c === "string" && /[0-9A-Fa-f]/.test(c);
71
+ // src/logger/index.ts
72
+ var import_log4js = __toESM(require("log4js"));
73
+ var logger = import_log4js.default.getLogger();
74
+ import_log4js.default.configure({
75
+ appenders: {
76
+ out: { type: "stdout", layout: { type: "messagePassThrough" } }
77
+ },
78
+ categories: { default: { appenders: ["out"], level: "info" } }
79
+ });
80
+ logger.level = "info";
81
+ function ansiRegex() {
82
+ const pattern = [
83
+ "[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)",
84
+ "(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"
85
+ ].join("|");
86
+ return new RegExp(pattern, "g");
87
+ }
88
+ var bar = "\u2502";
89
+ var strip = (str) => str.replace(ansiRegex(), "");
90
+ var note = (message = "", title = "") => {
91
+ const lines = `
92
+ ${message}
93
+ `.split("\n");
94
+ const len = lines.reduce((sum, ln) => {
95
+ ln = strip(ln);
96
+ return ln.length > sum ? ln.length : sum;
97
+ }, 0) + 2;
98
+ const msg = lines.map(
99
+ (ln) => `${import_chalk.default.gray(bar)} ${import_chalk.default.white(ln)}${" ".repeat(
100
+ len - strip(ln).length
101
+ )}${import_chalk.default.gray(bar)}`
102
+ ).join("\n");
103
+ const underscoreLen = len - title.length - 1 > 0 ? len - title.length - 1 : 0;
104
+ process.stdout.write(
105
+ `${import_chalk.default.gray(bar)}
106
+ ${import_chalk.default.green("\u25CB")} ${import_chalk.default.reset(
107
+ title
108
+ )} ${import_chalk.default.gray("\u2500".repeat(underscoreLen) + "\u256E")}
109
+ ${msg}
110
+ ${import_chalk.default.gray(
111
+ "\u251C" + "\u2500".repeat(len + 2) + "\u256F"
112
+ )}
113
+ `
114
+ );
115
+ };
116
+ var summary = (content) => {
117
+ const outString = [];
118
+ let longestKey = 0;
119
+ content.items.forEach((item) => {
120
+ item.subItems.forEach((subItem) => {
121
+ if (subItem.key.length > longestKey) {
122
+ longestKey = subItem.key.length;
427
123
  }
428
- };
124
+ });
125
+ });
126
+ content.items.forEach((item) => {
127
+ outString.push(`${item.emoji} ${import_chalk.default.cyan(item.heading)}`);
128
+ item.subItems.forEach((subItem) => {
129
+ const spaces = longestKey - subItem.key.length + 4;
130
+ outString.push(
131
+ ` ${subItem.key}:${[...Array(spaces)].join(" ")}${import_chalk.default.cyan(
132
+ subItem.value
133
+ )}`
134
+ );
135
+ });
136
+ outString.push(``);
137
+ });
138
+ if (process.env.CI) {
139
+ logger.info(JSON.stringify(content, null, 2));
140
+ } else {
141
+ note(outString.join("\n"), content.heading);
429
142
  }
430
- });
143
+ };
144
+ var unicode = isUnicodeSupported();
145
+ var s = (c, fallback) => unicode ? c : fallback;
146
+ var S_STEP_ACTIVE = s("\u25C6", "*");
147
+ var S_STEP_CANCEL = s("\u25A0", "x");
148
+ var S_STEP_ERROR = s("\u25B2", "x");
149
+ var S_STEP_SUBMIT = s("\u25C7", "o");
150
+ var S_BAR_START = s("\u250C", "T");
151
+ var S_BAR = s("\u2502", "|");
152
+ var S_BAR_END = s("\u2514", "\u2014");
153
+ var S_RADIO_ACTIVE = s("\u25CF", ">");
154
+ var S_RADIO_INACTIVE = s("\u25CB", " ");
155
+ var S_CHECKBOX_ACTIVE = s("\u25FB", "[\u2022]");
156
+ var S_CHECKBOX_SELECTED = s("\u25FC", "[+]");
157
+ var S_CHECKBOX_INACTIVE = s("\u25FB", "[ ]");
158
+ var S_PASSWORD_MASK = s("\u25AA", "\u2022");
159
+ var S_BAR_H = s("\u2500", "-");
160
+ var S_CORNER_TOP_RIGHT = s("\u256E", "+");
161
+ var S_CONNECT_LEFT = s("\u251C", "+");
162
+ var S_CORNER_BOTTOM_RIGHT = s("\u256F", "+");
163
+ var S_INFO = s("\u25CF", "\u2022");
164
+ var S_SUCCESS = s("\u25C6", "*");
165
+ var S_WARN = s("\u25B2", "!");
166
+ var S_ERROR = s("\u25A0", "x");
431
167
 
432
- // ../../../node_modules/.pnpm/json5@2.2.3/node_modules/json5/lib/parse.js
433
- var require_parse = __commonJS({
434
- "../../../node_modules/.pnpm/json5@2.2.3/node_modules/json5/lib/parse.js"(exports, module2) {
435
- var util = require_util();
436
- var source;
437
- var parseState;
438
- var stack;
439
- var pos;
440
- var line;
441
- var column;
442
- var token;
443
- var key;
444
- var root;
445
- module2.exports = function parse2(text, reviver) {
446
- source = String(text);
447
- parseState = "start";
448
- stack = [];
449
- pos = 0;
450
- line = 1;
451
- column = 0;
452
- token = void 0;
453
- key = void 0;
454
- root = void 0;
455
- do {
456
- token = lex();
457
- parseStates[parseState]();
458
- } while (token.type !== "eof");
459
- if (typeof reviver === "function") {
460
- return internalize({ "": root }, "", reviver);
461
- }
462
- return root;
463
- };
464
- function internalize(holder, name2, reviver) {
465
- const value = holder[name2];
466
- if (value != null && typeof value === "object") {
467
- if (Array.isArray(value)) {
468
- for (let i = 0; i < value.length; i++) {
469
- const key2 = String(i);
470
- const replacement = internalize(value, key2, reviver);
471
- if (replacement === void 0) {
472
- delete value[key2];
473
- } else {
474
- Object.defineProperty(value, key2, {
475
- value: replacement,
476
- writable: true,
477
- enumerable: true,
478
- configurable: true
479
- });
480
- }
481
- }
482
- } else {
483
- for (const key2 in value) {
484
- const replacement = internalize(value, key2, reviver);
485
- if (replacement === void 0) {
486
- delete value[key2];
487
- } else {
488
- Object.defineProperty(value, key2, {
489
- value: replacement,
490
- writable: true,
491
- enumerable: true,
492
- configurable: true
493
- });
494
- }
495
- }
496
- }
497
- }
498
- return reviver.call(holder, name2, value);
499
- }
500
- var lexState;
501
- var buffer;
502
- var doubleQuote;
503
- var sign;
504
- var c;
505
- function lex() {
506
- lexState = "default";
507
- buffer = "";
508
- doubleQuote = false;
509
- sign = 1;
510
- for (; ; ) {
511
- c = peek();
512
- const token2 = lexStates[lexState]();
513
- if (token2) {
514
- return token2;
515
- }
516
- }
517
- }
518
- function peek() {
519
- if (source[pos]) {
520
- return String.fromCodePoint(source.codePointAt(pos));
521
- }
522
- }
523
- function read() {
524
- const c2 = peek();
525
- if (c2 === "\n") {
526
- line++;
527
- column = 0;
528
- } else if (c2) {
529
- column += c2.length;
530
- } else {
531
- column++;
532
- }
533
- if (c2) {
534
- pos += c2.length;
535
- }
536
- return c2;
537
- }
538
- var lexStates = {
539
- default() {
540
- switch (c) {
541
- case " ":
542
- case "\v":
543
- case "\f":
544
- case " ":
545
- case "\xA0":
546
- case "\uFEFF":
547
- case "\n":
548
- case "\r":
549
- case "\u2028":
550
- case "\u2029":
551
- read();
552
- return;
553
- case "/":
554
- read();
555
- lexState = "comment";
556
- return;
557
- case void 0:
558
- read();
559
- return newToken("eof");
560
- }
561
- if (util.isSpaceSeparator(c)) {
562
- read();
563
- return;
564
- }
565
- return lexStates[parseState]();
566
- },
567
- comment() {
568
- switch (c) {
569
- case "*":
570
- read();
571
- lexState = "multiLineComment";
572
- return;
573
- case "/":
574
- read();
575
- lexState = "singleLineComment";
576
- return;
577
- }
578
- throw invalidChar(read());
579
- },
580
- multiLineComment() {
581
- switch (c) {
582
- case "*":
583
- read();
584
- lexState = "multiLineCommentAsterisk";
585
- return;
586
- case void 0:
587
- throw invalidChar(read());
588
- }
589
- read();
590
- },
591
- multiLineCommentAsterisk() {
592
- switch (c) {
593
- case "*":
594
- read();
595
- return;
596
- case "/":
597
- read();
598
- lexState = "default";
599
- return;
600
- case void 0:
601
- throw invalidChar(read());
602
- }
603
- read();
604
- lexState = "multiLineComment";
605
- },
606
- singleLineComment() {
607
- switch (c) {
608
- case "\n":
609
- case "\r":
610
- case "\u2028":
611
- case "\u2029":
612
- read();
613
- lexState = "default";
614
- return;
615
- case void 0:
616
- read();
617
- return newToken("eof");
618
- }
619
- read();
620
- },
621
- value() {
622
- switch (c) {
623
- case "{":
624
- case "[":
625
- return newToken("punctuator", read());
626
- case "n":
627
- read();
628
- literal("ull");
629
- return newToken("null", null);
630
- case "t":
631
- read();
632
- literal("rue");
633
- return newToken("boolean", true);
634
- case "f":
635
- read();
636
- literal("alse");
637
- return newToken("boolean", false);
638
- case "-":
639
- case "+":
640
- if (read() === "-") {
641
- sign = -1;
642
- }
643
- lexState = "sign";
644
- return;
645
- case ".":
646
- buffer = read();
647
- lexState = "decimalPointLeading";
648
- return;
649
- case "0":
650
- buffer = read();
651
- lexState = "zero";
652
- return;
653
- case "1":
654
- case "2":
655
- case "3":
656
- case "4":
657
- case "5":
658
- case "6":
659
- case "7":
660
- case "8":
661
- case "9":
662
- buffer = read();
663
- lexState = "decimalInteger";
664
- return;
665
- case "I":
666
- read();
667
- literal("nfinity");
668
- return newToken("numeric", Infinity);
669
- case "N":
670
- read();
671
- literal("aN");
672
- return newToken("numeric", NaN);
673
- case '"':
674
- case "'":
675
- doubleQuote = read() === '"';
676
- buffer = "";
677
- lexState = "string";
678
- return;
679
- }
680
- throw invalidChar(read());
681
- },
682
- identifierNameStartEscape() {
683
- if (c !== "u") {
684
- throw invalidChar(read());
685
- }
686
- read();
687
- const u = unicodeEscape();
688
- switch (u) {
689
- case "$":
690
- case "_":
691
- break;
692
- default:
693
- if (!util.isIdStartChar(u)) {
694
- throw invalidIdentifier();
695
- }
696
- break;
697
- }
698
- buffer += u;
699
- lexState = "identifierName";
700
- },
701
- identifierName() {
702
- switch (c) {
703
- case "$":
704
- case "_":
705
- case "\u200C":
706
- case "\u200D":
707
- buffer += read();
708
- return;
709
- case "\\":
710
- read();
711
- lexState = "identifierNameEscape";
712
- return;
713
- }
714
- if (util.isIdContinueChar(c)) {
715
- buffer += read();
716
- return;
717
- }
718
- return newToken("identifier", buffer);
719
- },
720
- identifierNameEscape() {
721
- if (c !== "u") {
722
- throw invalidChar(read());
723
- }
724
- read();
725
- const u = unicodeEscape();
726
- switch (u) {
727
- case "$":
728
- case "_":
729
- case "\u200C":
730
- case "\u200D":
731
- break;
732
- default:
733
- if (!util.isIdContinueChar(u)) {
734
- throw invalidIdentifier();
735
- }
736
- break;
737
- }
738
- buffer += u;
739
- lexState = "identifierName";
740
- },
741
- sign() {
742
- switch (c) {
743
- case ".":
744
- buffer = read();
745
- lexState = "decimalPointLeading";
746
- return;
747
- case "0":
748
- buffer = read();
749
- lexState = "zero";
750
- return;
751
- case "1":
752
- case "2":
753
- case "3":
754
- case "4":
755
- case "5":
756
- case "6":
757
- case "7":
758
- case "8":
759
- case "9":
760
- buffer = read();
761
- lexState = "decimalInteger";
762
- return;
763
- case "I":
764
- read();
765
- literal("nfinity");
766
- return newToken("numeric", sign * Infinity);
767
- case "N":
768
- read();
769
- literal("aN");
770
- return newToken("numeric", NaN);
771
- }
772
- throw invalidChar(read());
773
- },
774
- zero() {
775
- switch (c) {
776
- case ".":
777
- buffer += read();
778
- lexState = "decimalPoint";
779
- return;
780
- case "e":
781
- case "E":
782
- buffer += read();
783
- lexState = "decimalExponent";
784
- return;
785
- case "x":
786
- case "X":
787
- buffer += read();
788
- lexState = "hexadecimal";
789
- return;
790
- }
791
- return newToken("numeric", sign * 0);
792
- },
793
- decimalInteger() {
794
- switch (c) {
795
- case ".":
796
- buffer += read();
797
- lexState = "decimalPoint";
798
- return;
799
- case "e":
800
- case "E":
801
- buffer += read();
802
- lexState = "decimalExponent";
803
- return;
804
- }
805
- if (util.isDigit(c)) {
806
- buffer += read();
807
- return;
808
- }
809
- return newToken("numeric", sign * Number(buffer));
810
- },
811
- decimalPointLeading() {
812
- if (util.isDigit(c)) {
813
- buffer += read();
814
- lexState = "decimalFraction";
815
- return;
816
- }
817
- throw invalidChar(read());
818
- },
819
- decimalPoint() {
820
- switch (c) {
821
- case "e":
822
- case "E":
823
- buffer += read();
824
- lexState = "decimalExponent";
825
- return;
826
- }
827
- if (util.isDigit(c)) {
828
- buffer += read();
829
- lexState = "decimalFraction";
830
- return;
831
- }
832
- return newToken("numeric", sign * Number(buffer));
833
- },
834
- decimalFraction() {
835
- switch (c) {
836
- case "e":
837
- case "E":
838
- buffer += read();
839
- lexState = "decimalExponent";
840
- return;
841
- }
842
- if (util.isDigit(c)) {
843
- buffer += read();
844
- return;
845
- }
846
- return newToken("numeric", sign * Number(buffer));
847
- },
848
- decimalExponent() {
849
- switch (c) {
850
- case "+":
851
- case "-":
852
- buffer += read();
853
- lexState = "decimalExponentSign";
854
- return;
855
- }
856
- if (util.isDigit(c)) {
857
- buffer += read();
858
- lexState = "decimalExponentInteger";
859
- return;
860
- }
861
- throw invalidChar(read());
862
- },
863
- decimalExponentSign() {
864
- if (util.isDigit(c)) {
865
- buffer += read();
866
- lexState = "decimalExponentInteger";
867
- return;
868
- }
869
- throw invalidChar(read());
870
- },
871
- decimalExponentInteger() {
872
- if (util.isDigit(c)) {
873
- buffer += read();
874
- return;
875
- }
876
- return newToken("numeric", sign * Number(buffer));
877
- },
878
- hexadecimal() {
879
- if (util.isHexDigit(c)) {
880
- buffer += read();
881
- lexState = "hexadecimalInteger";
882
- return;
883
- }
884
- throw invalidChar(read());
885
- },
886
- hexadecimalInteger() {
887
- if (util.isHexDigit(c)) {
888
- buffer += read();
889
- return;
890
- }
891
- return newToken("numeric", sign * Number(buffer));
892
- },
893
- string() {
894
- switch (c) {
895
- case "\\":
896
- read();
897
- buffer += escape();
898
- return;
899
- case '"':
900
- if (doubleQuote) {
901
- read();
902
- return newToken("string", buffer);
903
- }
904
- buffer += read();
905
- return;
906
- case "'":
907
- if (!doubleQuote) {
908
- read();
909
- return newToken("string", buffer);
910
- }
911
- buffer += read();
912
- return;
913
- case "\n":
914
- case "\r":
915
- throw invalidChar(read());
916
- case "\u2028":
917
- case "\u2029":
918
- separatorChar(c);
919
- break;
920
- case void 0:
921
- throw invalidChar(read());
922
- }
923
- buffer += read();
924
- },
925
- start() {
926
- switch (c) {
927
- case "{":
928
- case "[":
929
- return newToken("punctuator", read());
930
- }
931
- lexState = "value";
932
- },
933
- beforePropertyName() {
934
- switch (c) {
935
- case "$":
936
- case "_":
937
- buffer = read();
938
- lexState = "identifierName";
939
- return;
940
- case "\\":
941
- read();
942
- lexState = "identifierNameStartEscape";
943
- return;
944
- case "}":
945
- return newToken("punctuator", read());
946
- case '"':
947
- case "'":
948
- doubleQuote = read() === '"';
949
- lexState = "string";
950
- return;
951
- }
952
- if (util.isIdStartChar(c)) {
953
- buffer += read();
954
- lexState = "identifierName";
955
- return;
956
- }
957
- throw invalidChar(read());
958
- },
959
- afterPropertyName() {
960
- if (c === ":") {
961
- return newToken("punctuator", read());
962
- }
963
- throw invalidChar(read());
964
- },
965
- beforePropertyValue() {
966
- lexState = "value";
967
- },
968
- afterPropertyValue() {
969
- switch (c) {
970
- case ",":
971
- case "}":
972
- return newToken("punctuator", read());
973
- }
974
- throw invalidChar(read());
975
- },
976
- beforeArrayValue() {
977
- if (c === "]") {
978
- return newToken("punctuator", read());
979
- }
980
- lexState = "value";
981
- },
982
- afterArrayValue() {
983
- switch (c) {
984
- case ",":
985
- case "]":
986
- return newToken("punctuator", read());
987
- }
988
- throw invalidChar(read());
989
- },
990
- end() {
991
- throw invalidChar(read());
992
- }
993
- };
994
- function newToken(type, value) {
995
- return {
996
- type,
997
- value,
998
- line,
999
- column
1000
- };
168
+ // src/next/config-manager.ts
169
+ var TINA_FOLDER = "tina";
170
+ var LEGACY_TINA_FOLDER = ".tina";
171
+ var GENERATED_FOLDER = "__generated__";
172
+ var GRAPHQL_JSON_FILE = "_graphql.json";
173
+ var GRAPHQL_GQL_FILE = "schema.gql";
174
+ var SCHEMA_JSON_FILE = "_schema.json";
175
+ var LOOKUP_JSON_FILE = "_lookup.json";
176
+ var ConfigManager = class {
177
+ constructor({
178
+ rootPath = process.cwd(),
179
+ tinaGraphQLVersion,
180
+ legacyNoSDK
181
+ }) {
182
+ this.rootPath = (0, import_normalize_path.default)(rootPath);
183
+ this.tinaGraphQLVersionFromCLI = tinaGraphQLVersion;
184
+ this.legacyNoSDK = legacyNoSDK;
185
+ }
186
+ isUsingTs() {
187
+ return [".ts", ".tsx"].includes(import_path.default.extname(this.tinaConfigFilePath));
188
+ }
189
+ hasSelfHostedConfig() {
190
+ return !!this.selfHostedDatabaseFilePath;
191
+ }
192
+ hasSeparateContentRoot() {
193
+ return this.rootPath !== this.contentRootPath;
194
+ }
195
+ shouldSkipSDK() {
196
+ var _a;
197
+ if (this.legacyNoSDK) {
198
+ return this.legacyNoSDK;
1001
199
  }
1002
- function literal(s2) {
1003
- for (const c2 of s2) {
1004
- const p = peek();
1005
- if (p !== c2) {
1006
- throw invalidChar(read());
1007
- }
1008
- read();
1009
- }
200
+ return ((_a = this.config.client) == null ? void 0 : _a.skip) || false;
201
+ }
202
+ async processConfig() {
203
+ this.tinaFolderPath = await this.getTinaFolderPath(this.rootPath);
204
+ this.envFilePath = import_path.default.resolve(
205
+ import_path.default.join(this.tinaFolderPath, "..", ".env")
206
+ );
207
+ dotenv.config({ path: this.envFilePath });
208
+ this.tinaConfigFilePath = await this.getPathWithExtension(
209
+ import_path.default.join(this.tinaFolderPath, "config")
210
+ );
211
+ if (!this.tinaConfigFilePath) {
212
+ throw new Error(
213
+ `Unable to find config file in ${this.tinaFolderPath}. Looking for a file named "config.{ts,tsx,js,jsx}"`
214
+ );
1010
215
  }
1011
- function escape() {
1012
- const c2 = peek();
1013
- switch (c2) {
1014
- case "b":
1015
- read();
1016
- return "\b";
1017
- case "f":
1018
- read();
1019
- return "\f";
1020
- case "n":
1021
- read();
1022
- return "\n";
1023
- case "r":
1024
- read();
1025
- return "\r";
1026
- case "t":
1027
- read();
1028
- return " ";
1029
- case "v":
1030
- read();
1031
- return "\v";
1032
- case "0":
1033
- read();
1034
- if (util.isDigit(peek())) {
1035
- throw invalidChar(read());
1036
- }
1037
- return "\0";
1038
- case "x":
1039
- read();
1040
- return hexEscape();
1041
- case "u":
1042
- read();
1043
- return unicodeEscape();
1044
- case "\n":
1045
- case "\u2028":
1046
- case "\u2029":
1047
- read();
1048
- return "";
1049
- case "\r":
1050
- read();
1051
- if (peek() === "\n") {
1052
- read();
1053
- }
1054
- return "";
1055
- case "1":
1056
- case "2":
1057
- case "3":
1058
- case "4":
1059
- case "5":
1060
- case "6":
1061
- case "7":
1062
- case "8":
1063
- case "9":
1064
- throw invalidChar(read());
1065
- case void 0:
1066
- throw invalidChar(read());
216
+ this.selfHostedDatabaseFilePath = await this.getPathWithExtension(
217
+ import_path.default.join(this.tinaFolderPath, "database")
218
+ );
219
+ this.generatedFolderPath = import_path.default.join(this.tinaFolderPath, GENERATED_FOLDER);
220
+ this.generatedCachePath = import_path.default.join(
221
+ this.generatedFolderPath,
222
+ ".cache",
223
+ String((/* @__PURE__ */ new Date()).getTime())
224
+ );
225
+ this.generatedGraphQLGQLPath = import_path.default.join(
226
+ this.generatedFolderPath,
227
+ GRAPHQL_GQL_FILE
228
+ );
229
+ this.generatedGraphQLJSONPath = import_path.default.join(
230
+ this.generatedFolderPath,
231
+ GRAPHQL_JSON_FILE
232
+ );
233
+ this.generatedSchemaJSONPath = import_path.default.join(
234
+ this.generatedFolderPath,
235
+ SCHEMA_JSON_FILE
236
+ );
237
+ this.generatedLookupJSONPath = import_path.default.join(
238
+ this.generatedFolderPath,
239
+ LOOKUP_JSON_FILE
240
+ );
241
+ this.generatedQueriesFilePath = import_path.default.join(
242
+ this.generatedFolderPath,
243
+ "queries.gql"
244
+ );
245
+ this.generatedFragmentsFilePath = import_path.default.join(
246
+ this.generatedFolderPath,
247
+ "frags.gql"
248
+ );
249
+ this.generatedTypesTSFilePath = import_path.default.join(
250
+ this.generatedFolderPath,
251
+ "types.ts"
252
+ );
253
+ this.generatedTypesJSFilePath = import_path.default.join(
254
+ this.generatedFolderPath,
255
+ "types.js"
256
+ );
257
+ this.generatedTypesDFilePath = import_path.default.join(
258
+ this.generatedFolderPath,
259
+ "types.d.ts"
260
+ );
261
+ this.userQueriesAndFragmentsGlob = import_path.default.join(
262
+ this.tinaFolderPath,
263
+ "queries/**/*.{graphql,gql}"
264
+ );
265
+ this.generatedQueriesAndFragmentsGlob = import_path.default.join(
266
+ this.generatedFolderPath,
267
+ "*.{graphql,gql}"
268
+ );
269
+ this.generatedClientTSFilePath = import_path.default.join(
270
+ this.generatedFolderPath,
271
+ "client.ts"
272
+ );
273
+ this.generatedClientJSFilePath = import_path.default.join(
274
+ this.generatedFolderPath,
275
+ "client.js"
276
+ );
277
+ this.generatedClientDFilePath = import_path.default.join(
278
+ this.generatedFolderPath,
279
+ "client.d.ts"
280
+ );
281
+ this.generatedDatabaseClientDFilePath = import_path.default.join(
282
+ this.generatedFolderPath,
283
+ "databaseClient.d.ts"
284
+ );
285
+ this.generatedDatabaseClientTSFilePath = import_path.default.join(
286
+ this.generatedFolderPath,
287
+ "databaseClient.ts"
288
+ );
289
+ this.generatedDatabaseClientJSFilePath = import_path.default.join(
290
+ this.generatedFolderPath,
291
+ "databaseClient.js"
292
+ );
293
+ const clientExists = this.isUsingTs() ? await import_fs_extra.default.pathExists(this.generatedClientTSFilePath) : await import_fs_extra.default.pathExists(this.generatedClientJSFilePath);
294
+ if (!clientExists) {
295
+ const file = "export default ()=>({})\nexport const client = ()=>({})";
296
+ if (this.isUsingTs()) {
297
+ await import_fs_extra.default.outputFile(this.generatedClientTSFilePath, file);
298
+ } else {
299
+ await import_fs_extra.default.outputFile(this.generatedClientJSFilePath, file);
1067
300
  }
1068
- return read();
1069
301
  }
1070
- function hexEscape() {
1071
- let buffer2 = "";
1072
- let c2 = peek();
1073
- if (!util.isHexDigit(c2)) {
1074
- throw invalidChar(read());
1075
- }
1076
- buffer2 += read();
1077
- c2 = peek();
1078
- if (!util.isHexDigit(c2)) {
1079
- throw invalidChar(read());
1080
- }
1081
- buffer2 += read();
1082
- return String.fromCodePoint(parseInt(buffer2, 16));
1083
- }
1084
- function unicodeEscape() {
1085
- let buffer2 = "";
1086
- let count = 4;
1087
- while (count-- > 0) {
1088
- const c2 = peek();
1089
- if (!util.isHexDigit(c2)) {
1090
- throw invalidChar(read());
1091
- }
1092
- buffer2 += read();
302
+ const { config: config2, prebuildPath, watchList } = await this.loadConfigFile(
303
+ this.generatedFolderPath,
304
+ this.tinaConfigFilePath
305
+ );
306
+ this.watchList = watchList;
307
+ this.config = config2;
308
+ this.prebuildFilePath = prebuildPath;
309
+ this.publicFolderPath = import_path.default.join(
310
+ this.rootPath,
311
+ this.config.build.publicFolder
312
+ );
313
+ this.outputFolderPath = import_path.default.join(
314
+ this.publicFolderPath,
315
+ this.config.build.outputFolder
316
+ );
317
+ this.outputHTMLFilePath = import_path.default.join(this.outputFolderPath, "index.html");
318
+ this.outputGitignorePath = import_path.default.join(this.outputFolderPath, ".gitignore");
319
+ const fullLocalContentPath = import_path.default.join(
320
+ this.tinaFolderPath,
321
+ this.config.localContentPath || ""
322
+ );
323
+ if (this.config.localContentPath) {
324
+ const localContentPathExists = await import_fs_extra.default.pathExists(fullLocalContentPath);
325
+ if (localContentPathExists) {
326
+ logger.info(`Using separate content repo at ${fullLocalContentPath}`);
327
+ this.contentRootPath = fullLocalContentPath;
328
+ } else {
329
+ logger.warn(
330
+ `${import_chalk2.default.yellow("Warning:")} The localContentPath ${import_chalk2.default.cyan(
331
+ fullLocalContentPath
332
+ )} does not exist. Please create it or remove the localContentPath from your config file at ${import_chalk2.default.cyan(
333
+ this.tinaConfigFilePath
334
+ )}`
335
+ );
1093
336
  }
1094
- return String.fromCodePoint(parseInt(buffer2, 16));
1095
337
  }
1096
- var parseStates = {
1097
- start() {
1098
- if (token.type === "eof") {
1099
- throw invalidEOF();
1100
- }
1101
- push();
1102
- },
1103
- beforePropertyName() {
1104
- switch (token.type) {
1105
- case "identifier":
1106
- case "string":
1107
- key = token.value;
1108
- parseState = "afterPropertyName";
1109
- return;
1110
- case "punctuator":
1111
- pop();
1112
- return;
1113
- case "eof":
1114
- throw invalidEOF();
1115
- }
1116
- },
1117
- afterPropertyName() {
1118
- if (token.type === "eof") {
1119
- throw invalidEOF();
1120
- }
1121
- parseState = "beforePropertyValue";
1122
- },
1123
- beforePropertyValue() {
1124
- if (token.type === "eof") {
1125
- throw invalidEOF();
1126
- }
1127
- push();
1128
- },
1129
- beforeArrayValue() {
1130
- if (token.type === "eof") {
1131
- throw invalidEOF();
1132
- }
1133
- if (token.type === "punctuator" && token.value === "]") {
1134
- pop();
1135
- return;
1136
- }
1137
- push();
1138
- },
1139
- afterPropertyValue() {
1140
- if (token.type === "eof") {
1141
- throw invalidEOF();
1142
- }
1143
- switch (token.value) {
1144
- case ",":
1145
- parseState = "beforePropertyName";
1146
- return;
1147
- case "}":
1148
- pop();
1149
- }
1150
- },
1151
- afterArrayValue() {
1152
- if (token.type === "eof") {
1153
- throw invalidEOF();
1154
- }
1155
- switch (token.value) {
1156
- case ",":
1157
- parseState = "beforeArrayValue";
1158
- return;
1159
- case "]":
1160
- pop();
1161
- }
1162
- },
1163
- end() {
1164
- }
1165
- };
1166
- function push() {
1167
- let value;
1168
- switch (token.type) {
1169
- case "punctuator":
1170
- switch (token.value) {
1171
- case "{":
1172
- value = {};
1173
- break;
1174
- case "[":
1175
- value = [];
1176
- break;
1177
- }
1178
- break;
1179
- case "null":
1180
- case "boolean":
1181
- case "numeric":
1182
- case "string":
1183
- value = token.value;
1184
- break;
1185
- }
1186
- if (root === void 0) {
1187
- root = value;
1188
- } else {
1189
- const parent = stack[stack.length - 1];
1190
- if (Array.isArray(parent)) {
1191
- parent.push(value);
1192
- } else {
1193
- Object.defineProperty(parent, key, {
1194
- value,
1195
- writable: true,
1196
- enumerable: true,
1197
- configurable: true
1198
- });
1199
- }
1200
- }
1201
- if (value !== null && typeof value === "object") {
1202
- stack.push(value);
1203
- if (Array.isArray(value)) {
1204
- parseState = "beforeArrayValue";
1205
- } else {
1206
- parseState = "beforePropertyName";
1207
- }
1208
- } else {
1209
- const current = stack[stack.length - 1];
1210
- if (current == null) {
1211
- parseState = "end";
1212
- } else if (Array.isArray(current)) {
1213
- parseState = "afterArrayValue";
1214
- } else {
1215
- parseState = "afterPropertyValue";
1216
- }
1217
- }
1218
- }
1219
- function pop() {
1220
- stack.pop();
1221
- const current = stack[stack.length - 1];
1222
- if (current == null) {
1223
- parseState = "end";
1224
- } else if (Array.isArray(current)) {
1225
- parseState = "afterArrayValue";
1226
- } else {
1227
- parseState = "afterPropertyValue";
1228
- }
338
+ if (!this.contentRootPath) {
339
+ this.contentRootPath = this.rootPath;
1229
340
  }
1230
- function invalidChar(c2) {
1231
- if (c2 === void 0) {
1232
- return syntaxError(`JSON5: invalid end of input at ${line}:${column}`);
1233
- }
1234
- return syntaxError(`JSON5: invalid character '${formatChar(c2)}' at ${line}:${column}`);
1235
- }
1236
- function invalidEOF() {
1237
- return syntaxError(`JSON5: invalid end of input at ${line}:${column}`);
1238
- }
1239
- function invalidIdentifier() {
1240
- column -= 5;
1241
- return syntaxError(`JSON5: invalid identifier character at ${line}:${column}`);
1242
- }
1243
- function separatorChar(c2) {
1244
- console.warn(`JSON5: '${formatChar(c2)}' in strings is not valid ECMAScript; consider escaping`);
1245
- }
1246
- function formatChar(c2) {
1247
- const replacements = {
1248
- "'": "\\'",
1249
- '"': '\\"',
1250
- "\\": "\\\\",
1251
- "\b": "\\b",
1252
- "\f": "\\f",
1253
- "\n": "\\n",
1254
- "\r": "\\r",
1255
- " ": "\\t",
1256
- "\v": "\\v",
1257
- "\0": "\\0",
1258
- "\u2028": "\\u2028",
1259
- "\u2029": "\\u2029"
1260
- };
1261
- if (replacements[c2]) {
1262
- return replacements[c2];
1263
- }
1264
- if (c2 < " ") {
1265
- const hexString = c2.charCodeAt(0).toString(16);
1266
- return "\\x" + ("00" + hexString).substring(hexString.length);
1267
- }
1268
- return c2;
341
+ this.generatedFolderPathContentRepo = import_path.default.join(
342
+ await this.getTinaFolderPath(this.contentRootPath),
343
+ GENERATED_FOLDER
344
+ );
345
+ this.spaMainPath = require.resolve("@tinacms/app");
346
+ this.spaRootPath = import_path.default.join(this.spaMainPath, "..", "..");
347
+ }
348
+ async getTinaFolderPath(rootPath) {
349
+ const tinaFolderPath = import_path.default.join(rootPath, TINA_FOLDER);
350
+ const tinaFolderExists = await import_fs_extra.default.pathExists(tinaFolderPath);
351
+ if (tinaFolderExists) {
352
+ this.isUsingLegacyFolder = false;
353
+ return tinaFolderPath;
1269
354
  }
1270
- function syntaxError(message) {
1271
- const err = new SyntaxError(message);
1272
- err.lineNumber = line;
1273
- err.columnNumber = column;
1274
- return err;
355
+ const legacyFolderPath = import_path.default.join(rootPath, LEGACY_TINA_FOLDER);
356
+ const legacyFolderExists = await import_fs_extra.default.pathExists(legacyFolderPath);
357
+ if (legacyFolderExists) {
358
+ this.isUsingLegacyFolder = true;
359
+ return legacyFolderPath;
1275
360
  }
361
+ throw new Error(
362
+ `Unable to find Tina folder, if you're working in folder outside of the Tina config be sure to specify --rootPath`
363
+ );
1276
364
  }
1277
- });
1278
-
1279
- // ../../../node_modules/.pnpm/json5@2.2.3/node_modules/json5/lib/stringify.js
1280
- var require_stringify = __commonJS({
1281
- "../../../node_modules/.pnpm/json5@2.2.3/node_modules/json5/lib/stringify.js"(exports, module2) {
1282
- var util = require_util();
1283
- module2.exports = function stringify(value, replacer, space) {
1284
- const stack = [];
1285
- let indent = "";
1286
- let propertyList;
1287
- let replacerFunc;
1288
- let gap = "";
1289
- let quote;
1290
- if (replacer != null && typeof replacer === "object" && !Array.isArray(replacer)) {
1291
- space = replacer.space;
1292
- quote = replacer.quote;
1293
- replacer = replacer.replacer;
1294
- }
1295
- if (typeof replacer === "function") {
1296
- replacerFunc = replacer;
1297
- } else if (Array.isArray(replacer)) {
1298
- propertyList = [];
1299
- for (const v of replacer) {
1300
- let item;
1301
- if (typeof v === "string") {
1302
- item = v;
1303
- } else if (typeof v === "number" || v instanceof String || v instanceof Number) {
1304
- item = String(v);
1305
- }
1306
- if (item !== void 0 && propertyList.indexOf(item) < 0) {
1307
- propertyList.push(item);
1308
- }
1309
- }
1310
- }
1311
- if (space instanceof Number) {
1312
- space = Number(space);
1313
- } else if (space instanceof String) {
1314
- space = String(space);
1315
- }
1316
- if (typeof space === "number") {
1317
- if (space > 0) {
1318
- space = Math.min(10, Math.floor(space));
1319
- gap = " ".substr(0, space);
1320
- }
1321
- } else if (typeof space === "string") {
1322
- gap = space.substr(0, 10);
1323
- }
1324
- return serializeProperty("", { "": value });
1325
- function serializeProperty(key, holder) {
1326
- let value2 = holder[key];
1327
- if (value2 != null) {
1328
- if (typeof value2.toJSON5 === "function") {
1329
- value2 = value2.toJSON5(key);
1330
- } else if (typeof value2.toJSON === "function") {
1331
- value2 = value2.toJSON(key);
1332
- }
1333
- }
1334
- if (replacerFunc) {
1335
- value2 = replacerFunc.call(holder, key, value2);
1336
- }
1337
- if (value2 instanceof Number) {
1338
- value2 = Number(value2);
1339
- } else if (value2 instanceof String) {
1340
- value2 = String(value2);
1341
- } else if (value2 instanceof Boolean) {
1342
- value2 = value2.valueOf();
1343
- }
1344
- switch (value2) {
1345
- case null:
1346
- return "null";
1347
- case true:
1348
- return "true";
1349
- case false:
1350
- return "false";
1351
- }
1352
- if (typeof value2 === "string") {
1353
- return quoteString(value2, false);
1354
- }
1355
- if (typeof value2 === "number") {
1356
- return String(value2);
1357
- }
1358
- if (typeof value2 === "object") {
1359
- return Array.isArray(value2) ? serializeArray(value2) : serializeObject(value2);
1360
- }
1361
- return void 0;
1362
- }
1363
- function quoteString(value2) {
1364
- const quotes = {
1365
- "'": 0.1,
1366
- '"': 0.2
1367
- };
1368
- const replacements = {
1369
- "'": "\\'",
1370
- '"': '\\"',
1371
- "\\": "\\\\",
1372
- "\b": "\\b",
1373
- "\f": "\\f",
1374
- "\n": "\\n",
1375
- "\r": "\\r",
1376
- " ": "\\t",
1377
- "\v": "\\v",
1378
- "\0": "\\0",
1379
- "\u2028": "\\u2028",
1380
- "\u2029": "\\u2029"
1381
- };
1382
- let product = "";
1383
- for (let i = 0; i < value2.length; i++) {
1384
- const c = value2[i];
1385
- switch (c) {
1386
- case "'":
1387
- case '"':
1388
- quotes[c]++;
1389
- product += c;
1390
- continue;
1391
- case "\0":
1392
- if (util.isDigit(value2[i + 1])) {
1393
- product += "\\x00";
1394
- continue;
1395
- }
1396
- }
1397
- if (replacements[c]) {
1398
- product += replacements[c];
1399
- continue;
1400
- }
1401
- if (c < " ") {
1402
- let hexString = c.charCodeAt(0).toString(16);
1403
- product += "\\x" + ("00" + hexString).substring(hexString.length);
1404
- continue;
1405
- }
1406
- product += c;
1407
- }
1408
- const quoteChar = quote || Object.keys(quotes).reduce((a, b) => quotes[a] < quotes[b] ? a : b);
1409
- product = product.replace(new RegExp(quoteChar, "g"), replacements[quoteChar]);
1410
- return quoteChar + product + quoteChar;
1411
- }
1412
- function serializeObject(value2) {
1413
- if (stack.indexOf(value2) >= 0) {
1414
- throw TypeError("Converting circular structure to JSON5");
1415
- }
1416
- stack.push(value2);
1417
- let stepback = indent;
1418
- indent = indent + gap;
1419
- let keys = propertyList || Object.keys(value2);
1420
- let partial = [];
1421
- for (const key of keys) {
1422
- const propertyString = serializeProperty(key, value2);
1423
- if (propertyString !== void 0) {
1424
- let member = serializeKey(key) + ":";
1425
- if (gap !== "") {
1426
- member += " ";
1427
- }
1428
- member += propertyString;
1429
- partial.push(member);
1430
- }
1431
- }
1432
- let final;
1433
- if (partial.length === 0) {
1434
- final = "{}";
1435
- } else {
1436
- let properties;
1437
- if (gap === "") {
1438
- properties = partial.join(",");
1439
- final = "{" + properties + "}";
1440
- } else {
1441
- let separator = ",\n" + indent;
1442
- properties = partial.join(separator);
1443
- final = "{\n" + indent + properties + ",\n" + stepback + "}";
1444
- }
1445
- }
1446
- stack.pop();
1447
- indent = stepback;
1448
- return final;
1449
- }
1450
- function serializeKey(key) {
1451
- if (key.length === 0) {
1452
- return quoteString(key, true);
1453
- }
1454
- const firstChar = String.fromCodePoint(key.codePointAt(0));
1455
- if (!util.isIdStartChar(firstChar)) {
1456
- return quoteString(key, true);
1457
- }
1458
- for (let i = firstChar.length; i < key.length; i++) {
1459
- if (!util.isIdContinueChar(String.fromCodePoint(key.codePointAt(i)))) {
1460
- return quoteString(key, true);
1461
- }
1462
- }
1463
- return key;
1464
- }
1465
- function serializeArray(value2) {
1466
- if (stack.indexOf(value2) >= 0) {
1467
- throw TypeError("Converting circular structure to JSON5");
1468
- }
1469
- stack.push(value2);
1470
- let stepback = indent;
1471
- indent = indent + gap;
1472
- let partial = [];
1473
- for (let i = 0; i < value2.length; i++) {
1474
- const propertyString = serializeProperty(String(i), value2);
1475
- partial.push(propertyString !== void 0 ? propertyString : "null");
1476
- }
1477
- let final;
1478
- if (partial.length === 0) {
1479
- final = "[]";
1480
- } else {
1481
- if (gap === "") {
1482
- let properties = partial.join(",");
1483
- final = "[" + properties + "]";
1484
- } else {
1485
- let separator = ",\n" + indent;
1486
- let properties = partial.join(separator);
1487
- final = "[\n" + indent + properties + ",\n" + stepback + "]";
1488
- }
1489
- }
1490
- stack.pop();
1491
- indent = stepback;
1492
- return final;
1493
- }
1494
- };
1495
- }
1496
- });
1497
-
1498
- // ../../../node_modules/.pnpm/json5@2.2.3/node_modules/json5/lib/index.js
1499
- var require_lib = __commonJS({
1500
- "../../../node_modules/.pnpm/json5@2.2.3/node_modules/json5/lib/index.js"(exports, module2) {
1501
- var parse2 = require_parse();
1502
- var stringify = require_stringify();
1503
- var JSON5 = {
1504
- parse: parse2,
1505
- stringify
1506
- };
1507
- module2.exports = JSON5;
1508
- }
1509
- });
1510
-
1511
- // ../../../node_modules/.pnpm/strip-bom@3.0.0/node_modules/strip-bom/index.js
1512
- var require_strip_bom = __commonJS({
1513
- "../../../node_modules/.pnpm/strip-bom@3.0.0/node_modules/strip-bom/index.js"(exports, module2) {
1514
- "use strict";
1515
- module2.exports = (x) => {
1516
- if (typeof x !== "string") {
1517
- throw new TypeError("Expected a string, got " + typeof x);
1518
- }
1519
- if (x.charCodeAt(0) === 65279) {
1520
- return x.slice(1);
1521
- }
1522
- return x;
1523
- };
1524
- }
1525
- });
1526
-
1527
- // ../../../node_modules/.pnpm/tsconfig-paths@4.2.0/node_modules/tsconfig-paths/lib/tsconfig-loader.js
1528
- var require_tsconfig_loader = __commonJS({
1529
- "../../../node_modules/.pnpm/tsconfig-paths@4.2.0/node_modules/tsconfig-paths/lib/tsconfig-loader.js"(exports) {
1530
- "use strict";
1531
- var __assign = exports && exports.__assign || function() {
1532
- __assign = Object.assign || function(t) {
1533
- for (var s2, i = 1, n = arguments.length; i < n; i++) {
1534
- s2 = arguments[i];
1535
- for (var p in s2)
1536
- if (Object.prototype.hasOwnProperty.call(s2, p))
1537
- t[p] = s2[p];
1538
- }
1539
- return t;
1540
- };
1541
- return __assign.apply(this, arguments);
1542
- };
1543
- Object.defineProperty(exports, "__esModule", { value: true });
1544
- exports.loadTsconfig = exports.walkForTsConfig = exports.tsConfigLoader = void 0;
1545
- var path15 = require("path");
1546
- var fs15 = require("fs");
1547
- var JSON5 = require_lib();
1548
- var StripBom = require_strip_bom();
1549
- function tsConfigLoader(_a) {
1550
- var getEnv = _a.getEnv, cwd = _a.cwd, _b = _a.loadSync, loadSync = _b === void 0 ? loadSyncDefault : _b;
1551
- var TS_NODE_PROJECT = getEnv("TS_NODE_PROJECT");
1552
- var TS_NODE_BASEURL = getEnv("TS_NODE_BASEURL");
1553
- var loadResult = loadSync(cwd, TS_NODE_PROJECT, TS_NODE_BASEURL);
1554
- return loadResult;
1555
- }
1556
- exports.tsConfigLoader = tsConfigLoader;
1557
- function loadSyncDefault(cwd, filename, baseUrl) {
1558
- var configPath = resolveConfigPath(cwd, filename);
1559
- if (!configPath) {
1560
- return {
1561
- tsConfigPath: void 0,
1562
- baseUrl: void 0,
1563
- paths: void 0
1564
- };
1565
- }
1566
- var config2 = loadTsconfig(configPath);
365
+ getTinaGraphQLVersion() {
366
+ if (this.tinaGraphQLVersionFromCLI) {
367
+ const version2 = this.tinaGraphQLVersionFromCLI.split(".");
1567
368
  return {
1568
- tsConfigPath: configPath,
1569
- baseUrl: baseUrl || config2 && config2.compilerOptions && config2.compilerOptions.baseUrl,
1570
- paths: config2 && config2.compilerOptions && config2.compilerOptions.paths
369
+ fullVersion: this.tinaGraphQLVersionFromCLI,
370
+ major: version2[0] || "x",
371
+ minor: version2[1] || "x",
372
+ patch: version2[2] || "x"
1571
373
  };
1572
374
  }
1573
- function resolveConfigPath(cwd, filename) {
1574
- if (filename) {
1575
- var absolutePath = fs15.lstatSync(filename).isDirectory() ? path15.resolve(filename, "./tsconfig.json") : path15.resolve(cwd, filename);
1576
- return absolutePath;
1577
- }
1578
- if (fs15.statSync(cwd).isFile()) {
1579
- return path15.resolve(cwd);
1580
- }
1581
- var configAbsolutePath = walkForTsConfig(cwd);
1582
- return configAbsolutePath ? path15.resolve(configAbsolutePath) : void 0;
1583
- }
1584
- function walkForTsConfig(directory, readdirSync) {
1585
- if (readdirSync === void 0) {
1586
- readdirSync = fs15.readdirSync;
1587
- }
1588
- var files = readdirSync(directory);
1589
- var filesToCheck = ["tsconfig.json", "jsconfig.json"];
1590
- for (var _i = 0, filesToCheck_1 = filesToCheck; _i < filesToCheck_1.length; _i++) {
1591
- var fileToCheck = filesToCheck_1[_i];
1592
- if (files.indexOf(fileToCheck) !== -1) {
1593
- return path15.join(directory, fileToCheck);
1594
- }
1595
- }
1596
- var parentDirectory = path15.dirname(directory);
1597
- if (directory === parentDirectory) {
1598
- return void 0;
1599
- }
1600
- return walkForTsConfig(parentDirectory, readdirSync);
1601
- }
1602
- exports.walkForTsConfig = walkForTsConfig;
1603
- function loadTsconfig(configFilePath, existsSync, readFileSync) {
1604
- if (existsSync === void 0) {
1605
- existsSync = fs15.existsSync;
1606
- }
1607
- if (readFileSync === void 0) {
1608
- readFileSync = function(filename) {
1609
- return fs15.readFileSync(filename, "utf8");
1610
- };
1611
- }
1612
- if (!existsSync(configFilePath)) {
1613
- return void 0;
1614
- }
1615
- var configString = readFileSync(configFilePath);
1616
- var cleanedJson = StripBom(configString);
1617
- var config2;
1618
- try {
1619
- config2 = JSON5.parse(cleanedJson);
1620
- } catch (e) {
1621
- throw new Error("".concat(configFilePath, " is malformed ").concat(e.message));
1622
- }
1623
- var extendedConfig = config2.extends;
1624
- if (extendedConfig) {
1625
- var base = void 0;
1626
- if (Array.isArray(extendedConfig)) {
1627
- base = extendedConfig.reduce(function(currBase, extendedConfigElement) {
1628
- return mergeTsconfigs(currBase, loadTsconfigFromExtends(configFilePath, extendedConfigElement, existsSync, readFileSync));
1629
- }, {});
1630
- } else {
1631
- base = loadTsconfigFromExtends(configFilePath, extendedConfig, existsSync, readFileSync);
1632
- }
1633
- return mergeTsconfigs(base, config2);
1634
- }
1635
- return config2;
1636
- }
1637
- exports.loadTsconfig = loadTsconfig;
1638
- function loadTsconfigFromExtends(configFilePath, extendedConfigValue, existsSync, readFileSync) {
1639
- var _a;
1640
- if (typeof extendedConfigValue === "string" && extendedConfigValue.indexOf(".json") === -1) {
1641
- extendedConfigValue += ".json";
1642
- }
1643
- var currentDir = path15.dirname(configFilePath);
1644
- var extendedConfigPath = path15.join(currentDir, extendedConfigValue);
1645
- if (extendedConfigValue.indexOf("/") !== -1 && extendedConfigValue.indexOf(".") !== -1 && !existsSync(extendedConfigPath)) {
1646
- extendedConfigPath = path15.join(currentDir, "node_modules", extendedConfigValue);
1647
- }
1648
- var config2 = loadTsconfig(extendedConfigPath, existsSync, readFileSync) || {};
1649
- if ((_a = config2.compilerOptions) === null || _a === void 0 ? void 0 : _a.baseUrl) {
1650
- var extendsDir = path15.dirname(extendedConfigValue);
1651
- config2.compilerOptions.baseUrl = path15.join(extendsDir, config2.compilerOptions.baseUrl);
1652
- }
1653
- return config2;
1654
- }
1655
- function mergeTsconfigs(base, config2) {
1656
- base = base || {};
1657
- config2 = config2 || {};
1658
- return __assign(__assign(__assign({}, base), config2), { compilerOptions: __assign(__assign({}, base.compilerOptions), config2.compilerOptions) });
375
+ const generatedSchema = import_fs_extra.default.readJSONSync(this.generatedSchemaJSONPath);
376
+ if (!generatedSchema || !(typeof (generatedSchema == null ? void 0 : generatedSchema.version) !== "undefined")) {
377
+ throw new Error(
378
+ `Can not find Tina GraphQL version in ${this.generatedSchemaJSONPath}`
379
+ );
1659
380
  }
381
+ return generatedSchema.version;
1660
382
  }
1661
- });
1662
-
1663
- // ../../../node_modules/.pnpm/tsconfig-paths@4.2.0/node_modules/tsconfig-paths/lib/config-loader.js
1664
- var require_config_loader = __commonJS({
1665
- "../../../node_modules/.pnpm/tsconfig-paths@4.2.0/node_modules/tsconfig-paths/lib/config-loader.js"(exports) {
1666
- "use strict";
1667
- Object.defineProperty(exports, "__esModule", { value: true });
1668
- exports.configLoader = exports.loadConfig = void 0;
1669
- var TsConfigLoader2 = require_tsconfig_loader();
1670
- var path15 = require("path");
1671
- function loadConfig2(cwd) {
1672
- if (cwd === void 0) {
1673
- cwd = process.cwd();
1674
- }
1675
- return configLoader({ cwd });
1676
- }
1677
- exports.loadConfig = loadConfig2;
1678
- function configLoader(_a) {
1679
- var cwd = _a.cwd, explicitParams = _a.explicitParams, _b = _a.tsConfigLoader, tsConfigLoader = _b === void 0 ? TsConfigLoader2.tsConfigLoader : _b;
1680
- if (explicitParams) {
1681
- var absoluteBaseUrl = path15.isAbsolute(explicitParams.baseUrl) ? explicitParams.baseUrl : path15.join(cwd, explicitParams.baseUrl);
1682
- return {
1683
- resultType: "success",
1684
- configFileAbsolutePath: "",
1685
- baseUrl: explicitParams.baseUrl,
1686
- absoluteBaseUrl,
1687
- paths: explicitParams.paths,
1688
- mainFields: explicitParams.mainFields,
1689
- addMatchAll: explicitParams.addMatchAll
1690
- };
1691
- }
1692
- var loadResult = tsConfigLoader({
1693
- cwd,
1694
- getEnv: function(key) {
1695
- return process.env[key];
1696
- }
1697
- });
1698
- if (!loadResult.tsConfigPath) {
1699
- return {
1700
- resultType: "failed",
1701
- message: "Couldn't find tsconfig.json"
1702
- };
1703
- }
1704
- return {
1705
- resultType: "success",
1706
- configFileAbsolutePath: loadResult.tsConfigPath,
1707
- baseUrl: loadResult.baseUrl,
1708
- absoluteBaseUrl: path15.resolve(path15.dirname(loadResult.tsConfigPath), loadResult.baseUrl || ""),
1709
- paths: loadResult.paths || {},
1710
- addMatchAll: loadResult.baseUrl !== void 0
1711
- };
383
+ printGeneratedClientFilePath() {
384
+ if (this.isUsingTs()) {
385
+ return this.generatedClientTSFilePath.replace(`${this.rootPath}/`, "");
1712
386
  }
1713
- exports.configLoader = configLoader;
387
+ return this.generatedClientJSFilePath.replace(`${this.rootPath}/`, "");
1714
388
  }
1715
- });
1716
-
1717
- // ../../../node_modules/.pnpm/minimist@1.2.8/node_modules/minimist/index.js
1718
- var require_minimist = __commonJS({
1719
- "../../../node_modules/.pnpm/minimist@1.2.8/node_modules/minimist/index.js"(exports, module2) {
1720
- "use strict";
1721
- function hasKey(obj, keys) {
1722
- var o = obj;
1723
- keys.slice(0, -1).forEach(function(key2) {
1724
- o = o[key2] || {};
1725
- });
1726
- var key = keys[keys.length - 1];
1727
- return key in o;
1728
- }
1729
- function isNumber(x) {
1730
- if (typeof x === "number") {
1731
- return true;
1732
- }
1733
- if (/^0x[0-9a-f]+$/i.test(x)) {
1734
- return true;
1735
- }
1736
- return /^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(x);
389
+ printGeneratedTypesFilePath() {
390
+ return this.generatedTypesTSFilePath.replace(`${this.rootPath}/`, "");
391
+ }
392
+ printoutputHTMLFilePath() {
393
+ return this.outputHTMLFilePath.replace(`${this.publicFolderPath}/`, "");
394
+ }
395
+ printRelativePath(filename) {
396
+ if (filename) {
397
+ return filename.replace(/\\/g, "/").replace(`${this.rootPath}/`, "");
1737
398
  }
1738
- function isConstructorOrProto(obj, key) {
1739
- return key === "constructor" && typeof obj[key] === "function" || key === "__proto__";
399
+ throw `No path provided to print`;
400
+ }
401
+ printPrebuildFilePath() {
402
+ return this.prebuildFilePath.replace(/\\/g, "/").replace(`${this.rootPath}/${this.tinaFolderPath}/`, "");
403
+ }
404
+ printContentRelativePath(filename) {
405
+ if (filename) {
406
+ return filename.replace(/\\/g, "/").replace(`${this.contentRootPath}/`, "");
1740
407
  }
1741
- module2.exports = function(args, opts) {
1742
- if (!opts) {
1743
- opts = {};
1744
- }
1745
- var flags = {
1746
- bools: {},
1747
- strings: {},
1748
- unknownFn: null
1749
- };
1750
- if (typeof opts.unknown === "function") {
1751
- flags.unknownFn = opts.unknown;
1752
- }
1753
- if (typeof opts.boolean === "boolean" && opts.boolean) {
1754
- flags.allBools = true;
1755
- } else {
1756
- [].concat(opts.boolean).filter(Boolean).forEach(function(key2) {
1757
- flags.bools[key2] = true;
1758
- });
1759
- }
1760
- var aliases = {};
1761
- function aliasIsBoolean(key2) {
1762
- return aliases[key2].some(function(x) {
1763
- return flags.bools[x];
1764
- });
1765
- }
1766
- Object.keys(opts.alias || {}).forEach(function(key2) {
1767
- aliases[key2] = [].concat(opts.alias[key2]);
1768
- aliases[key2].forEach(function(x) {
1769
- aliases[x] = [key2].concat(aliases[key2].filter(function(y) {
1770
- return x !== y;
1771
- }));
1772
- });
1773
- });
1774
- [].concat(opts.string).filter(Boolean).forEach(function(key2) {
1775
- flags.strings[key2] = true;
1776
- if (aliases[key2]) {
1777
- [].concat(aliases[key2]).forEach(function(k) {
1778
- flags.strings[k] = true;
1779
- });
1780
- }
1781
- });
1782
- var defaults = opts.default || {};
1783
- var argv = { _: [] };
1784
- function argDefined(key2, arg2) {
1785
- return flags.allBools && /^--[^=]+$/.test(arg2) || flags.strings[key2] || flags.bools[key2] || aliases[key2];
1786
- }
1787
- function setKey(obj, keys, value2) {
1788
- var o = obj;
1789
- for (var i2 = 0; i2 < keys.length - 1; i2++) {
1790
- var key2 = keys[i2];
1791
- if (isConstructorOrProto(o, key2)) {
1792
- return;
1793
- }
1794
- if (o[key2] === void 0) {
1795
- o[key2] = {};
1796
- }
1797
- if (o[key2] === Object.prototype || o[key2] === Number.prototype || o[key2] === String.prototype) {
1798
- o[key2] = {};
1799
- }
1800
- if (o[key2] === Array.prototype) {
1801
- o[key2] = [];
1802
- }
1803
- o = o[key2];
1804
- }
1805
- var lastKey = keys[keys.length - 1];
1806
- if (isConstructorOrProto(o, lastKey)) {
408
+ throw `No path provided to print`;
409
+ }
410
+ /**
411
+ * Given a filepath without an extension, find the first match (eg. tsx, ts, jsx, js)
412
+ */
413
+ async getPathWithExtension(filepath) {
414
+ const extensions = ["tsx", "ts", "jsx", "js"];
415
+ let result;
416
+ await Promise.all(
417
+ extensions.map(async (ext) => {
418
+ if (result) {
1807
419
  return;
1808
420
  }
1809
- if (o === Object.prototype || o === Number.prototype || o === String.prototype) {
1810
- o = {};
1811
- }
1812
- if (o === Array.prototype) {
1813
- o = [];
1814
- }
1815
- if (o[lastKey] === void 0 || flags.bools[lastKey] || typeof o[lastKey] === "boolean") {
1816
- o[lastKey] = value2;
1817
- } else if (Array.isArray(o[lastKey])) {
1818
- o[lastKey].push(value2);
1819
- } else {
1820
- o[lastKey] = [o[lastKey], value2];
1821
- }
1822
- }
1823
- function setArg(key2, val, arg2) {
1824
- if (arg2 && flags.unknownFn && !argDefined(key2, arg2)) {
1825
- if (flags.unknownFn(arg2) === false) {
1826
- return;
1827
- }
1828
- }
1829
- var value2 = !flags.strings[key2] && isNumber(val) ? Number(val) : val;
1830
- setKey(argv, key2.split("."), value2);
1831
- (aliases[key2] || []).forEach(function(x) {
1832
- setKey(argv, x.split("."), value2);
1833
- });
1834
- }
1835
- Object.keys(flags.bools).forEach(function(key2) {
1836
- setArg(key2, defaults[key2] === void 0 ? false : defaults[key2]);
1837
- });
1838
- var notFlags = [];
1839
- if (args.indexOf("--") !== -1) {
1840
- notFlags = args.slice(args.indexOf("--") + 1);
1841
- args = args.slice(0, args.indexOf("--"));
1842
- }
1843
- for (var i = 0; i < args.length; i++) {
1844
- var arg = args[i];
1845
- var key;
1846
- var next;
1847
- if (/^--.+=/.test(arg)) {
1848
- var m = arg.match(/^--([^=]+)=([\s\S]*)$/);
1849
- key = m[1];
1850
- var value = m[2];
1851
- if (flags.bools[key]) {
1852
- value = value !== "false";
1853
- }
1854
- setArg(key, value, arg);
1855
- } else if (/^--no-.+/.test(arg)) {
1856
- key = arg.match(/^--no-(.+)/)[1];
1857
- setArg(key, false, arg);
1858
- } else if (/^--.+/.test(arg)) {
1859
- key = arg.match(/^--(.+)/)[1];
1860
- next = args[i + 1];
1861
- if (next !== void 0 && !/^(-|--)[^-]/.test(next) && !flags.bools[key] && !flags.allBools && (aliases[key] ? !aliasIsBoolean(key) : true)) {
1862
- setArg(key, next, arg);
1863
- i += 1;
1864
- } else if (/^(true|false)$/.test(next)) {
1865
- setArg(key, next === "true", arg);
1866
- i += 1;
1867
- } else {
1868
- setArg(key, flags.strings[key] ? "" : true, arg);
1869
- }
1870
- } else if (/^-[^-]+/.test(arg)) {
1871
- var letters = arg.slice(1, -1).split("");
1872
- var broken = false;
1873
- for (var j = 0; j < letters.length; j++) {
1874
- next = arg.slice(j + 2);
1875
- if (next === "-") {
1876
- setArg(letters[j], next, arg);
1877
- continue;
1878
- }
1879
- if (/[A-Za-z]/.test(letters[j]) && next[0] === "=") {
1880
- setArg(letters[j], next.slice(1), arg);
1881
- broken = true;
1882
- break;
1883
- }
1884
- if (/[A-Za-z]/.test(letters[j]) && /-?\d+(\.\d*)?(e-?\d+)?$/.test(next)) {
1885
- setArg(letters[j], next, arg);
1886
- broken = true;
1887
- break;
1888
- }
1889
- if (letters[j + 1] && letters[j + 1].match(/\W/)) {
1890
- setArg(letters[j], arg.slice(j + 2), arg);
1891
- broken = true;
1892
- break;
1893
- } else {
1894
- setArg(letters[j], flags.strings[letters[j]] ? "" : true, arg);
1895
- }
1896
- }
1897
- key = arg.slice(-1)[0];
1898
- if (!broken && key !== "-") {
1899
- if (args[i + 1] && !/^(-|--)[^-]/.test(args[i + 1]) && !flags.bools[key] && (aliases[key] ? !aliasIsBoolean(key) : true)) {
1900
- setArg(key, args[i + 1], arg);
1901
- i += 1;
1902
- } else if (args[i + 1] && /^(true|false)$/.test(args[i + 1])) {
1903
- setArg(key, args[i + 1] === "true", arg);
1904
- i += 1;
1905
- } else {
1906
- setArg(key, flags.strings[key] ? "" : true, arg);
1907
- }
1908
- }
1909
- } else {
1910
- if (!flags.unknownFn || flags.unknownFn(arg) !== false) {
1911
- argv._.push(flags.strings._ || !isNumber(arg) ? arg : Number(arg));
1912
- }
1913
- if (opts.stopEarly) {
1914
- argv._.push.apply(argv._, args.slice(i + 1));
1915
- break;
1916
- }
1917
- }
1918
- }
1919
- Object.keys(defaults).forEach(function(k) {
1920
- if (!hasKey(argv, k.split("."))) {
1921
- setKey(argv, k.split("."), defaults[k]);
1922
- (aliases[k] || []).forEach(function(x) {
1923
- setKey(argv, x.split("."), defaults[k]);
1924
- });
421
+ const filepathWithExtension = `${filepath}.${ext}`;
422
+ const exists = import_fs_extra.default.existsSync(filepathWithExtension);
423
+ if (exists) {
424
+ result = filepathWithExtension;
1925
425
  }
1926
- });
1927
- if (opts["--"]) {
1928
- argv["--"] = notFlags.slice();
1929
- } else {
1930
- notFlags.forEach(function(k) {
1931
- argv._.push(k);
1932
- });
1933
- }
1934
- return argv;
1935
- };
426
+ })
427
+ );
428
+ return result;
1936
429
  }
1937
- });
1938
-
1939
- // ../../../node_modules/.pnpm/tsconfig-paths@4.2.0/node_modules/tsconfig-paths/lib/register.js
1940
- var require_register = __commonJS({
1941
- "../../../node_modules/.pnpm/tsconfig-paths@4.2.0/node_modules/tsconfig-paths/lib/register.js"(exports) {
1942
- "use strict";
1943
- var __spreadArray = exports && exports.__spreadArray || function(to, from, pack) {
1944
- if (pack || arguments.length === 2)
1945
- for (var i = 0, l = from.length, ar; i < l; i++) {
1946
- if (ar || !(i in from)) {
1947
- if (!ar)
1948
- ar = Array.prototype.slice.call(from, 0, i);
1949
- ar[i] = from[i];
1950
- }
1951
- }
1952
- return to.concat(ar || Array.prototype.slice.call(from));
1953
- };
1954
- Object.defineProperty(exports, "__esModule", { value: true });
1955
- exports.register = void 0;
1956
- var match_path_sync_1 = require_match_path_sync();
1957
- var config_loader_1 = require_config_loader();
1958
- var noOp = function() {
1959
- return void 0;
1960
- };
1961
- function getCoreModules(builtinModules) {
1962
- builtinModules = builtinModules || [
1963
- "assert",
1964
- "buffer",
1965
- "child_process",
1966
- "cluster",
1967
- "crypto",
1968
- "dgram",
1969
- "dns",
1970
- "domain",
1971
- "events",
1972
- "fs",
1973
- "http",
1974
- "https",
1975
- "net",
1976
- "os",
1977
- "path",
1978
- "punycode",
1979
- "querystring",
1980
- "readline",
1981
- "stream",
1982
- "string_decoder",
1983
- "tls",
1984
- "tty",
1985
- "url",
1986
- "util",
1987
- "v8",
1988
- "vm",
1989
- "zlib"
1990
- ];
1991
- var coreModules = {};
1992
- for (var _i = 0, builtinModules_1 = builtinModules; _i < builtinModules_1.length; _i++) {
1993
- var module_1 = builtinModules_1[_i];
1994
- coreModules[module_1] = true;
1995
- }
1996
- return coreModules;
1997
- }
1998
- function register(params) {
1999
- var cwd;
2000
- var explicitParams;
2001
- if (params) {
2002
- cwd = params.cwd;
2003
- if (params.baseUrl || params.paths) {
2004
- explicitParams = params;
2005
- }
2006
- } else {
2007
- var minimist = require_minimist();
2008
- var argv = minimist(process.argv.slice(2), {
2009
- string: ["project"],
2010
- alias: {
2011
- project: ["P"]
2012
- }
2013
- });
2014
- cwd = argv.project;
2015
- }
2016
- var configLoaderResult = (0, config_loader_1.configLoader)({
2017
- cwd: cwd !== null && cwd !== void 0 ? cwd : process.cwd(),
2018
- explicitParams
2019
- });
2020
- if (configLoaderResult.resultType === "failed") {
2021
- console.warn("".concat(configLoaderResult.message, ". tsconfig-paths will be skipped"));
2022
- return noOp;
430
+ async loadDatabaseFile() {
431
+ const tmpdir = import_path.default.join(import_os.default.tmpdir(), Date.now().toString());
432
+ const outfile = import_path.default.join(tmpdir, "database.build.js");
433
+ await esbuild.build({
434
+ entryPoints: [this.selfHostedDatabaseFilePath],
435
+ bundle: true,
436
+ platform: "node",
437
+ outfile,
438
+ loader: loaders
439
+ });
440
+ const result = require(outfile);
441
+ import_fs_extra.default.removeSync(outfile);
442
+ return result.default;
443
+ }
444
+ async loadConfigFile(generatedFolderPath, configFilePath) {
445
+ const tmpdir = import_path.default.join(import_os.default.tmpdir(), Date.now().toString());
446
+ const preBuildConfigPath = import_path.default.join(
447
+ this.generatedFolderPath,
448
+ "config.prebuild.jsx"
449
+ );
450
+ const outfile = import_path.default.join(tmpdir, "config.build.jsx");
451
+ const outfile2 = import_path.default.join(tmpdir, "config.build.js");
452
+ const tempTSConfigFile = import_path.default.join(tmpdir, "tsconfig.json");
453
+ import_fs_extra.default.outputFileSync(tempTSConfigFile, "{}");
454
+ const result2 = await esbuild.build({
455
+ entryPoints: [configFilePath],
456
+ bundle: true,
457
+ target: ["es2020"],
458
+ platform: "browser",
459
+ format: "esm",
460
+ logLevel: "silent",
461
+ packages: "external",
462
+ ignoreAnnotations: true,
463
+ outfile: preBuildConfigPath,
464
+ loader: loaders,
465
+ metafile: true
466
+ });
467
+ const flattenedList = [];
468
+ Object.keys(result2.metafile.inputs).forEach((key) => {
469
+ if (key.includes("node_modules") || key.includes("__generated__")) {
470
+ return;
2023
471
  }
2024
- var matchPath = (0, match_path_sync_1.createMatchPath)(configLoaderResult.absoluteBaseUrl, configLoaderResult.paths, configLoaderResult.mainFields, configLoaderResult.addMatchAll);
2025
- var Module = require("module");
2026
- var originalResolveFilename = Module._resolveFilename;
2027
- var coreModules = getCoreModules(Module.builtinModules);
2028
- Module._resolveFilename = function(request2, _parent) {
2029
- var isCoreModule = coreModules.hasOwnProperty(request2);
2030
- if (!isCoreModule) {
2031
- var found = matchPath(request2);
2032
- if (found) {
2033
- var modifiedArguments = __spreadArray([found], [].slice.call(arguments, 1), true);
2034
- return originalResolveFilename.apply(this, modifiedArguments);
2035
- }
2036
- }
2037
- return originalResolveFilename.apply(this, arguments);
2038
- };
2039
- return function() {
2040
- Module._resolveFilename = originalResolveFilename;
2041
- };
472
+ flattenedList.push(key);
473
+ });
474
+ await esbuild.build({
475
+ entryPoints: [configFilePath],
476
+ bundle: true,
477
+ target: ["es2020"],
478
+ logLevel: "silent",
479
+ platform: "node",
480
+ outfile,
481
+ loader: loaders
482
+ });
483
+ await esbuild.build({
484
+ entryPoints: [outfile],
485
+ bundle: true,
486
+ // Suppress warning about comparison with -0 from client module
487
+ logLevel: "silent",
488
+ platform: "node",
489
+ outfile: outfile2,
490
+ loader: loaders
491
+ });
492
+ let result;
493
+ try {
494
+ result = require(outfile2);
495
+ } catch (e) {
496
+ console.error("Unexpected error loading config");
497
+ console.error(e);
498
+ throw e;
2042
499
  }
2043
- exports.register = register;
2044
- }
2045
- });
2046
-
2047
- // ../../../node_modules/.pnpm/tsconfig-paths@4.2.0/node_modules/tsconfig-paths/lib/index.js
2048
- var require_lib2 = __commonJS({
2049
- "../../../node_modules/.pnpm/tsconfig-paths@4.2.0/node_modules/tsconfig-paths/lib/index.js"(exports) {
2050
- "use strict";
2051
- Object.defineProperty(exports, "__esModule", { value: true });
2052
- exports.loadConfig = exports.register = exports.matchFromAbsolutePathsAsync = exports.createMatchPathAsync = exports.matchFromAbsolutePaths = exports.createMatchPath = void 0;
2053
- var match_path_sync_1 = require_match_path_sync();
2054
- Object.defineProperty(exports, "createMatchPath", { enumerable: true, get: function() {
2055
- return match_path_sync_1.createMatchPath;
2056
- } });
2057
- Object.defineProperty(exports, "matchFromAbsolutePaths", { enumerable: true, get: function() {
2058
- return match_path_sync_1.matchFromAbsolutePaths;
2059
- } });
2060
- var match_path_async_1 = require_match_path_async();
2061
- Object.defineProperty(exports, "createMatchPathAsync", { enumerable: true, get: function() {
2062
- return match_path_async_1.createMatchPathAsync;
2063
- } });
2064
- Object.defineProperty(exports, "matchFromAbsolutePathsAsync", { enumerable: true, get: function() {
2065
- return match_path_async_1.matchFromAbsolutePathsAsync;
2066
- } });
2067
- var register_1 = require_register();
2068
- Object.defineProperty(exports, "register", { enumerable: true, get: function() {
2069
- return register_1.register;
2070
- } });
2071
- var config_loader_1 = require_config_loader();
2072
- Object.defineProperty(exports, "loadConfig", { enumerable: true, get: function() {
2073
- return config_loader_1.loadConfig;
2074
- } });
500
+ import_fs_extra.default.removeSync(outfile);
501
+ import_fs_extra.default.removeSync(outfile2);
502
+ return {
503
+ config: result.default,
504
+ prebuildPath: preBuildConfigPath,
505
+ watchList: flattenedList
506
+ };
2075
507
  }
2076
- });
508
+ };
509
+ var loaders = {
510
+ ".aac": "file",
511
+ ".css": "file",
512
+ ".eot": "file",
513
+ ".flac": "file",
514
+ ".gif": "file",
515
+ ".jpeg": "file",
516
+ ".jpg": "file",
517
+ ".json": "json",
518
+ ".mp3": "file",
519
+ ".mp4": "file",
520
+ ".ogg": "file",
521
+ ".otf": "file",
522
+ ".png": "file",
523
+ ".svg": "file",
524
+ ".ttf": "file",
525
+ ".wav": "file",
526
+ ".webm": "file",
527
+ ".webp": "file",
528
+ ".woff": "file",
529
+ ".woff2": "file",
530
+ ".js": "jsx",
531
+ ".jsx": "jsx",
532
+ ".tsx": "tsx"
533
+ };
2077
534
 
2078
- // src/index.ts
2079
- var src_exports = {};
2080
- __export(src_exports, {
2081
- default: () => src_default
2082
- });
2083
- module.exports = __toCommonJS(src_exports);
2084
- var import_clipanion8 = require("clipanion");
535
+ // src/next/commands/dev-command/html.ts
536
+ var errorHTML = `<style type="text/css">
537
+ #no-assets-placeholder body {
538
+ font-family: sans-serif;
539
+ font-size: 16px;
540
+ line-height: 1.4;
541
+ color: #333;
542
+ background-color: #f5f5f5;
543
+ }
544
+ #no-assets-placeholder {
545
+ max-width: 600px;
546
+ margin: 0 auto;
547
+ padding: 40px;
548
+ text-align: center;
549
+ background-color: #fff;
550
+ box-shadow: 0px 0px 20px rgba(0, 0, 0, 0.1);
551
+ }
552
+ #no-assets-placeholder h1 {
553
+ font-size: 24px;
554
+ margin-bottom: 20px;
555
+ }
556
+ #no-assets-placeholder p {
557
+ margin-bottom: 10px;
558
+ }
559
+ #no-assets-placeholder a {
560
+ color: #0077cc;
561
+ text-decoration: none;
562
+ }
563
+ #no-assets-placeholder a:hover {
564
+ text-decoration: underline;
565
+ }
566
+ </style>
567
+ <div id="no-assets-placeholder">
568
+ <h1>Failed loading TinaCMS assets</h1>
569
+ <p>
570
+ Your TinaCMS configuration may be misconfigured, and we could not load
571
+ the assets for this page.
572
+ </p>
573
+ <p>
574
+ Please visit <a href="https://tina.io/docs/tina-cloud/faq/#how-do-i-resolve-failed-loading-tinacms-assets-error">this doc</a> for help.
575
+ </p>
576
+ </div>
577
+ </div>`.trim().replace(/[\r\n\s]+/g, " ");
578
+ var devHTML = (port) => `<!DOCTYPE html>
579
+ <html lang="en">
580
+ <head>
581
+ <meta charset="UTF-8" />
582
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
583
+ <title>TinaCMS</title>
584
+ </head>
2085
585
 
2086
- // package.json
2087
- var version = "1.7.0";
586
+ <!-- if development -->
587
+ <script type="module">
588
+ import RefreshRuntime from 'http://localhost:${port}/@react-refresh'
589
+ RefreshRuntime.injectIntoGlobalHook(window)
590
+ window.$RefreshReg$ = () => {}
591
+ window.$RefreshSig$ = () => (type) => type
592
+ window.__vite_plugin_react_preamble_installed__ = true
593
+ </script>
594
+ <script type="module" src="http://localhost:${port}/@vite/client"></script>
595
+ <script>
596
+ function handleLoadError() {
597
+ // Assets have failed to load
598
+ document.getElementById('root').innerHTML = '${errorHTML}';
599
+ }
600
+ </script>
601
+ <script
602
+ type="module"
603
+ src="http://localhost:${port}/src/main.tsx"
604
+ onerror="handleLoadError()"
605
+ ></script>
606
+ <body class="tina-tailwind">
607
+ <div id="root"></div>
608
+ </body>
609
+ </html>`;
2088
610
 
2089
- // src/next/commands/dev-command/index.ts
2090
- var import_clipanion2 = require("clipanion");
2091
- var import_fs_extra6 = __toESM(require("fs-extra"));
2092
- var import_path6 = __toESM(require("path"));
2093
- var import_chokidar = __toESM(require("chokidar"));
2094
- var import_graphql10 = require("@tinacms/graphql");
611
+ // src/utils/theme.ts
612
+ var import_chalk3 = __toESM(require("chalk"));
613
+ var successText = import_chalk3.default.bold.green;
614
+ var focusText = import_chalk3.default.bold;
615
+ var dangerText = import_chalk3.default.bold.red;
616
+ var neutralText = import_chalk3.default.bold.cyan;
617
+ var linkText = import_chalk3.default.bold.cyan;
618
+ var labelText = import_chalk3.default.bold;
619
+ var cmdText = import_chalk3.default.inverse;
620
+ var indentedCmd = (str) => {
621
+ return ` \u2503 ` + str;
622
+ };
623
+ var indentText = (str) => {
624
+ return String(str).split("\n").map((line) => ` ${line}`).join("\n");
625
+ };
626
+ var logText = import_chalk3.default.italic.gray;
627
+ var warnText = import_chalk3.default.yellowBright.bgBlack;
628
+ var titleText = import_chalk3.default.bgHex("d2f1f8").hex("ec4816");
629
+ var CONFIRMATION_TEXT = import_chalk3.default.dim("enter to confirm");
2095
630
 
2096
- // src/next/config-manager.ts
2097
- var import_fs_extra2 = __toESM(require("fs-extra"));
2098
- var import_path2 = __toESM(require("path"));
2099
- var import_os = __toESM(require("os"));
2100
- var esbuild = __toESM(require("esbuild"));
2101
- var dotenv = __toESM(require("dotenv"));
2102
- var import_normalize_path2 = __toESM(require("normalize-path"));
2103
- var import_chalk2 = __toESM(require("chalk"));
631
+ // src/next/commands/dev-command/server/index.ts
632
+ var import_vite3 = require("vite");
2104
633
 
2105
634
  // src/next/vite/index.ts
2106
635
  var import_node_path2 = __toESM(require("path"));
2107
636
  var import_plugin_react = __toESM(require("@vitejs/plugin-react"));
2108
- var import_fs_extra = __toESM(require("fs-extra"));
2109
- var import_normalize_path = __toESM(require("normalize-path"));
637
+ var import_fs_extra2 = __toESM(require("fs-extra"));
638
+ var import_normalize_path2 = __toESM(require("normalize-path"));
2110
639
  var import_vite = require("vite");
2111
640
 
2112
641
  // src/next/vite/tailwind.ts
@@ -2119,6 +648,7 @@ var import_defaultTheme = __toESM(require("tailwindcss/defaultTheme.js"));
2119
648
  var tinaTailwind = (spaPath, prebuildFilePath) => {
2120
649
  return {
2121
650
  name: "vite-plugin-tina",
651
+ // @ts-ignore
2122
652
  config: (viteConfig) => {
2123
653
  const plugins = [];
2124
654
  const content = [
@@ -2374,841 +904,218 @@ var tinaTailwind = (spaPath, prebuildFilePath) => {
2374
904
  }
2375
905
  };
2376
906
  }
2377
- };
2378
- };
2379
-
2380
- // src/next/vite/index.ts
2381
- async function listFilesRecursively({
2382
- directoryPath,
2383
- config: config2,
2384
- roothPath
2385
- }) {
2386
- const fullDirectoryPath = import_node_path2.default.join(
2387
- roothPath,
2388
- config2.publicFolder,
2389
- directoryPath
2390
- );
2391
- const exists = await import_fs_extra.default.pathExists(fullDirectoryPath);
2392
- if (!exists) {
2393
- return { "0": [] };
2394
- }
2395
- const items = await import_fs_extra.default.readdir(fullDirectoryPath);
2396
- const staticMediaItems = [];
2397
- for (const item of items) {
2398
- const itemPath = import_node_path2.default.join(fullDirectoryPath, item);
2399
- const stats = await import_fs_extra.default.promises.lstat(itemPath);
2400
- const staticMediaItem = {
2401
- id: item,
2402
- filename: item,
2403
- type: stats.isDirectory() ? "dir" : "file",
2404
- directory: `${directoryPath.replace(config2.mediaRoot, "")}`,
2405
- src: `/${import_node_path2.default.join(directoryPath, item)}`,
2406
- thumbnails: {
2407
- "75x75": `/${import_node_path2.default.join(directoryPath, item)}`,
2408
- "400x400": `/${import_node_path2.default.join(directoryPath, item)}`,
2409
- "1000x1000": `/${import_node_path2.default.join(directoryPath, item)}`
2410
- }
2411
- };
2412
- if (stats.isDirectory()) {
2413
- staticMediaItem.children = await listFilesRecursively({
2414
- directoryPath: import_node_path2.default.join(directoryPath, item),
2415
- config: config2,
2416
- roothPath
2417
- });
2418
- }
2419
- staticMediaItems.push(staticMediaItem);
2420
- }
2421
- function chunkArrayIntoObject(array, chunkSize) {
2422
- const result = {};
2423
- for (let i = 0; i < array.length; i += chunkSize) {
2424
- const chunkKey = `${i / chunkSize * 20}`;
2425
- result[chunkKey] = array.slice(i, i + chunkSize);
2426
- }
2427
- return result;
2428
- }
2429
- return chunkArrayIntoObject(staticMediaItems, 20);
2430
- }
2431
- var loadProjectConfig = async ({
2432
- rootPath,
2433
- viteConfigEnv
2434
- }) => {
2435
- if (viteConfigEnv) {
2436
- const configFileJs = import_node_path2.default.join(rootPath, "vite.config.js");
2437
- const configFileTs = import_node_path2.default.join(rootPath, "vite.config.ts");
2438
- if (import_fs_extra.default.existsSync(configFileJs)) {
2439
- return await (0, import_vite.loadConfigFromFile)(viteConfigEnv, configFileJs);
2440
- } else if (import_fs_extra.default.existsSync(configFileTs)) {
2441
- return await (0, import_vite.loadConfigFromFile)(viteConfigEnv, configFileTs);
2442
- }
2443
- }
2444
- return { config: {} };
2445
- };
2446
- var createConfig = async ({
2447
- configManager,
2448
- database,
2449
- apiURL,
2450
- plugins = [],
2451
- noWatch,
2452
- rollupOptions,
2453
- viteConfigEnv
2454
- }) => {
2455
- var _a, _b, _c, _d, _e, _f, _g, _h, _i;
2456
- const projectConfig = await loadProjectConfig({
2457
- rootPath: configManager.rootPath,
2458
- viteConfigEnv
2459
- });
2460
- const publicEnv = {};
2461
- Object.keys(process.env).forEach((key) => {
2462
- if (key.startsWith("TINA_PUBLIC_") || key.startsWith("NEXT_PUBLIC_") || key === "NODE_ENV" || key === "HEAD") {
2463
- try {
2464
- if (typeof process.env[key] === "string") {
2465
- publicEnv[key] = process.env[key];
2466
- } else {
2467
- publicEnv[key] = JSON.stringify(process.env[key]);
2468
- }
2469
- } catch (error) {
2470
- console.warn(
2471
- `Could not stringify public env process.env.${key} env variable`
2472
- );
2473
- console.warn(error);
2474
- }
2475
- }
2476
- });
2477
- const staticMediaPath = import_node_path2.default.join(
2478
- configManager.generatedFolderPath,
2479
- "static-media.json"
2480
- );
2481
- if ((_b = (_a = configManager.config.media) == null ? void 0 : _a.tina) == null ? void 0 : _b.static) {
2482
- const staticMedia = await listFilesRecursively({
2483
- directoryPath: ((_c = configManager.config.media.tina) == null ? void 0 : _c.mediaRoot) || "",
2484
- config: configManager.config.media.tina,
2485
- roothPath: configManager.rootPath
2486
- });
2487
- await import_fs_extra.default.outputFile(staticMediaPath, JSON.stringify(staticMedia, null, 2));
2488
- } else {
2489
- await import_fs_extra.default.outputFile(staticMediaPath, `[]`);
2490
- }
2491
- const alias = {
2492
- TINA_IMPORT: configManager.prebuildFilePath,
2493
- SCHEMA_IMPORT: configManager.generatedGraphQLJSONPath,
2494
- STATIC_MEDIA_IMPORT: staticMediaPath,
2495
- crypto: import_node_path2.default.join(configManager.spaRootPath, "src", "dummy-client.ts"),
2496
- fs: import_node_path2.default.join(configManager.spaRootPath, "src", "dummy-client.ts"),
2497
- os: import_node_path2.default.join(configManager.spaRootPath, "src", "dummy-client.ts"),
2498
- path: import_node_path2.default.join(configManager.spaRootPath, "src", "dummy-client.ts")
2499
- };
2500
- if (configManager.shouldSkipSDK()) {
2501
- alias["CLIENT_IMPORT"] = import_node_path2.default.join(
2502
- configManager.spaRootPath,
2503
- "src",
2504
- "dummy-client.ts"
2505
- );
2506
- } else {
2507
- alias["CLIENT_IMPORT"] = configManager.isUsingTs() ? configManager.generatedTypesTSFilePath : configManager.generatedTypesJSFilePath;
2508
- }
2509
- let basePath;
2510
- if (configManager.config.build.basePath) {
2511
- basePath = configManager.config.build.basePath;
2512
- }
2513
- const fullVersion = configManager.getTinaGraphQLVersion();
2514
- const version2 = `${fullVersion.major}.${fullVersion.minor}`;
2515
- const config2 = {
2516
- root: configManager.spaRootPath,
2517
- base: `/${basePath ? `${(0, import_normalize_path.default)(basePath)}/` : ""}${(0, import_normalize_path.default)(
2518
- configManager.config.build.outputFolder
2519
- )}/`,
2520
- appType: "spa",
2521
- resolve: {
2522
- alias: {
2523
- ...(_d = projectConfig.config.resolve) == null ? void 0 : _d.alias,
2524
- ...alias
2525
- },
2526
- dedupe: ["graphql", "tinacms", "react", "react-dom", "react-router-dom"]
2527
- },
2528
- define: {
2529
- "process.env": `new Object(${JSON.stringify(publicEnv)})`,
2530
- "process.platform": `"${process.platform}"`,
2531
- __API_URL__: `"${apiURL}"`,
2532
- __BASE_PATH__: `"${((_f = (_e = configManager.config) == null ? void 0 : _e.build) == null ? void 0 : _f.basePath) || ""}"`,
2533
- __TINA_GRAPHQL_VERSION__: version2
2534
- },
2535
- logLevel: "error",
2536
- optimizeDeps: {
2537
- force: true,
2538
- include: ["react/jsx-runtime", "react/jsx-dev-runtime"]
2539
- },
2540
- server: {
2541
- host: (_i = (_h = (_g = configManager.config) == null ? void 0 : _g.build) == null ? void 0 : _h.host) != null ? _i : false,
2542
- watch: noWatch ? {
2543
- ignored: ["**/*"]
2544
- } : {
2545
- ignored: [
2546
- `${configManager.tinaFolderPath}/**/!(config.prebuild.jsx|_graphql.json)`
2547
- ]
2548
- },
2549
- fs: {
2550
- strict: false
2551
- }
2552
- },
2553
- build: {
2554
- sourcemap: false,
2555
- outDir: configManager.outputFolderPath,
2556
- emptyOutDir: true,
2557
- rollupOptions
2558
- },
2559
- plugins: [
2560
- (0, import_plugin_react.default)({
2561
- babel: {
2562
- compact: true
2563
- }
2564
- }),
2565
- (0, import_vite.splitVendorChunkPlugin)(),
2566
- tinaTailwind(configManager.spaRootPath, configManager.prebuildFilePath),
2567
- ...plugins
2568
- ]
2569
- };
2570
- return config2;
2571
- };
2572
-
2573
- // src/next/config-manager.ts
2574
- var import_tsconfig_paths = __toESM(require_lib2());
2575
- var import_esbuild_plugin_alias_path = require("esbuild-plugin-alias-path");
2576
-
2577
- // src/logger/index.ts
2578
- var import_chalk = __toESM(require("chalk"));
2579
-
2580
- // src/logger/is-unicode-supported.ts
2581
- function isUnicodeSupported() {
2582
- if (process.platform !== "win32") {
2583
- return process.env.TERM !== "linux";
2584
- }
2585
- return Boolean(process.env.CI) || Boolean(process.env.WT_SESSION) || Boolean(process.env.TERMINUS_SUBLIME) || process.env.ConEmuTask === "{cmd::Cmder}" || process.env.TERM_PROGRAM === "Terminus-Sublime" || process.env.TERM_PROGRAM === "vscode" || process.env.TERM === "xterm-256color" || process.env.TERM === "alacritty" || process.env.TERMINAL_EMULATOR === "JetBrains-JediTerm";
2586
- }
2587
-
2588
- // src/logger/index.ts
2589
- var import_log4js = __toESM(require("log4js"));
2590
- var logger = import_log4js.default.getLogger();
2591
- import_log4js.default.configure({
2592
- appenders: {
2593
- out: { type: "stdout", layout: { type: "messagePassThrough" } }
2594
- },
2595
- categories: { default: { appenders: ["out"], level: "info" } }
2596
- });
2597
- logger.level = "info";
2598
- function ansiRegex() {
2599
- const pattern = [
2600
- "[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)",
2601
- "(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"
2602
- ].join("|");
2603
- return new RegExp(pattern, "g");
2604
- }
2605
- var bar = "\u2502";
2606
- var strip = (str) => str.replace(ansiRegex(), "");
2607
- var note = (message = "", title = "") => {
2608
- const lines = `
2609
- ${message}
2610
- `.split("\n");
2611
- const len = lines.reduce((sum, ln) => {
2612
- ln = strip(ln);
2613
- return ln.length > sum ? ln.length : sum;
2614
- }, 0) + 2;
2615
- const msg = lines.map(
2616
- (ln) => `${import_chalk.default.gray(bar)} ${import_chalk.default.white(ln)}${" ".repeat(
2617
- len - strip(ln).length
2618
- )}${import_chalk.default.gray(bar)}`
2619
- ).join("\n");
2620
- const underscoreLen = len - title.length - 1 > 0 ? len - title.length - 1 : 0;
2621
- process.stdout.write(
2622
- `${import_chalk.default.gray(bar)}
2623
- ${import_chalk.default.green("\u25CB")} ${import_chalk.default.reset(
2624
- title
2625
- )} ${import_chalk.default.gray("\u2500".repeat(underscoreLen) + "\u256E")}
2626
- ${msg}
2627
- ${import_chalk.default.gray(
2628
- "\u251C" + "\u2500".repeat(len + 2) + "\u256F"
2629
- )}
2630
- `
2631
- );
2632
- };
2633
- var summary = (content) => {
2634
- const outString = [];
2635
- let longestKey = 0;
2636
- content.items.forEach((item) => {
2637
- item.subItems.forEach((subItem) => {
2638
- if (subItem.key.length > longestKey) {
2639
- longestKey = subItem.key.length;
2640
- }
2641
- });
2642
- });
2643
- content.items.forEach((item) => {
2644
- outString.push(`${item.emoji} ${import_chalk.default.cyan(item.heading)}`);
2645
- item.subItems.forEach((subItem) => {
2646
- const spaces = longestKey - subItem.key.length + 4;
2647
- outString.push(
2648
- ` ${subItem.key}:${[...Array(spaces)].join(" ")}${import_chalk.default.cyan(
2649
- subItem.value
2650
- )}`
2651
- );
2652
- });
2653
- outString.push(``);
2654
- });
2655
- if (process.env.CI) {
2656
- logger.info(JSON.stringify(content, null, 2));
2657
- } else {
2658
- note(outString.join("\n"), content.heading);
2659
- }
2660
- };
2661
- var unicode = isUnicodeSupported();
2662
- var s = (c, fallback) => unicode ? c : fallback;
2663
- var S_STEP_ACTIVE = s("\u25C6", "*");
2664
- var S_STEP_CANCEL = s("\u25A0", "x");
2665
- var S_STEP_ERROR = s("\u25B2", "x");
2666
- var S_STEP_SUBMIT = s("\u25C7", "o");
2667
- var S_BAR_START = s("\u250C", "T");
2668
- var S_BAR = s("\u2502", "|");
2669
- var S_BAR_END = s("\u2514", "\u2014");
2670
- var S_RADIO_ACTIVE = s("\u25CF", ">");
2671
- var S_RADIO_INACTIVE = s("\u25CB", " ");
2672
- var S_CHECKBOX_ACTIVE = s("\u25FB", "[\u2022]");
2673
- var S_CHECKBOX_SELECTED = s("\u25FC", "[+]");
2674
- var S_CHECKBOX_INACTIVE = s("\u25FB", "[ ]");
2675
- var S_PASSWORD_MASK = s("\u25AA", "\u2022");
2676
- var S_BAR_H = s("\u2500", "-");
2677
- var S_CORNER_TOP_RIGHT = s("\u256E", "+");
2678
- var S_CONNECT_LEFT = s("\u251C", "+");
2679
- var S_CORNER_BOTTOM_RIGHT = s("\u256F", "+");
2680
- var S_INFO = s("\u25CF", "\u2022");
2681
- var S_SUCCESS = s("\u25C6", "*");
2682
- var S_WARN = s("\u25B2", "!");
2683
- var S_ERROR = s("\u25A0", "x");
2684
-
2685
- // src/utils/alias-helpers.ts
2686
- var import_path = __toESM(require("path"));
2687
- function resolveTsPathsToEsbuildAliases(absoluteBaseUrl, paths) {
2688
- return Object.entries(paths).reduce((aliases, [aliasKey, aliasPaths]) => {
2689
- if (aliasKey === "@/*") {
2690
- console.warn('Ignoring "@/*" alias due to potential conflicts.');
2691
- return aliases;
2692
- }
2693
- const hasWildcard = aliasKey.includes("*");
2694
- const baseAliasKey = hasWildcard ? aliasKey.replace("/*", "") : aliasKey;
2695
- const baseAliasPath = import_path.default.resolve(
2696
- absoluteBaseUrl,
2697
- aliasPaths[0].replace("/*", "")
2698
- );
2699
- if (hasWildcard) {
2700
- aliases[`${baseAliasKey}/*`] = `${baseAliasPath}`;
2701
- } else {
2702
- aliases[baseAliasKey] = baseAliasPath;
2703
- }
2704
- return aliases;
2705
- }, {});
2706
- }
2707
-
2708
- // src/next/config-manager.ts
2709
- var TINA_FOLDER = "tina";
2710
- var LEGACY_TINA_FOLDER = ".tina";
2711
- var GENERATED_FOLDER = "__generated__";
2712
- var GRAPHQL_JSON_FILE = "_graphql.json";
2713
- var GRAPHQL_GQL_FILE = "schema.gql";
2714
- var SCHEMA_JSON_FILE = "_schema.json";
2715
- var LOOKUP_JSON_FILE = "_lookup.json";
2716
- var ConfigManager = class {
2717
- constructor({
2718
- rootPath = process.cwd(),
2719
- tinaGraphQLVersion,
2720
- legacyNoSDK
2721
- }) {
2722
- this.rootPath = (0, import_normalize_path2.default)(rootPath);
2723
- this.tinaGraphQLVersionFromCLI = tinaGraphQLVersion;
2724
- this.legacyNoSDK = legacyNoSDK;
2725
- }
2726
- isUsingTs() {
2727
- return [".ts", ".tsx"].includes(import_path2.default.extname(this.tinaConfigFilePath));
2728
- }
2729
- hasSelfHostedConfig() {
2730
- return !!this.selfHostedDatabaseFilePath;
2731
- }
2732
- hasSeparateContentRoot() {
2733
- return this.rootPath !== this.contentRootPath;
2734
- }
2735
- shouldSkipSDK() {
2736
- var _a;
2737
- if (this.legacyNoSDK) {
2738
- return this.legacyNoSDK;
2739
- }
2740
- return ((_a = this.config.client) == null ? void 0 : _a.skip) || false;
2741
- }
2742
- async processConfig() {
2743
- this.tinaFolderPath = await this.getTinaFolderPath(this.rootPath);
2744
- this.envFilePath = import_path2.default.resolve(
2745
- import_path2.default.join(this.tinaFolderPath, "..", ".env")
2746
- );
2747
- dotenv.config({ path: this.envFilePath });
2748
- this.tinaConfigFilePath = await this.getPathWithExtension(
2749
- import_path2.default.join(this.tinaFolderPath, "config")
2750
- );
2751
- if (!this.tinaConfigFilePath) {
2752
- throw new Error(
2753
- `Unable to find config file in ${this.tinaFolderPath}. Looking for a file named "config.{ts,tsx,js,jsx}"`
2754
- );
2755
- }
2756
- this.selfHostedDatabaseFilePath = await this.getPathWithExtension(
2757
- import_path2.default.join(this.tinaFolderPath, "database")
2758
- );
2759
- this.generatedFolderPath = import_path2.default.join(this.tinaFolderPath, GENERATED_FOLDER);
2760
- this.generatedCachePath = import_path2.default.join(
2761
- this.generatedFolderPath,
2762
- ".cache",
2763
- String(new Date().getTime())
2764
- );
2765
- this.generatedGraphQLGQLPath = import_path2.default.join(
2766
- this.generatedFolderPath,
2767
- GRAPHQL_GQL_FILE
2768
- );
2769
- this.generatedGraphQLJSONPath = import_path2.default.join(
2770
- this.generatedFolderPath,
2771
- GRAPHQL_JSON_FILE
2772
- );
2773
- this.generatedSchemaJSONPath = import_path2.default.join(
2774
- this.generatedFolderPath,
2775
- SCHEMA_JSON_FILE
2776
- );
2777
- this.generatedLookupJSONPath = import_path2.default.join(
2778
- this.generatedFolderPath,
2779
- LOOKUP_JSON_FILE
2780
- );
2781
- this.generatedQueriesFilePath = import_path2.default.join(
2782
- this.generatedFolderPath,
2783
- "queries.gql"
2784
- );
2785
- this.generatedFragmentsFilePath = import_path2.default.join(
2786
- this.generatedFolderPath,
2787
- "frags.gql"
2788
- );
2789
- this.generatedTypesTSFilePath = import_path2.default.join(
2790
- this.generatedFolderPath,
2791
- "types.ts"
2792
- );
2793
- this.generatedTypesJSFilePath = import_path2.default.join(
2794
- this.generatedFolderPath,
2795
- "types.js"
2796
- );
2797
- this.generatedTypesDFilePath = import_path2.default.join(
2798
- this.generatedFolderPath,
2799
- "types.d.ts"
2800
- );
2801
- this.userQueriesAndFragmentsGlob = import_path2.default.join(
2802
- this.tinaFolderPath,
2803
- "queries/**/*.{graphql,gql}"
2804
- );
2805
- this.generatedQueriesAndFragmentsGlob = import_path2.default.join(
2806
- this.generatedFolderPath,
2807
- "*.{graphql,gql}"
2808
- );
2809
- this.generatedClientTSFilePath = import_path2.default.join(
2810
- this.generatedFolderPath,
2811
- "client.ts"
2812
- );
2813
- this.generatedClientJSFilePath = import_path2.default.join(
2814
- this.generatedFolderPath,
2815
- "client.js"
2816
- );
2817
- this.generatedClientDFilePath = import_path2.default.join(
2818
- this.generatedFolderPath,
2819
- "client.d.ts"
2820
- );
2821
- this.generatedDatabaseClientDFilePath = import_path2.default.join(
2822
- this.generatedFolderPath,
2823
- "databaseClient.d.ts"
2824
- );
2825
- this.generatedDatabaseClientTSFilePath = import_path2.default.join(
2826
- this.generatedFolderPath,
2827
- "databaseClient.ts"
2828
- );
2829
- this.generatedDatabaseClientJSFilePath = import_path2.default.join(
2830
- this.generatedFolderPath,
2831
- "databaseClient.js"
2832
- );
2833
- const clientExists = this.isUsingTs() ? await import_fs_extra2.default.pathExists(this.generatedClientTSFilePath) : await import_fs_extra2.default.pathExists(this.generatedClientJSFilePath);
2834
- if (!clientExists) {
2835
- const file = "export default ()=>({})\nexport const client = ()=>({})";
2836
- if (this.isUsingTs()) {
2837
- await import_fs_extra2.default.outputFile(this.generatedClientTSFilePath, file);
2838
- } else {
2839
- await import_fs_extra2.default.outputFile(this.generatedClientJSFilePath, file);
2840
- }
2841
- }
2842
- const { config: config2, prebuildPath, watchList } = await this.loadConfigFile(
2843
- this.generatedFolderPath,
2844
- this.tinaConfigFilePath
2845
- );
2846
- this.watchList = watchList;
2847
- this.config = config2;
2848
- this.prebuildFilePath = prebuildPath;
2849
- this.publicFolderPath = import_path2.default.join(
2850
- this.rootPath,
2851
- this.config.build.publicFolder
2852
- );
2853
- this.outputFolderPath = import_path2.default.join(
2854
- this.publicFolderPath,
2855
- this.config.build.outputFolder
2856
- );
2857
- this.outputHTMLFilePath = import_path2.default.join(this.outputFolderPath, "index.html");
2858
- this.outputGitignorePath = import_path2.default.join(this.outputFolderPath, ".gitignore");
2859
- const fullLocalContentPath = import_path2.default.join(
2860
- this.tinaFolderPath,
2861
- this.config.localContentPath || ""
2862
- );
2863
- if (this.config.localContentPath) {
2864
- const localContentPathExists = await import_fs_extra2.default.pathExists(fullLocalContentPath);
2865
- if (localContentPathExists) {
2866
- logger.info(`Using separate content repo at ${fullLocalContentPath}`);
2867
- this.contentRootPath = fullLocalContentPath;
2868
- } else {
2869
- logger.warn(
2870
- `${import_chalk2.default.yellow("Warning:")} The localContentPath ${import_chalk2.default.cyan(
2871
- fullLocalContentPath
2872
- )} does not exist. Please create it or remove the localContentPath from your config file at ${import_chalk2.default.cyan(
2873
- this.tinaConfigFilePath
2874
- )}`
2875
- );
2876
- }
2877
- }
2878
- if (!this.contentRootPath) {
2879
- this.contentRootPath = this.rootPath;
2880
- }
2881
- this.generatedFolderPathContentRepo = import_path2.default.join(
2882
- await this.getTinaFolderPath(this.contentRootPath),
2883
- GENERATED_FOLDER
2884
- );
2885
- this.spaMainPath = require.resolve("@tinacms/app");
2886
- this.spaRootPath = import_path2.default.join(this.spaMainPath, "..", "..");
2887
- }
2888
- async getTinaFolderPath(rootPath) {
2889
- const tinaFolderPath = import_path2.default.join(rootPath, TINA_FOLDER);
2890
- const tinaFolderExists = await import_fs_extra2.default.pathExists(tinaFolderPath);
2891
- if (tinaFolderExists) {
2892
- this.isUsingLegacyFolder = false;
2893
- return tinaFolderPath;
2894
- }
2895
- const legacyFolderPath = import_path2.default.join(rootPath, LEGACY_TINA_FOLDER);
2896
- const legacyFolderExists = await import_fs_extra2.default.pathExists(legacyFolderPath);
2897
- if (legacyFolderExists) {
2898
- this.isUsingLegacyFolder = true;
2899
- return legacyFolderPath;
2900
- }
2901
- throw new Error(
2902
- `Unable to find Tina folder, if you're working in folder outside of the Tina config be sure to specify --rootPath`
2903
- );
2904
- }
2905
- getTinaGraphQLVersion() {
2906
- if (this.tinaGraphQLVersionFromCLI) {
2907
- const version2 = this.tinaGraphQLVersionFromCLI.split(".");
2908
- return {
2909
- fullVersion: this.tinaGraphQLVersionFromCLI,
2910
- major: version2[0] || "x",
2911
- minor: version2[1] || "x",
2912
- patch: version2[2] || "x"
2913
- };
2914
- }
2915
- const generatedSchema = import_fs_extra2.default.readJSONSync(this.generatedSchemaJSONPath);
2916
- if (!generatedSchema || !(typeof (generatedSchema == null ? void 0 : generatedSchema.version) !== "undefined")) {
2917
- throw new Error(
2918
- `Can not find Tina GraphQL version in ${this.generatedSchemaJSONPath}`
2919
- );
2920
- }
2921
- return generatedSchema.version;
2922
- }
2923
- printGeneratedClientFilePath() {
2924
- if (this.isUsingTs()) {
2925
- return this.generatedClientTSFilePath.replace(`${this.rootPath}/`, "");
2926
- }
2927
- return this.generatedClientJSFilePath.replace(`${this.rootPath}/`, "");
2928
- }
2929
- printGeneratedTypesFilePath() {
2930
- return this.generatedTypesTSFilePath.replace(`${this.rootPath}/`, "");
2931
- }
2932
- printoutputHTMLFilePath() {
2933
- return this.outputHTMLFilePath.replace(`${this.publicFolderPath}/`, "");
2934
- }
2935
- printRelativePath(filename) {
2936
- if (filename) {
2937
- return filename.replace(/\\/g, "/").replace(`${this.rootPath}/`, "");
2938
- }
2939
- throw `No path provided to print`;
2940
- }
2941
- printPrebuildFilePath() {
2942
- return this.prebuildFilePath.replace(/\\/g, "/").replace(`${this.rootPath}/${this.tinaFolderPath}/`, "");
2943
- }
2944
- printContentRelativePath(filename) {
2945
- if (filename) {
2946
- return filename.replace(/\\/g, "/").replace(`${this.contentRootPath}/`, "");
2947
- }
2948
- throw `No path provided to print`;
2949
- }
2950
- async getPathWithExtension(filepath) {
2951
- const extensions = ["tsx", "ts", "jsx", "js"];
2952
- let result;
2953
- await Promise.all(
2954
- extensions.map(async (ext) => {
2955
- if (result) {
2956
- return;
2957
- }
2958
- const filepathWithExtension = `${filepath}.${ext}`;
2959
- const exists = import_fs_extra2.default.existsSync(filepathWithExtension);
2960
- if (exists) {
2961
- result = filepathWithExtension;
2962
- }
2963
- })
2964
- );
2965
- return result;
2966
- }
2967
- async loadDatabaseFile() {
2968
- const tmpdir = import_path2.default.join(import_os.default.tmpdir(), Date.now().toString());
2969
- const outfile = import_path2.default.join(tmpdir, "database.build.js");
2970
- await esbuild.build({
2971
- entryPoints: [this.selfHostedDatabaseFilePath],
2972
- bundle: true,
2973
- platform: "node",
2974
- outfile,
2975
- loader: loaders
2976
- });
2977
- const result = require(outfile);
2978
- import_fs_extra2.default.removeSync(outfile);
2979
- return result.default;
2980
- }
2981
- async loadConfigFile(generatedFolderPath, configFilePath) {
2982
- var _a;
2983
- const tmpdir = import_path2.default.join(import_os.default.tmpdir(), Date.now().toString());
2984
- const preBuildConfigPath = import_path2.default.join(
2985
- this.generatedFolderPath,
2986
- "config.prebuild.jsx"
2987
- );
2988
- const outfile = import_path2.default.join(tmpdir, "config.build.jsx");
2989
- const outfile2 = import_path2.default.join(tmpdir, "config.build.js");
2990
- const tempTSConfigFile = import_path2.default.join(tmpdir, "tsconfig.json");
2991
- const viteConfig = await loadProjectConfig({
2992
- rootPath: this.rootPath,
2993
- viteConfigEnv: {
2994
- command: "build",
2995
- mode: "production"
2996
- }
2997
- });
2998
- const tsconfigPath = import_path2.default.join(this.rootPath, "tsconfig.json");
2999
- let dynamicAliases = {};
3000
- if (import_fs_extra2.default.existsSync(tsconfigPath)) {
3001
- const tsConfigResult = (0, import_tsconfig_paths.loadConfig)(tsconfigPath);
3002
- if (tsConfigResult.resultType === "success") {
3003
- const { absoluteBaseUrl, paths } = tsConfigResult;
3004
- dynamicAliases = resolveTsPathsToEsbuildAliases(absoluteBaseUrl, paths);
3005
- } else {
3006
- console.error("Failed to load tsconfig.json:", tsConfigResult.message);
3007
- throw new Error(`Invalid tsconfig.json at ${tsconfigPath}`);
3008
- }
3009
- } else {
3010
- console.warn(
3011
- "Warning: tsconfig.json not found. Alias resolution will not be supported."
3012
- );
3013
- }
3014
- import_fs_extra2.default.outputFileSync(tempTSConfigFile, "{}");
3015
- const result2 = await esbuild.build({
3016
- entryPoints: [configFilePath],
3017
- bundle: true,
3018
- target: ["es2020"],
3019
- platform: "browser",
3020
- format: "esm",
3021
- logLevel: "silent",
3022
- packages: "external",
3023
- ignoreAnnotations: true,
3024
- outfile: preBuildConfigPath,
3025
- loader: loaders,
3026
- metafile: true,
3027
- plugins: Object.keys(dynamicAliases).length ? [(0, import_esbuild_plugin_alias_path.aliasPath)({ alias: dynamicAliases })] : []
3028
- });
3029
- const flattenedList = [];
3030
- Object.keys(result2.metafile.inputs).forEach((key) => {
3031
- if (key.includes("node_modules") || key.includes("__generated__")) {
3032
- return;
3033
- }
3034
- flattenedList.push(key);
3035
- });
3036
- await esbuild.build({
3037
- entryPoints: [configFilePath],
3038
- bundle: true,
3039
- target: ["es2020"],
3040
- logLevel: "silent",
3041
- platform: "node",
3042
- outfile,
3043
- loader: loaders,
3044
- alias: (_a = viteConfig.config.resolve) == null ? void 0 : _a.alias
3045
- });
3046
- await esbuild.build({
3047
- entryPoints: [outfile],
3048
- bundle: true,
3049
- logLevel: "silent",
3050
- platform: "node",
3051
- outfile: outfile2,
3052
- loader: loaders
3053
- });
3054
- let result;
3055
- try {
3056
- result = require(outfile2);
3057
- } catch (e) {
3058
- console.error("Unexpected error loading config");
3059
- console.error(e);
3060
- throw e;
3061
- }
3062
- import_fs_extra2.default.removeSync(outfile);
3063
- import_fs_extra2.default.removeSync(outfile2);
3064
- return {
3065
- config: result.default,
3066
- prebuildPath: preBuildConfigPath,
3067
- watchList: flattenedList
3068
- };
3069
- }
3070
- };
3071
- var loaders = {
3072
- ".aac": "file",
3073
- ".css": "file",
3074
- ".eot": "file",
3075
- ".flac": "file",
3076
- ".gif": "file",
3077
- ".jpeg": "file",
3078
- ".jpg": "file",
3079
- ".json": "json",
3080
- ".mp3": "file",
3081
- ".mp4": "file",
3082
- ".ogg": "file",
3083
- ".otf": "file",
3084
- ".png": "file",
3085
- ".svg": "file",
3086
- ".ttf": "file",
3087
- ".wav": "file",
3088
- ".webm": "file",
3089
- ".webp": "file",
3090
- ".woff": "file",
3091
- ".woff2": "file",
3092
- ".js": "jsx",
3093
- ".jsx": "jsx",
3094
- ".tsx": "tsx"
3095
- };
3096
-
3097
- // src/next/commands/dev-command/html.ts
3098
- var errorHTML = `<style type="text/css">
3099
- #no-assets-placeholder body {
3100
- font-family: sans-serif;
3101
- font-size: 16px;
3102
- line-height: 1.4;
3103
- color: #333;
3104
- background-color: #f5f5f5;
3105
- }
3106
- #no-assets-placeholder {
3107
- max-width: 600px;
3108
- margin: 0 auto;
3109
- padding: 40px;
3110
- text-align: center;
3111
- background-color: #fff;
3112
- box-shadow: 0px 0px 20px rgba(0, 0, 0, 0.1);
3113
- }
3114
- #no-assets-placeholder h1 {
3115
- font-size: 24px;
3116
- margin-bottom: 20px;
3117
- }
3118
- #no-assets-placeholder p {
3119
- margin-bottom: 10px;
3120
- }
3121
- #no-assets-placeholder a {
3122
- color: #0077cc;
3123
- text-decoration: none;
3124
- }
3125
- #no-assets-placeholder a:hover {
3126
- text-decoration: underline;
3127
- }
3128
- </style>
3129
- <div id="no-assets-placeholder">
3130
- <h1>Failed loading TinaCMS assets</h1>
3131
- <p>
3132
- Your TinaCMS configuration may be misconfigured, and we could not load
3133
- the assets for this page.
3134
- </p>
3135
- <p>
3136
- Please visit <a href="https://tina.io/docs/tina-cloud/faq/#how-do-i-resolve-failed-loading-tinacms-assets-error">this doc</a> for help.
3137
- </p>
3138
- </div>
3139
- </div>`.trim().replace(/[\r\n\s]+/g, " ");
3140
- var devHTML = (port) => `<!DOCTYPE html>
3141
- <html lang="en">
3142
- <head>
3143
- <meta charset="UTF-8" />
3144
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
3145
- <title>TinaCMS</title>
3146
- </head>
3147
-
3148
- <!-- if development -->
3149
- <script type="module">
3150
- import RefreshRuntime from 'http://localhost:${port}/@react-refresh'
3151
- RefreshRuntime.injectIntoGlobalHook(window)
3152
- window.$RefreshReg$ = () => {}
3153
- window.$RefreshSig$ = () => (type) => type
3154
- window.__vite_plugin_react_preamble_installed__ = true
3155
- <\/script>
3156
- <script type="module" src="http://localhost:${port}/@vite/client"><\/script>
3157
- <script>
3158
- function handleLoadError() {
3159
- // Assets have failed to load
3160
- document.getElementById('root').innerHTML = '${errorHTML}';
3161
- }
3162
- <\/script>
3163
- <script
3164
- type="module"
3165
- src="http://localhost:${port}/src/main.tsx"
3166
- onerror="handleLoadError()"
3167
- ><\/script>
3168
- <body class="tina-tailwind">
3169
- <div id="root"></div>
3170
- </body>
3171
- </html>`;
3172
-
3173
- // src/utils/theme.ts
3174
- var import_chalk3 = __toESM(require("chalk"));
3175
- var successText = import_chalk3.default.bold.green;
3176
- var focusText = import_chalk3.default.bold;
3177
- var dangerText = import_chalk3.default.bold.red;
3178
- var neutralText = import_chalk3.default.bold.cyan;
3179
- var linkText = import_chalk3.default.bold.cyan;
3180
- var labelText = import_chalk3.default.bold;
3181
- var cmdText = import_chalk3.default.inverse;
3182
- var indentedCmd = (str) => {
3183
- return ` \u2503 ` + str;
3184
- };
3185
- var indentText = (str) => {
3186
- return String(str).split("\n").map((line) => ` ${line}`).join("\n");
907
+ };
3187
908
  };
3188
- var logText = import_chalk3.default.italic.gray;
3189
- var warnText = import_chalk3.default.yellowBright.bgBlack;
3190
- var titleText = import_chalk3.default.bgHex("d2f1f8").hex("ec4816");
3191
- var CONFIRMATION_TEXT = import_chalk3.default.dim("enter to confirm");
3192
909
 
3193
- // src/next/commands/dev-command/server/index.ts
3194
- var import_vite4 = require("vite");
910
+ // src/next/vite/index.ts
911
+ async function listFilesRecursively({
912
+ directoryPath,
913
+ config: config2,
914
+ roothPath
915
+ }) {
916
+ const fullDirectoryPath = import_node_path2.default.join(
917
+ roothPath,
918
+ config2.publicFolder,
919
+ directoryPath
920
+ );
921
+ const exists = await import_fs_extra2.default.pathExists(fullDirectoryPath);
922
+ if (!exists) {
923
+ return { "0": [] };
924
+ }
925
+ const items = await import_fs_extra2.default.readdir(fullDirectoryPath);
926
+ const staticMediaItems = [];
927
+ for (const item of items) {
928
+ const itemPath = import_node_path2.default.join(fullDirectoryPath, item);
929
+ const stats = await import_fs_extra2.default.promises.lstat(itemPath);
930
+ const staticMediaItem = {
931
+ id: item,
932
+ filename: item,
933
+ type: stats.isDirectory() ? "dir" : "file",
934
+ directory: `${directoryPath.replace(config2.mediaRoot, "")}`,
935
+ src: `/${import_node_path2.default.join(directoryPath, item)}`,
936
+ thumbnails: {
937
+ "75x75": `/${import_node_path2.default.join(directoryPath, item)}`,
938
+ "400x400": `/${import_node_path2.default.join(directoryPath, item)}`,
939
+ "1000x1000": `/${import_node_path2.default.join(directoryPath, item)}`
940
+ }
941
+ };
942
+ if (stats.isDirectory()) {
943
+ staticMediaItem.children = await listFilesRecursively({
944
+ directoryPath: import_node_path2.default.join(directoryPath, item),
945
+ config: config2,
946
+ roothPath
947
+ });
948
+ }
949
+ staticMediaItems.push(staticMediaItem);
950
+ }
951
+ function chunkArrayIntoObject(array, chunkSize) {
952
+ const result = {};
953
+ for (let i = 0; i < array.length; i += chunkSize) {
954
+ const chunkKey = `${i / chunkSize * 20}`;
955
+ result[chunkKey] = array.slice(i, i + chunkSize);
956
+ }
957
+ return result;
958
+ }
959
+ return chunkArrayIntoObject(staticMediaItems, 20);
960
+ }
961
+ var createConfig = async ({
962
+ configManager,
963
+ apiURL,
964
+ plugins = [],
965
+ noWatch,
966
+ rollupOptions
967
+ }) => {
968
+ var _a, _b, _c, _d, _e, _f, _g, _h;
969
+ const publicEnv = {};
970
+ Object.keys(process.env).forEach((key) => {
971
+ if (key.startsWith("TINA_PUBLIC_") || key.startsWith("NEXT_PUBLIC_") || key === "NODE_ENV" || key === "HEAD") {
972
+ try {
973
+ if (typeof process.env[key] === "string") {
974
+ publicEnv[key] = process.env[key];
975
+ } else {
976
+ publicEnv[key] = JSON.stringify(process.env[key]);
977
+ }
978
+ } catch (error) {
979
+ console.warn(
980
+ `Could not stringify public env process.env.${key} env variable`
981
+ );
982
+ console.warn(error);
983
+ }
984
+ }
985
+ });
986
+ const staticMediaPath = import_node_path2.default.join(
987
+ configManager.generatedFolderPath,
988
+ "static-media.json"
989
+ );
990
+ if ((_b = (_a = configManager.config.media) == null ? void 0 : _a.tina) == null ? void 0 : _b.static) {
991
+ const staticMedia = await listFilesRecursively({
992
+ directoryPath: ((_c = configManager.config.media.tina) == null ? void 0 : _c.mediaRoot) || "",
993
+ config: configManager.config.media.tina,
994
+ roothPath: configManager.rootPath
995
+ });
996
+ await import_fs_extra2.default.outputFile(staticMediaPath, JSON.stringify(staticMedia, null, 2));
997
+ } else {
998
+ await import_fs_extra2.default.outputFile(staticMediaPath, `[]`);
999
+ }
1000
+ const alias = {
1001
+ TINA_IMPORT: configManager.prebuildFilePath,
1002
+ SCHEMA_IMPORT: configManager.generatedGraphQLJSONPath,
1003
+ STATIC_MEDIA_IMPORT: staticMediaPath,
1004
+ crypto: import_node_path2.default.join(configManager.spaRootPath, "src", "dummy-client.ts"),
1005
+ fs: import_node_path2.default.join(configManager.spaRootPath, "src", "dummy-client.ts"),
1006
+ os: import_node_path2.default.join(configManager.spaRootPath, "src", "dummy-client.ts"),
1007
+ path: import_node_path2.default.join(configManager.spaRootPath, "src", "dummy-client.ts")
1008
+ };
1009
+ if (configManager.shouldSkipSDK()) {
1010
+ alias["CLIENT_IMPORT"] = import_node_path2.default.join(
1011
+ configManager.spaRootPath,
1012
+ "src",
1013
+ "dummy-client.ts"
1014
+ );
1015
+ } else {
1016
+ alias["CLIENT_IMPORT"] = configManager.isUsingTs() ? configManager.generatedTypesTSFilePath : configManager.generatedTypesJSFilePath;
1017
+ }
1018
+ let basePath;
1019
+ if (configManager.config.build.basePath) {
1020
+ basePath = configManager.config.build.basePath;
1021
+ }
1022
+ const fullVersion = configManager.getTinaGraphQLVersion();
1023
+ const version2 = `${fullVersion.major}.${fullVersion.minor}`;
1024
+ const config2 = {
1025
+ root: configManager.spaRootPath,
1026
+ base: `/${basePath ? `${(0, import_normalize_path2.default)(basePath)}/` : ""}${(0, import_normalize_path2.default)(
1027
+ configManager.config.build.outputFolder
1028
+ )}/`,
1029
+ appType: "spa",
1030
+ resolve: {
1031
+ alias,
1032
+ dedupe: ["graphql", "tinacms", "react", "react-dom", "react-router-dom"]
1033
+ },
1034
+ define: {
1035
+ /**
1036
+ * Since we prebuild the config.ts, it's possible for modules to be loaded which make
1037
+ * use of `process`. The main scenario where this is an issue is when co-locating schema
1038
+ * definitions with source files, and specifically source files which impor from NextJS.
1039
+ *
1040
+ * Some examples of what NextJS uses for `process.env` are:
1041
+ * - `process.env.__NEXT_TRAILING_SLASH`
1042
+ * - `process.env.__NEXT_CROSS_ORIGIN`
1043
+ * - `process.env.__NEXT_I18N_SUPPORT`
1044
+ *
1045
+ * Also, interestingly some of the advice for handling this doesn't work, references to replacing
1046
+ * `process.env` with `{}` are problematic, because browsers don't understand the `{}.` syntax,
1047
+ * but node does. This was a surprise, but using `new Object()` seems to do the trick.
1048
+ */
1049
+ "process.env": `new Object(${JSON.stringify(publicEnv)})`,
1050
+ // Used by picomatch https://github.com/micromatch/picomatch/blob/master/lib/utils.js#L4
1051
+ "process.platform": `"${process.platform}"`,
1052
+ __API_URL__: `"${apiURL}"`,
1053
+ __BASE_PATH__: `"${((_e = (_d = configManager.config) == null ? void 0 : _d.build) == null ? void 0 : _e.basePath) || ""}"`,
1054
+ __TINA_GRAPHQL_VERSION__: version2
1055
+ },
1056
+ logLevel: "error",
1057
+ // Vite import warnings are noisy
1058
+ optimizeDeps: {
1059
+ force: true,
1060
+ // Not 100% sure why this isn't being picked up automatically, this works from within the monorepo
1061
+ // but breaks externally
1062
+ include: ["react/jsx-runtime", "react/jsx-dev-runtime"]
1063
+ },
1064
+ server: {
1065
+ host: (_h = (_g = (_f = configManager.config) == null ? void 0 : _f.build) == null ? void 0 : _g.host) != null ? _h : false,
1066
+ watch: noWatch ? {
1067
+ ignored: ["**/*"]
1068
+ } : {
1069
+ // Ignore everything except for the alias fields we specified above
1070
+ ignored: [
1071
+ `${configManager.tinaFolderPath}/**/!(config.prebuild.jsx|_graphql.json)`
1072
+ ]
1073
+ },
1074
+ fs: {
1075
+ strict: false
1076
+ }
1077
+ },
1078
+ build: {
1079
+ sourcemap: false,
1080
+ outDir: configManager.outputFolderPath,
1081
+ emptyOutDir: true,
1082
+ rollupOptions
1083
+ },
1084
+ plugins: [
1085
+ /**
1086
+ * `splitVendorChunkPlugin` is needed because `tinacms` is quite large,
1087
+ * Vite's chunking strategy chokes on memory issues for smaller machines (ie. on CI).
1088
+ */
1089
+ (0, import_plugin_react.default)({
1090
+ babel: {
1091
+ // Supresses the warning [NOTE] babel The code generator has deoptimised the styling of
1092
+ compact: true
1093
+ }
1094
+ }),
1095
+ (0, import_vite.splitVendorChunkPlugin)(),
1096
+ tinaTailwind(configManager.spaRootPath, configManager.prebuildFilePath),
1097
+ ...plugins
1098
+ ]
1099
+ };
1100
+ return config2;
1101
+ };
3195
1102
 
3196
1103
  // src/next/vite/plugins.ts
3197
1104
  var import_pluginutils = require("@rollup/pluginutils");
3198
1105
  var import_fs = __toESM(require("fs"));
3199
- var import_vite3 = require("vite");
1106
+ var import_vite2 = require("vite");
3200
1107
  var import_esbuild = require("esbuild");
3201
- var import_path4 = __toESM(require("path"));
1108
+ var import_path3 = __toESM(require("path"));
3202
1109
  var import_body_parser = __toESM(require("body-parser"));
3203
1110
  var import_cors = __toESM(require("cors"));
3204
1111
  var import_graphql = require("@tinacms/graphql");
3205
1112
 
3206
1113
  // src/next/commands/dev-command/server/media.ts
3207
1114
  var import_fs_extra3 = __toESM(require("fs-extra"));
3208
- var import_path3 = __toESM(require("path"));
1115
+ var import_path2 = __toESM(require("path"));
3209
1116
  var import_busboy = __toESM(require("busboy"));
3210
1117
  var createMediaRouter = (config2) => {
3211
- const mediaFolder = import_path3.default.join(
1118
+ const mediaFolder = import_path2.default.join(
3212
1119
  config2.rootPath,
3213
1120
  config2.publicFolder,
3214
1121
  config2.mediaRoot
@@ -3236,8 +1143,8 @@ var createMediaRouter = (config2) => {
3236
1143
  bb.on("file", async (_name, file, _info) => {
3237
1144
  var _a;
3238
1145
  const fullPath = decodeURI((_a = req.url) == null ? void 0 : _a.slice("/media/upload/".length));
3239
- const saveTo = import_path3.default.join(mediaFolder, ...fullPath.split("/"));
3240
- await import_fs_extra3.default.ensureDir(import_path3.default.dirname(saveTo));
1146
+ const saveTo = import_path2.default.join(mediaFolder, ...fullPath.split("/"));
1147
+ await import_fs_extra3.default.ensureDir(import_path2.default.dirname(saveTo));
3241
1148
  file.pipe(import_fs_extra3.default.createWriteStream(saveTo));
3242
1149
  });
3243
1150
  bb.on("error", (error) => {
@@ -3258,8 +1165,7 @@ var createMediaRouter = (config2) => {
3258
1165
  };
3259
1166
  var parseMediaFolder = (str) => {
3260
1167
  let returnString = str;
3261
- if (returnString.startsWith("/"))
3262
- returnString = returnString.substr(1);
1168
+ if (returnString.startsWith("/")) returnString = returnString.substr(1);
3263
1169
  if (returnString.endsWith("/"))
3264
1170
  returnString = returnString.substr(0, returnString.length - 1);
3265
1171
  return returnString;
@@ -3272,11 +1178,11 @@ var MediaModel = class {
3272
1178
  }
3273
1179
  async listMedia(args) {
3274
1180
  try {
3275
- const folderPath = (0, import_path3.join)(
1181
+ const folderPath = (0, import_path2.join)(
3276
1182
  this.rootPath,
3277
1183
  this.publicFolder,
3278
1184
  this.mediaRoot,
3279
- args.searchPath
1185
+ decodeURIComponent(args.searchPath)
3280
1186
  );
3281
1187
  const searchPath = parseMediaFolder(args.searchPath);
3282
1188
  if (!await import_fs_extra3.default.pathExists(folderPath)) {
@@ -3287,7 +1193,7 @@ var MediaModel = class {
3287
1193
  }
3288
1194
  const filesStr = await import_fs_extra3.default.readdir(folderPath);
3289
1195
  const filesProm = filesStr.map(async (file) => {
3290
- const filePath = (0, import_path3.join)(folderPath, file);
1196
+ const filePath = (0, import_path2.join)(folderPath, file);
3291
1197
  const stat = await import_fs_extra3.default.stat(filePath);
3292
1198
  let src = `/${file}`;
3293
1199
  const isFile = stat.isFile();
@@ -3344,11 +1250,11 @@ var MediaModel = class {
3344
1250
  }
3345
1251
  async deleteMedia(args) {
3346
1252
  try {
3347
- const file = (0, import_path3.join)(
1253
+ const file = (0, import_path2.join)(
3348
1254
  this.rootPath,
3349
1255
  this.publicFolder,
3350
1256
  this.mediaRoot,
3351
- args.searchPath
1257
+ decodeURIComponent(args.searchPath)
3352
1258
  );
3353
1259
  await import_fs_extra3.default.stat(file);
3354
1260
  await import_fs_extra3.default.remove(file);
@@ -3409,7 +1315,7 @@ var transformTsxPlugin = ({
3409
1315
  const plug = {
3410
1316
  name: "transform-tsx",
3411
1317
  async transform(code, id) {
3412
- const extName = import_path4.default.extname(id);
1318
+ const extName = import_path3.default.extname(id);
3413
1319
  if (extName.startsWith(".tsx") || extName.startsWith(".ts")) {
3414
1320
  const result = await (0, import_esbuild.transform)(code, { loader: "tsx" });
3415
1321
  return {
@@ -3424,7 +1330,8 @@ var devServerEndPointsPlugin = ({
3424
1330
  configManager,
3425
1331
  apiURL,
3426
1332
  database,
3427
- searchIndex
1333
+ searchIndex,
1334
+ databaseLock
3428
1335
  }) => {
3429
1336
  const plug = {
3430
1337
  name: "graphql-endpoints",
@@ -3468,14 +1375,17 @@ var devServerEndPointsPlugin = ({
3468
1375
  }
3469
1376
  if (req.url === "/graphql") {
3470
1377
  const { query, variables } = req.body;
3471
- const result = await (0, import_graphql.resolve)({
3472
- config: {
3473
- useRelativeMedia: true
3474
- },
3475
- database,
3476
- query,
3477
- variables,
3478
- verbose: false
1378
+ let result;
1379
+ await databaseLock(async () => {
1380
+ result = await (0, import_graphql.resolve)({
1381
+ config: {
1382
+ useRelativeMedia: true
1383
+ },
1384
+ database,
1385
+ query,
1386
+ variables,
1387
+ verbose: false
1388
+ });
3479
1389
  });
3480
1390
  res.end(JSON.stringify(result));
3481
1391
  return;
@@ -3519,13 +1429,14 @@ function viteTransformExtension({
3519
1429
  previousExport: exportAsDefault ? null : code
3520
1430
  }
3521
1431
  });
3522
- const res = await (0, import_vite3.transformWithEsbuild)(componentCode, id, {
1432
+ const res = await (0, import_vite2.transformWithEsbuild)(componentCode, id, {
3523
1433
  loader: "jsx",
3524
1434
  ...esbuildOptions
3525
1435
  });
3526
1436
  return {
3527
1437
  code: res.code,
3528
1438
  map: null
1439
+ // TODO:
3529
1440
  };
3530
1441
  }
3531
1442
  }
@@ -3533,19 +1444,33 @@ function viteTransformExtension({
3533
1444
  }
3534
1445
 
3535
1446
  // src/next/commands/dev-command/server/index.ts
3536
- var createDevServer = async (configManager, database, searchIndex, apiURL, noWatch) => {
1447
+ var createDevServer = async (configManager, database, searchIndex, apiURL, noWatch, databaseLock) => {
3537
1448
  const plugins = [
3538
1449
  transformTsxPlugin({ configManager }),
3539
- devServerEndPointsPlugin({ apiURL, configManager, database, searchIndex }),
1450
+ devServerEndPointsPlugin({
1451
+ apiURL,
1452
+ configManager,
1453
+ database,
1454
+ searchIndex,
1455
+ databaseLock
1456
+ }),
3540
1457
  viteTransformExtension()
3541
1458
  ];
3542
- return (0, import_vite4.createServer)(
1459
+ return (0, import_vite3.createServer)(
3543
1460
  await createConfig({
3544
1461
  configManager,
3545
1462
  database,
3546
1463
  apiURL,
3547
1464
  plugins,
3548
1465
  noWatch,
1466
+ /**
1467
+ * Ensure Vite's import scan uses the spaMainPath as the input
1468
+ * so it properly finds everything. This is for dev only, and when
1469
+ * running the server outside of this monorepo vite fails to find
1470
+ * and optimize the imports, so you get errors about it not being
1471
+ * able to find an export from a module, and it's always a CJS
1472
+ * module that Vite would usually transform to an ES module.
1473
+ */
3549
1474
  rollupOptions: {
3550
1475
  input: configManager.spaMainPath,
3551
1476
  onwarn(warning, warn) {
@@ -3554,10 +1479,6 @@ var createDevServer = async (configManager, database, searchIndex, apiURL, noWat
3554
1479
  }
3555
1480
  warn(warning);
3556
1481
  }
3557
- },
3558
- viteConfigEnv: {
3559
- command: "serve",
3560
- mode: "development"
3561
1482
  }
3562
1483
  })
3563
1484
  );
@@ -3565,7 +1486,7 @@ var createDevServer = async (configManager, database, searchIndex, apiURL, noWat
3565
1486
 
3566
1487
  // src/next/codegen/index.ts
3567
1488
  var import_fs_extra4 = __toESM(require("fs-extra"));
3568
- var import_path5 = __toESM(require("path"));
1489
+ var import_path4 = __toESM(require("path"));
3569
1490
  var import_graphql6 = require("graphql");
3570
1491
 
3571
1492
  // src/next/codegen/codegen/index.ts
@@ -3675,6 +1596,7 @@ var GenericSdkVisitor = class extends import_visitor_plugin_common.ClientSideBas
3675
1596
  node,
3676
1597
  documentVariableName,
3677
1598
  operationType,
1599
+ // This is the only line that is different
3678
1600
  operationResultType: `{data: ${operationResultType}, errors?: { message: string, locations: { line: number, column: number }[], path: string[] }[], variables: ${operationVariablesTypes}, query: string}`,
3679
1601
  operationVariablesTypes
3680
1602
  });
@@ -3723,6 +1645,8 @@ var plugin = (schema, documents, config2) => {
3723
1645
  const visitor = new GenericSdkVisitor(schema, allFragments, config2);
3724
1646
  const visitorResult = (0, import_graphql3.visit)(allAst, { leave: visitor });
3725
1647
  return {
1648
+ // We will take care of imports
1649
+ // prepend: visitor.getImports(),
3726
1650
  content: [
3727
1651
  visitor.fragments,
3728
1652
  ...visitorResult.definitions.filter((t) => typeof t === "string"),
@@ -3738,6 +1662,7 @@ var generateTypes = async (schema, queryPathGlob = process.cwd(), fragDocPath =
3738
1662
  docs = await loadGraphQLDocuments(queryPathGlob);
3739
1663
  fragDocs = await loadGraphQLDocuments(fragDocPath);
3740
1664
  const res = await (0, import_core.codegen)({
1665
+ // Filename is not used. This is because the typescript plugin returns a string instead of writing to a file.
3741
1666
  filename: process.cwd(),
3742
1667
  schema: (0, import_graphql5.parse)((0, import_graphql5.printSchema)(schema)),
3743
1668
  documents: [...docs, ...fragDocs],
@@ -3772,9 +1697,12 @@ var loadGraphQLDocuments = async (globPath) => {
3772
1697
  loaders: [new import_graphql_file_loader.GraphQLFileLoader()]
3773
1698
  });
3774
1699
  } catch (e) {
3775
- if ((e.message || "").includes(
3776
- "Unable to find any GraphQL type definitions for the following pointers:"
3777
- )) {
1700
+ if (
1701
+ // https://www.graphql-tools.com/docs/documents-loading#no-files-found
1702
+ (e.message || "").includes(
1703
+ "Unable to find any GraphQL type definitions for the following pointers:"
1704
+ )
1705
+ ) {
3778
1706
  } else {
3779
1707
  throw e;
3780
1708
  }
@@ -3811,11 +1739,14 @@ var Codegen = class {
3811
1739
  this.noClientBuildCache = noClientBuildCache;
3812
1740
  }
3813
1741
  async writeConfigFile(fileName, data) {
3814
- const filePath = import_path5.default.join(this.configManager.generatedFolderPath, fileName);
1742
+ const filePath = import_path4.default.join(
1743
+ this.configManager.generatedFolderPath,
1744
+ fileName
1745
+ );
3815
1746
  await import_fs_extra4.default.ensureFile(filePath);
3816
1747
  await import_fs_extra4.default.outputFile(filePath, data);
3817
1748
  if (this.configManager.hasSeparateContentRoot()) {
3818
- const filePath2 = import_path5.default.join(
1749
+ const filePath2 = import_path4.default.join(
3819
1750
  this.configManager.generatedFolderPathContentRepo,
3820
1751
  fileName
3821
1752
  );
@@ -3936,12 +1867,9 @@ var Codegen = class {
3936
1867
  const baseUrl = ((_d = this.configManager.config.tinaioConfig) == null ? void 0 : _d.contentApiUrlOverride) || `https://${TINA_HOST}`;
3937
1868
  if ((!branch || !clientId || !token) && !this.port && !this.configManager.config.contentApiUrlOverride) {
3938
1869
  const missing = [];
3939
- if (!branch)
3940
- missing.push("branch");
3941
- if (!clientId)
3942
- missing.push("clientId");
3943
- if (!token)
3944
- missing.push("token");
1870
+ if (!branch) missing.push("branch");
1871
+ if (!clientId) missing.push("clientId");
1872
+ if (!token) missing.push("token");
3945
1873
  throw new Error(
3946
1874
  `Client not configured properly. Missing ${missing.join(
3947
1875
  ", "
@@ -4095,7 +2023,11 @@ schema {
4095
2023
  }
4096
2024
  };
4097
2025
  var maybeWarnFragmentSize = async (filepath) => {
4098
- if ((await import_fs_extra4.default.stat(filepath)).size > 100 * 1024) {
2026
+ if (
2027
+ // is the file bigger than 100kb?
2028
+ (await import_fs_extra4.default.stat(filepath)).size > // convert to 100 kb to bytes
2029
+ 100 * 1024
2030
+ ) {
4099
2031
  console.warn(
4100
2032
  "Warning: frags.gql is very large (>100kb). Consider setting the reference depth to 1 or 0. See code snippet below."
4101
2033
  );
@@ -4123,6 +2055,7 @@ var import_many_level = require("many-level");
4123
2055
  var import_memory_level = require("memory-level");
4124
2056
  var createDBServer = (port) => {
4125
2057
  const levelHost = new import_many_level.ManyLevelHost(
2058
+ // @ts-ignore
4126
2059
  new import_memory_level.MemoryLevel({
4127
2060
  valueEncoding: "json"
4128
2061
  })
@@ -4273,7 +2206,9 @@ var BaseCommand = class extends import_clipanion.Command {
4273
2206
  let subProc;
4274
2207
  if (this.subCommand) {
4275
2208
  subProc = await startSubprocess2({ command: this.subCommand });
4276
- logger.info(`Starting subprocess: ${import_chalk4.default.cyan(this.subCommand)}`);
2209
+ logger.info(
2210
+ `Running web application with command: ${import_chalk4.default.cyan(this.subCommand)}`
2211
+ );
4277
2212
  }
4278
2213
  function exitHandler(options, exitCode) {
4279
2214
  if (subProc) {
@@ -4353,7 +2288,7 @@ var BaseCommand = class extends import_clipanion.Command {
4353
2288
  pathFilter
4354
2289
  });
4355
2290
  const tinaPathUpdates = modified.filter(
4356
- (path15) => path15.startsWith(".tina/__generated__/_schema.json") || path15.startsWith("tina/tina-lock.json")
2291
+ (path14) => path14.startsWith(".tina/__generated__/_schema.json") || path14.startsWith("tina/tina-lock.json")
4357
2292
  );
4358
2293
  if (tinaPathUpdates.length > 0) {
4359
2294
  res = await database.indexContent({
@@ -4397,6 +2332,7 @@ var import_search = require("@tinacms/search");
4397
2332
  var DevCommand = class extends BaseCommand {
4398
2333
  constructor() {
4399
2334
  super(...arguments);
2335
+ // NOTE: camelCase commands for string options don't work if there's an `=` used https://github.com/arcanis/clipanion/issues/141
4400
2336
  this.watchFolders = import_clipanion2.Option.String("-w,--watchFolders", {
4401
2337
  description: "DEPRECATED - a list of folders (relative to where this is being run) that the cli will watch for changes"
4402
2338
  });
@@ -4406,6 +2342,10 @@ var DevCommand = class extends BaseCommand {
4406
2342
  this.outputSearchIndexPath = import_clipanion2.Option.String("--outputSearchIndexPath", {
4407
2343
  description: "Path to write the search index to"
4408
2344
  });
2345
+ this.noServer = import_clipanion2.Option.Boolean("--no-server", false, {
2346
+ description: "Do not start the dev server"
2347
+ });
2348
+ this.indexingLock = new import_async_lock.default();
4409
2349
  }
4410
2350
  async catch(error) {
4411
2351
  logger.error("Error occured during tinacms dev");
@@ -4426,10 +2366,13 @@ var DevCommand = class extends BaseCommand {
4426
2366
  rootPath: this.rootPath,
4427
2367
  legacyNoSDK: this.noSDK
4428
2368
  });
4429
- logger.info("Starting Tina Dev Server");
2369
+ logger.info("\u{1F999} TinaCMS Dev Server is initializing...");
4430
2370
  this.logDeprecationWarnings();
4431
2371
  createDBServer(Number(this.datalayerPort));
4432
2372
  let database = null;
2373
+ const dbLock = async (fn) => {
2374
+ return this.indexingLock.acquire("Key", fn);
2375
+ };
4433
2376
  const setup = async ({ firstTime }) => {
4434
2377
  try {
4435
2378
  await configManager.processConfig();
@@ -4468,21 +2411,18 @@ var DevCommand = class extends BaseCommand {
4468
2411
  graphql: graphqlSchemaObject
4469
2412
  });
4470
2413
  import_fs_extra6.default.writeFileSync(
4471
- import_path6.default.join(configManager.tinaFolderPath, tinaLockFilename),
2414
+ import_path5.default.join(configManager.tinaFolderPath, tinaLockFilename),
4472
2415
  tinaLockContent
4473
2416
  );
4474
2417
  if (configManager.hasSeparateContentRoot()) {
4475
2418
  const rootPath = await configManager.getTinaFolderPath(
4476
2419
  configManager.contentRootPath
4477
2420
  );
4478
- const filePath = import_path6.default.join(rootPath, tinaLockFilename);
2421
+ const filePath = import_path5.default.join(rootPath, tinaLockFilename);
4479
2422
  await import_fs_extra6.default.ensureFile(filePath);
4480
2423
  await import_fs_extra6.default.outputFile(filePath, tinaLockContent);
4481
2424
  }
4482
2425
  }
4483
- if (!this.noWatch) {
4484
- this.watchQueries(configManager, async () => await codegen2.execute());
4485
- }
4486
2426
  await this.indexContentWithSpinner({
4487
2427
  database,
4488
2428
  graphQLSchema: graphQLSchema2,
@@ -4492,6 +2432,13 @@ var DevCommand = class extends BaseCommand {
4492
2432
  if (!firstTime) {
4493
2433
  logger.error("Re-index complete");
4494
2434
  }
2435
+ if (!this.noWatch) {
2436
+ this.watchQueries(
2437
+ configManager,
2438
+ dbLock,
2439
+ async () => await codegen2.execute()
2440
+ );
2441
+ }
4495
2442
  return { apiURL: apiURL2, database, graphQLSchema: graphQLSchema2, tinaSchema: tinaSchema2 };
4496
2443
  } catch (e) {
4497
2444
  logger.error(`
@@ -4526,14 +2473,6 @@ ${dangerText(e.message)}
4526
2473
  tokenSplitRegex: (_d = (_c = configManager.config.search) == null ? void 0 : _c.tina) == null ? void 0 : _d.tokenSplitRegex
4527
2474
  });
4528
2475
  await searchIndexClient.onStartIndexing();
4529
- const server = await createDevServer(
4530
- configManager,
4531
- database,
4532
- searchIndexClient.searchIndex,
4533
- apiURL,
4534
- this.noWatch
4535
- );
4536
- await server.listen(Number(this.port));
4537
2476
  const searchIndexer = new import_search.SearchIndexer({
4538
2477
  batchSize: ((_e = configManager.config.search) == null ? void 0 : _e.indexBatchSize) || 100,
4539
2478
  bridge: new import_graphql10.FilesystemBridge(
@@ -4555,16 +2494,34 @@ ${dangerText(e.message)}
4555
2494
  await searchIndexClient.export(this.outputSearchIndexPath);
4556
2495
  }
4557
2496
  }
2497
+ if (this.noServer) {
2498
+ logger.info("--no-server option specified - Dev server not started");
2499
+ process.exit(0);
2500
+ }
4558
2501
  if (!this.noWatch) {
4559
2502
  this.watchContentFiles(
4560
2503
  configManager,
4561
2504
  database,
2505
+ dbLock,
4562
2506
  configManager.config.search && searchIndexer
4563
2507
  );
2508
+ }
2509
+ const server = await createDevServer(
2510
+ configManager,
2511
+ database,
2512
+ searchIndexClient.searchIndex,
2513
+ apiURL,
2514
+ this.noWatch,
2515
+ dbLock
2516
+ );
2517
+ await server.listen(Number(this.port));
2518
+ if (!this.noWatch) {
4564
2519
  import_chokidar.default.watch(configManager.watchList).on("change", async () => {
4565
- logger.info(`Tina config change detected, rebuilding`);
4566
- await setup({ firstTime: false });
4567
- server.ws.send({ type: "full-reload", path: "*" });
2520
+ await dbLock(async () => {
2521
+ logger.info(`Tina config change detected, rebuilding`);
2522
+ await setup({ firstTime: false });
2523
+ server.ws.send({ type: "full-reload", path: "*" });
2524
+ });
4568
2525
  });
4569
2526
  }
4570
2527
  const subItems = [];
@@ -4577,7 +2534,7 @@ ${dangerText(e.message)}
4577
2534
  const summaryItems = [
4578
2535
  {
4579
2536
  emoji: "\u{1F999}",
4580
- heading: "Tina Config",
2537
+ heading: "TinaCMS URLs",
4581
2538
  subItems: [
4582
2539
  {
4583
2540
  key: "CMS",
@@ -4612,17 +2569,31 @@ ${dangerText(e.message)}
4612
2569
  });
4613
2570
  }
4614
2571
  summary({
4615
- heading: "Tina Dev Server is running...",
2572
+ heading: "\u2705 \u{1F999} TinaCMS Dev Server is active:",
4616
2573
  items: [
4617
2574
  ...summaryItems
2575
+ // {
2576
+ // emoji: '📚',
2577
+ // heading: 'Useful links',
2578
+ // subItems: [
2579
+ // {
2580
+ // key: 'Custom queries',
2581
+ // value: 'https://tina.io/querying',
2582
+ // },
2583
+ // {
2584
+ // key: 'Visual editing',
2585
+ // value: 'https://tina.io/visual-editing',
2586
+ // },
2587
+ // ],
2588
+ // },
4618
2589
  ]
4619
2590
  });
4620
2591
  await this.startSubCommand();
4621
2592
  }
4622
- watchContentFiles(configManager, database, searchIndexer) {
2593
+ watchContentFiles(configManager, database, databaseLock, searchIndexer) {
4623
2594
  const collectionContentFiles = [];
4624
2595
  configManager.config.schema.collections.forEach((collection) => {
4625
- const collectionGlob = `${import_path6.default.join(
2596
+ const collectionGlob = `${import_path5.default.join(
4626
2597
  configManager.contentRootPath,
4627
2598
  collection.path
4628
2599
  )}/**/*.${collection.format || "md"}`;
@@ -4635,39 +2606,42 @@ ${dangerText(e.message)}
4635
2606
  if (!ready) {
4636
2607
  return;
4637
2608
  }
4638
- const pathFromRoot = configManager.printContentRelativePath(addedFile);
4639
- await database.indexContentByPaths([pathFromRoot]).catch(console.error);
4640
- if (searchIndexer) {
4641
- await searchIndexer.indexContentByPaths([pathFromRoot]).catch(console.error);
4642
- }
2609
+ await databaseLock(async () => {
2610
+ const pathFromRoot = configManager.printContentRelativePath(addedFile);
2611
+ await database.indexContentByPaths([pathFromRoot]).catch(console.error);
2612
+ if (searchIndexer) {
2613
+ await searchIndexer.indexContentByPaths([pathFromRoot]).catch(console.error);
2614
+ }
2615
+ });
4643
2616
  }).on("change", async (changedFile) => {
4644
2617
  const pathFromRoot = configManager.printContentRelativePath(changedFile);
4645
- await database.indexContentByPaths([pathFromRoot]).catch(console.error);
4646
- if (searchIndexer) {
4647
- await searchIndexer.indexContentByPaths([pathFromRoot]).catch(console.error);
4648
- }
2618
+ await databaseLock(async () => {
2619
+ await database.indexContentByPaths([pathFromRoot]).catch(console.error);
2620
+ if (searchIndexer) {
2621
+ await searchIndexer.indexContentByPaths([pathFromRoot]).catch(console.error);
2622
+ }
2623
+ });
4649
2624
  }).on("unlink", async (removedFile) => {
4650
2625
  const pathFromRoot = configManager.printContentRelativePath(removedFile);
4651
- await database.deleteContentByPaths([pathFromRoot]).catch(console.error);
4652
- if (searchIndexer) {
4653
- await searchIndexer.deleteIndexContent([pathFromRoot]).catch(console.error);
4654
- }
2626
+ await databaseLock(async () => {
2627
+ await database.deleteContentByPaths([pathFromRoot]).catch(console.error);
2628
+ if (searchIndexer) {
2629
+ await searchIndexer.deleteIndexContent([pathFromRoot]).catch(console.error);
2630
+ }
2631
+ });
4655
2632
  });
4656
2633
  }
4657
- watchQueries(configManager, callback) {
4658
- let ready = false;
4659
- import_chokidar.default.watch(configManager.userQueriesAndFragmentsGlob).on("ready", () => {
4660
- ready = true;
4661
- }).on("add", async (addedFile) => {
4662
- await callback();
4663
- }).on("change", async (changedFile) => {
4664
- await callback();
4665
- }).on("unlink", async (removedFile) => {
4666
- await callback();
4667
- });
2634
+ watchQueries(configManager, databaseLock, callback) {
2635
+ const executeCallback = async (_) => {
2636
+ await databaseLock(async () => {
2637
+ await callback();
2638
+ });
2639
+ };
2640
+ import_chokidar.default.watch(configManager.userQueriesAndFragmentsGlob).on("add", executeCallback).on("change", executeCallback).on("unlink", executeCallback);
4668
2641
  }
4669
2642
  };
4670
2643
  DevCommand.paths = [["dev"], ["server:start"]];
2644
+ // Prevent indexes and reads occurring at once
4671
2645
  DevCommand.usage = import_clipanion2.Command.Usage({
4672
2646
  category: `Commands`,
4673
2647
  description: `Builds Tina and starts the dev server`,
@@ -4682,11 +2656,11 @@ var import_clipanion3 = require("clipanion");
4682
2656
  var import_progress2 = __toESM(require("progress"));
4683
2657
  var import_fs_extra7 = __toESM(require("fs-extra"));
4684
2658
  var import_crypto = __toESM(require("crypto"));
4685
- var import_path7 = __toESM(require("path"));
2659
+ var import_path6 = __toESM(require("path"));
4686
2660
  var import_graphql11 = require("@tinacms/graphql");
4687
2661
 
4688
2662
  // src/next/commands/build-command/server.ts
4689
- var import_vite6 = require("vite");
2663
+ var import_vite5 = require("vite");
4690
2664
  var buildProductionSpa = async (configManager, database, apiURL) => {
4691
2665
  const publicEnv = {};
4692
2666
  Object.keys(process.env).forEach((key) => {
@@ -4718,13 +2692,9 @@ var buildProductionSpa = async (configManager, database, apiURL) => {
4718
2692
  }
4719
2693
  warn(warning);
4720
2694
  }
4721
- },
4722
- viteConfigEnv: {
4723
- command: "build",
4724
- mode: "production"
4725
2695
  }
4726
2696
  });
4727
- return (0, import_vite6.build)(config2);
2697
+ return (0, import_vite5.build)(config2);
4728
2698
  };
4729
2699
 
4730
2700
  // src/next/commands/build-command/index.ts
@@ -4861,6 +2831,9 @@ var BuildCommand = class extends BaseCommand {
4861
2831
  this.tinaGraphQLVersion = import_clipanion3.Option.String("--tina-graphql-version", {
4862
2832
  description: "Specify the version of @tinacms/graphql to use (defaults to latest)"
4863
2833
  });
2834
+ /**
2835
+ * This option allows the user to skip the tina cloud 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 Tina Cloud
2836
+ */
4864
2837
  this.skipCloudChecks = import_clipanion3.Option.Boolean("--skip-cloud-checks", false, {
4865
2838
  description: "Skips checking the provided cloud config."
4866
2839
  });
@@ -4966,7 +2939,8 @@ ${dangerText(e.message)}
4966
2939
  database,
4967
2940
  null,
4968
2941
  apiURL,
4969
- true
2942
+ true,
2943
+ (lockedFn) => lockedFn()
4970
2944
  );
4971
2945
  await server.listen(Number(this.port));
4972
2946
  console.log("server listening on port", this.port);
@@ -5028,7 +3002,9 @@ ${dangerText(e.message)}
5028
3002
  `ERROR: Branch not configured in tina search configuration.`
5029
3003
  )}`
5030
3004
  );
5031
- throw new Error("Branch not configured in tina search configuration.");
3005
+ throw new Error(
3006
+ "Branch not configured in tina search configuration."
3007
+ );
5032
3008
  }
5033
3009
  if (!((_d = configManager.config) == null ? void 0 : _d.clientId)) {
5034
3010
  logger.error(`${dangerText(`ERROR: clientId not configured.`)}`);
@@ -5171,7 +3147,10 @@ ${dangerText(e.message)}
5171
3147
  });
5172
3148
  throw e;
5173
3149
  }
5174
- const branchBar = new import_progress2.default("Checking branch is on Tina Cloud. :prog", 1);
3150
+ const branchBar = new import_progress2.default(
3151
+ "Checking branch is on Tina Cloud. :prog",
3152
+ 1
3153
+ );
5175
3154
  if (branchKnown) {
5176
3155
  branchBar.tick({
5177
3156
  prog: "\u2705"
@@ -5295,7 +3274,7 @@ Additional info: Branch: ${config2.branch}, Client ID: ${config2.clientId} `;
5295
3274
  const localSchemaDocument = await database.getGraphQLSchemaFromBridge();
5296
3275
  const localGraphqlSchema = (0, import_graphql12.buildASTSchema)(localSchemaDocument);
5297
3276
  try {
5298
- const diffResult = await (0, import_core3.diff)(localGraphqlSchema, remoteGqlSchema);
3277
+ const diffResult = await (0, import_core3.diff)(remoteGqlSchema, localGraphqlSchema);
5299
3278
  if (diffResult.length === 0) {
5300
3279
  bar2.tick({
5301
3280
  prog: "\u2705"
@@ -5352,7 +3331,9 @@ Additional info:
5352
3331
  const { clientId, branch, isLocalClient, host } = (0, import_schema_tools2.parseURL)(apiURL);
5353
3332
  if (isLocalClient || !host || !clientId || !branch) {
5354
3333
  if (verbose) {
5355
- logger.info(logText("Not using Tina Cloud, skipping Tina Schema check"));
3334
+ logger.info(
3335
+ logText("Not using Tina Cloud, skipping Tina Schema check")
3336
+ );
5356
3337
  }
5357
3338
  return;
5358
3339
  }
@@ -5377,7 +3358,7 @@ Additional info: Branch: ${config2.branch}, Client ID: ${config2.clientId} `;
5377
3358
  }
5378
3359
  const localTinaSchema = JSON.parse(
5379
3360
  await database.bridge.get(
5380
- import_path7.default.join(database.tinaDirectory, "__generated__", "_schema.json")
3361
+ import_path6.default.join(database.tinaDirectory, "__generated__", "_schema.json")
5381
3362
  )
5382
3363
  );
5383
3364
  localTinaSchema.version = void 0;
@@ -5601,6 +3582,7 @@ var auditDocuments = async (args) => {
5601
3582
  logger.error(import_chalk5.default.red(err.message));
5602
3583
  if (err.originalError.originalError) {
5603
3584
  logger.error(
3585
+ // @ts-ignore FIXME: this doesn't seem right
5604
3586
  import_chalk5.default.red(` ${err.originalError.originalError.message}`)
5605
3587
  );
5606
3588
  }
@@ -5747,25 +3729,25 @@ var import_clipanion6 = require("clipanion");
5747
3729
 
5748
3730
  // src/cmds/init/detectEnvironment.ts
5749
3731
  var import_fs_extra8 = __toESM(require("fs-extra"));
5750
- var import_path8 = __toESM(require("path"));
3732
+ var import_path7 = __toESM(require("path"));
5751
3733
  var checkGitignoreForItem = async ({
5752
3734
  baseDir,
5753
3735
  line
5754
3736
  }) => {
5755
- const gitignoreContent = import_fs_extra8.default.readFileSync(import_path8.default.join(baseDir, ".gitignore")).toString();
3737
+ const gitignoreContent = import_fs_extra8.default.readFileSync(import_path7.default.join(baseDir, ".gitignore")).toString();
5756
3738
  return gitignoreContent.split("\n").some((item) => item === line);
5757
3739
  };
5758
3740
  var makeGeneratedFile = async (name2, generatedFileType, parentPath, opts) => {
5759
3741
  const result = {
5760
- fullPathTS: import_path8.default.join(
3742
+ fullPathTS: import_path7.default.join(
5761
3743
  parentPath,
5762
3744
  `${name2}.${(opts == null ? void 0 : opts.typescriptSuffix) || (opts == null ? void 0 : opts.extensionOverride) || "ts"}`
5763
3745
  ),
5764
- fullPathJS: import_path8.default.join(
3746
+ fullPathJS: import_path7.default.join(
5765
3747
  parentPath,
5766
3748
  `${name2}.${(opts == null ? void 0 : opts.extensionOverride) || "js"}`
5767
3749
  ),
5768
- fullPathOverride: (opts == null ? void 0 : opts.extensionOverride) ? import_path8.default.join(parentPath, `${name2}.${opts == null ? void 0 : opts.extensionOverride}`) : "",
3750
+ fullPathOverride: (opts == null ? void 0 : opts.extensionOverride) ? import_path7.default.join(parentPath, `${name2}.${opts == null ? void 0 : opts.extensionOverride}`) : "",
5769
3751
  generatedFileType,
5770
3752
  name: name2,
5771
3753
  parentPath,
@@ -5795,18 +3777,20 @@ var detectEnvironment = async ({
5795
3777
  }) => {
5796
3778
  var _a;
5797
3779
  const hasForestryConfig = await import_fs_extra8.default.pathExists(
5798
- import_path8.default.join(pathToForestryConfig, ".forestry", "settings.yml")
3780
+ import_path7.default.join(pathToForestryConfig, ".forestry", "settings.yml")
5799
3781
  );
5800
- const sampleContentPath = import_path8.default.join(
3782
+ const sampleContentPath = import_path7.default.join(
5801
3783
  baseDir,
5802
3784
  "content",
5803
3785
  "posts",
5804
3786
  "hello-world.md"
5805
3787
  );
5806
- const usingSrc = import_fs_extra8.default.pathExistsSync(import_path8.default.join(baseDir, "src")) && (import_fs_extra8.default.pathExistsSync(import_path8.default.join(baseDir, "src", "app")) || import_fs_extra8.default.pathExistsSync(import_path8.default.join(baseDir, "src", "pages")));
5807
- const tinaFolder = import_path8.default.join(baseDir, "tina");
3788
+ const usingSrc = import_fs_extra8.default.pathExistsSync(import_path7.default.join(baseDir, "src")) && (import_fs_extra8.default.pathExistsSync(import_path7.default.join(baseDir, "src", "app")) || import_fs_extra8.default.pathExistsSync(import_path7.default.join(baseDir, "src", "pages")));
3789
+ const tinaFolder = import_path7.default.join(baseDir, "tina");
5808
3790
  const tinaConfigExists = Boolean(
5809
- await import_fs_extra8.default.pathExists(tinaFolder) && (await import_fs_extra8.default.readdir(tinaFolder)).find((x) => x.includes("config"))
3791
+ // Does the tina folder exist?
3792
+ await import_fs_extra8.default.pathExists(tinaFolder) && // Does the tina folder contain a config file?
3793
+ (await import_fs_extra8.default.readdir(tinaFolder)).find((x) => x.includes("config"))
5810
3794
  );
5811
3795
  const pagesDir = [baseDir, usingSrc ? "src" : false, "pages"].filter(
5812
3796
  Boolean
@@ -5818,12 +3802,12 @@ var detectEnvironment = async ({
5818
3802
  "next-api-handler": await makeGeneratedFile(
5819
3803
  "[...routes]",
5820
3804
  "next-api-handler",
5821
- import_path8.default.join(...pagesDir, "api", "tina")
3805
+ import_path7.default.join(...pagesDir, "api", "tina")
5822
3806
  ),
5823
3807
  "reactive-example": await makeGeneratedFile(
5824
3808
  "[filename]",
5825
3809
  "reactive-example",
5826
- import_path8.default.join(...pagesDir, "demo", "blog"),
3810
+ import_path7.default.join(...pagesDir, "demo", "blog"),
5827
3811
  {
5828
3812
  typescriptSuffix: "tsx"
5829
3813
  }
@@ -5831,13 +3815,13 @@ var detectEnvironment = async ({
5831
3815
  "users-json": await makeGeneratedFile(
5832
3816
  "index",
5833
3817
  "users-json",
5834
- import_path8.default.join(baseDir, "content", "users"),
3818
+ import_path7.default.join(baseDir, "content", "users"),
5835
3819
  { extensionOverride: "json" }
5836
3820
  ),
5837
3821
  "sample-content": await makeGeneratedFile(
5838
3822
  "hello-world",
5839
3823
  "sample-content",
5840
- import_path8.default.join(baseDir, "content", "posts"),
3824
+ import_path7.default.join(baseDir, "content", "posts"),
5841
3825
  { extensionOverride: "md" }
5842
3826
  )
5843
3827
  };
@@ -5863,13 +3847,13 @@ var detectEnvironment = async ({
5863
3847
  );
5864
3848
  }
5865
3849
  }
5866
- const hasGitIgnore = await import_fs_extra8.default.pathExists(import_path8.default.join(".gitignore"));
3850
+ const hasGitIgnore = await import_fs_extra8.default.pathExists(import_path7.default.join(".gitignore"));
5867
3851
  const hasGitIgnoreNodeModules = hasGitIgnore && await checkGitignoreForItem({ baseDir, line: "node_modules" });
5868
3852
  const hasEnvTina = hasGitIgnore && await checkGitignoreForItem({ baseDir, line: ".env.tina" });
5869
3853
  const hasGitIgnoreEnv = hasGitIgnore && await checkGitignoreForItem({ baseDir, line: ".env" });
5870
3854
  let frontMatterFormat;
5871
3855
  if (hasForestryConfig) {
5872
- const hugoConfigPath = import_path8.default.join(rootPath, "config.toml");
3856
+ const hugoConfigPath = import_path7.default.join(rootPath, "config.toml");
5873
3857
  if (await import_fs_extra8.default.pathExists(hugoConfigPath)) {
5874
3858
  const hugoConfig = await import_fs_extra8.default.readFile(hugoConfigPath, "utf8");
5875
3859
  const metaDataFormat = (_a = hugoConfig.match(/metaDataFormat = "(.*)"/)) == null ? void 0 : _a[1];
@@ -6041,6 +4025,7 @@ var supportedDatabaseAdapters = {
6041
4025
  {
6042
4026
  from: "mongodb",
6043
4027
  imported: [],
4028
+ // not explicitly imported
6044
4029
  packageName: "mongodb"
6045
4030
  }
6046
4031
  ]
@@ -6113,6 +4098,10 @@ var chooseDatabaseAdapter = async ({
6113
4098
  title: "MongoDB",
6114
4099
  value: "mongodb"
6115
4100
  }
4101
+ // {
4102
+ // title: "I'll create my own database adapter",
4103
+ // value: 'other',
4104
+ // },
6116
4105
  ]
6117
4106
  }
6118
4107
  ]);
@@ -6390,6 +4379,7 @@ async function configure(env, opts) {
6390
4379
  packageManager,
6391
4380
  forestryMigrate: false,
6392
4381
  isLocalEnvVarName: "TINA_PUBLIC_IS_LOCAL",
4382
+ // TODO: give this a better default
6393
4383
  typescript: false
6394
4384
  };
6395
4385
  if (config2.framework.name === "next") {
@@ -6477,31 +4467,41 @@ var CLICommand = class {
6477
4467
  };
6478
4468
 
6479
4469
  // src/cmds/init/apply.ts
6480
- var import_path12 = __toESM(require("path"));
4470
+ var import_path11 = __toESM(require("path"));
6481
4471
 
6482
4472
  // src/cmds/forestry-migrate/index.ts
6483
4473
  var import_fs_extra10 = __toESM(require("fs-extra"));
6484
- var import_path10 = __toESM(require("path"));
4474
+ var import_path9 = __toESM(require("path"));
6485
4475
  var import_js_yaml2 = __toESM(require("js-yaml"));
6486
4476
  var import_minimatch = __toESM(require("minimatch"));
6487
4477
  var import_graphql16 = require("@tinacms/graphql");
6488
4478
 
6489
4479
  // src/cmds/forestry-migrate/util/index.ts
6490
4480
  var import_fs_extra9 = __toESM(require("fs-extra"));
6491
- var import_path9 = __toESM(require("path"));
4481
+ var import_path8 = __toESM(require("path"));
6492
4482
  var import_js_yaml = __toESM(require("js-yaml"));
6493
4483
  var import_zod = __toESM(require("zod"));
6494
4484
 
6495
4485
  // src/cmds/forestry-migrate/util/errorSingleton.ts
6496
- var ErrorSingleton = class {
4486
+ var ErrorSingleton = class _ErrorSingleton {
4487
+ /**
4488
+ * The Singleton's constructor should always be private to prevent direct
4489
+ * construction calls with the `new` operator.
4490
+ */
6497
4491
  constructor() {
6498
4492
  }
4493
+ /**
4494
+ * The static method that controls the access to the singleton instance.
4495
+ *
4496
+ * This implementation let you subclass the Singleton class while keeping
4497
+ * just one instance of each subclass around.
4498
+ */
6499
4499
  static getInstance() {
6500
- if (!ErrorSingleton.instance) {
6501
- ErrorSingleton.instance = new ErrorSingleton();
6502
- ErrorSingleton.instance.collectionNameErrors = [];
4500
+ if (!_ErrorSingleton.instance) {
4501
+ _ErrorSingleton.instance = new _ErrorSingleton();
4502
+ _ErrorSingleton.instance.collectionNameErrors = [];
6503
4503
  }
6504
- return ErrorSingleton.instance;
4504
+ return _ErrorSingleton.instance;
6505
4505
  }
6506
4506
  addErrorName(error) {
6507
4507
  this.collectionNameErrors.push(error);
@@ -6544,8 +4544,7 @@ var makeFieldsWithInternalCode = ({
6544
4544
  if (hasBody) {
6545
4545
  return [bodyField, `__TINA_INTERNAL__:::...${field}():::`];
6546
4546
  } else {
6547
- if (spread)
6548
- return `__TINA_INTERNAL__:::...${field}():::`;
4547
+ if (spread) return `__TINA_INTERNAL__:::...${field}():::`;
6549
4548
  return `__TINA_INTERNAL__:::${field}():::`;
6550
4549
  }
6551
4550
  };
@@ -6629,6 +4628,7 @@ var forestryConfigSchema = import_zod.default.object({
6629
4628
  )
6630
4629
  });
6631
4630
  var forestryFieldWithoutField = import_zod.default.object({
4631
+ // TODO: maybe better type this?
6632
4632
  type: import_zod.default.union([
6633
4633
  import_zod.default.literal("text"),
6634
4634
  import_zod.default.literal("datetime"),
@@ -6652,6 +4652,7 @@ var forestryFieldWithoutField = import_zod.default.object({
6652
4652
  default: import_zod.default.any().optional(),
6653
4653
  template: import_zod.default.string().optional(),
6654
4654
  config: import_zod.default.object({
4655
+ // min and max are used for lists
6655
4656
  min: import_zod.default.number().optional().nullable(),
6656
4657
  max: import_zod.default.number().optional().nullable(),
6657
4658
  required: import_zod.default.boolean().optional().nullable(),
@@ -6665,6 +4666,7 @@ var forestryFieldWithoutField = import_zod.default.object({
6665
4666
  import_zod.default.literal("pages"),
6666
4667
  import_zod.default.literal("documents"),
6667
4668
  import_zod.default.literal("simple"),
4669
+ // TODO: I want to ignore this key if its invalid
6668
4670
  import_zod.default.string()
6669
4671
  ]).optional().nullable(),
6670
4672
  section: import_zod.default.string().optional().nullable()
@@ -6700,6 +4702,7 @@ var transformForestryFieldsToTinaFields = ({
6700
4702
  }
6701
4703
  let field;
6702
4704
  switch (forestryField2.type) {
4705
+ // Single filed types
6703
4706
  case "text":
6704
4707
  field = {
6705
4708
  type: "string",
@@ -6779,6 +4782,7 @@ var transformForestryFieldsToTinaFields = ({
6779
4782
  );
6780
4783
  }
6781
4784
  break;
4785
+ // List Types
6782
4786
  case "list":
6783
4787
  field = {
6784
4788
  type: "string",
@@ -6801,6 +4805,7 @@ var transformForestryFieldsToTinaFields = ({
6801
4805
  }
6802
4806
  };
6803
4807
  break;
4808
+ // Object (Group) types
6804
4809
  case "field_group":
6805
4810
  field = {
6806
4811
  type: "object",
@@ -6841,6 +4846,7 @@ var transformForestryFieldsToTinaFields = ({
6841
4846
  });
6842
4847
  const fieldsString = stringifyLabelWithField(template2.label);
6843
4848
  const t = {
4849
+ // @ts-ignore
6844
4850
  fields: makeFieldsWithInternalCode({
6845
4851
  hasBody: false,
6846
4852
  field: fieldsString
@@ -6849,7 +4855,6 @@ var transformForestryFieldsToTinaFields = ({
6849
4855
  name: stringifyTemplateName(tem, tem)
6850
4856
  };
6851
4857
  if (t.name != tem) {
6852
- ;
6853
4858
  t.nameOverride = tem;
6854
4859
  }
6855
4860
  templates2.push(t);
@@ -6878,6 +4883,7 @@ var transformForestryFieldsToTinaFields = ({
6878
4883
  spread: true
6879
4884
  });
6880
4885
  tinaFields.push(
4886
+ // @ts-ignore
6881
4887
  field2
6882
4888
  );
6883
4889
  break;
@@ -6899,7 +4905,7 @@ var transformForestryFieldsToTinaFields = ({
6899
4905
  return tinaFields;
6900
4906
  };
6901
4907
  var getFieldsFromTemplates = ({ tem, pathToForestryConfig, skipBlocks = false }) => {
6902
- const templatePath = import_path9.default.join(
4908
+ const templatePath = import_path8.default.join(
6903
4909
  pathToForestryConfig,
6904
4910
  ".forestry",
6905
4911
  "front_matter",
@@ -6937,6 +4943,7 @@ var parseSections = ({ val }) => {
6937
4943
 
6938
4944
  // src/cmds/forestry-migrate/index.ts
6939
4945
  var BODY_FIELD = {
4946
+ // This is the body field
6940
4947
  type: "rich-text",
6941
4948
  name: "body",
6942
4949
  label: "Body of Document",
@@ -6974,8 +4981,8 @@ var generateAllTemplates = async ({
6974
4981
  pathToForestryConfig
6975
4982
  }) => {
6976
4983
  const allTemplates = (await import_fs_extra10.default.readdir(
6977
- import_path10.default.join(pathToForestryConfig, ".forestry", "front_matter", "templates")
6978
- )).map((tem) => import_path10.default.basename(tem, ".yml"));
4984
+ import_path9.default.join(pathToForestryConfig, ".forestry", "front_matter", "templates")
4985
+ )).map((tem) => import_path9.default.basename(tem, ".yml"));
6979
4986
  const templateMap = /* @__PURE__ */ new Map();
6980
4987
  const proms = allTemplates.map(async (tem) => {
6981
4988
  try {
@@ -6995,8 +5002,7 @@ var generateAllTemplates = async ({
6995
5002
  };
6996
5003
  var generateCollectionFromForestrySection = (args) => {
6997
5004
  const { section, templateMap } = args;
6998
- if (section.read_only)
6999
- return;
5005
+ if (section.read_only) return;
7000
5006
  let format3 = "md";
7001
5007
  if (section.new_doc_ext) {
7002
5008
  const ext = checkExt(section.new_doc_ext);
@@ -7063,12 +5069,14 @@ var generateCollectionFromForestrySection = (args) => {
7063
5069
  if (((forestryTemplates == null ? void 0 : forestryTemplates.length) || 0) > 1) {
7064
5070
  c = {
7065
5071
  ...baseCollection,
5072
+ // @ts-expect-error
7066
5073
  templates: forestryTemplates.map((tem) => {
7067
5074
  const currentTemplate = templateMap.get(tem);
7068
5075
  const fieldsString = stringifyLabelWithField(
7069
5076
  currentTemplate.templateObj.label
7070
5077
  );
7071
5078
  return {
5079
+ // fields: [BODY_FIELD],
7072
5080
  fields: makeFieldsWithInternalCode({
7073
5081
  hasBody,
7074
5082
  field: fieldsString,
@@ -7086,6 +5094,8 @@ var generateCollectionFromForestrySection = (args) => {
7086
5094
  const fieldsString = stringifyLabelWithField(template.templateObj.label);
7087
5095
  c = {
7088
5096
  ...baseCollection,
5097
+ // fields: [BODY_FIELD],
5098
+ // @ts-expect-error
7089
5099
  fields: makeFieldsWithInternalCode({
7090
5100
  field: fieldsString,
7091
5101
  hasBody,
@@ -7117,9 +5127,9 @@ var generateCollectionFromForestrySection = (args) => {
7117
5127
  return c;
7118
5128
  } else if (section.type === "document") {
7119
5129
  const filePath = section.path;
7120
- const extname = import_path10.default.extname(filePath);
7121
- const fileName = import_path10.default.basename(filePath, extname);
7122
- const dir = import_path10.default.dirname(filePath);
5130
+ const extname = import_path9.default.extname(filePath);
5131
+ const fileName = import_path9.default.basename(filePath, extname);
5132
+ const dir = import_path9.default.dirname(filePath);
7123
5133
  const ext = checkExt(extname);
7124
5134
  if (ext) {
7125
5135
  const fields = [];
@@ -7182,7 +5192,7 @@ var generateCollections = async ({
7182
5192
  usingTypescript
7183
5193
  });
7184
5194
  const forestryConfig = await import_fs_extra10.default.readFile(
7185
- import_path10.default.join(pathToForestryConfig, ".forestry", "settings.yml")
5195
+ import_path9.default.join(pathToForestryConfig, ".forestry", "settings.yml")
7186
5196
  );
7187
5197
  rewriteTemplateKeysInDocs({
7188
5198
  templateMap,
@@ -7213,11 +5223,11 @@ var rewriteTemplateKeysInDocs = (args) => {
7213
5223
  const { templateObj } = templateMap.get(templateKey);
7214
5224
  (_a = templateObj == null ? void 0 : templateObj.pages) == null ? void 0 : _a.forEach((page) => {
7215
5225
  try {
7216
- const filePath = import_path10.default.join(page);
5226
+ const filePath = import_path9.default.join(page);
7217
5227
  if (import_fs_extra10.default.lstatSync(filePath).isDirectory()) {
7218
5228
  return;
7219
5229
  }
7220
- const extname = import_path10.default.extname(filePath);
5230
+ const extname = import_path9.default.extname(filePath);
7221
5231
  const fileContent = import_fs_extra10.default.readFileSync(filePath).toString();
7222
5232
  const content = (0, import_graphql16.parseFile)(
7223
5233
  fileContent,
@@ -7249,7 +5259,7 @@ var import_fs_extra13 = __toESM(require("fs-extra"));
7249
5259
  // src/next/commands/codemod-command/index.ts
7250
5260
  var import_clipanion5 = require("clipanion");
7251
5261
  var import_fs_extra11 = __toESM(require("fs-extra"));
7252
- var import_path11 = __toESM(require("path"));
5262
+ var import_path10 = __toESM(require("path"));
7253
5263
  var CodemodCommand = class extends import_clipanion5.Command {
7254
5264
  constructor() {
7255
5265
  super(...arguments);
@@ -7293,7 +5303,7 @@ var moveTinaFolder = async (rootPath = process.cwd()) => {
7293
5303
  logger.error(e.message);
7294
5304
  process.exit(1);
7295
5305
  }
7296
- const tinaDestination = import_path11.default.join(configManager.rootPath, "tina");
5306
+ const tinaDestination = import_path10.default.join(configManager.rootPath, "tina");
7297
5307
  if (await import_fs_extra11.default.existsSync(tinaDestination)) {
7298
5308
  logger.info(
7299
5309
  `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.`
@@ -7308,7 +5318,7 @@ var moveTinaFolder = async (rootPath = process.cwd()) => {
7308
5318
  };
7309
5319
  var writeGitignore = async (rootPath) => {
7310
5320
  await import_fs_extra11.default.outputFileSync(
7311
- import_path11.default.join(rootPath, "tina", ".gitignore"),
5321
+ import_path10.default.join(rootPath, "tina", ".gitignore"),
7312
5322
  "__generated__"
7313
5323
  );
7314
5324
  };
@@ -7833,6 +5843,7 @@ var makeImportsVisitor = (sourceFile, importMap) => (ctx) => (node) => {
7833
5843
  ) : [];
7834
5844
  const newImports = [
7835
5845
  .../* @__PURE__ */ new Set([
5846
+ // we use Set to remove duplicates
7836
5847
  ...existingImports,
7837
5848
  ...imports
7838
5849
  ])
@@ -7987,10 +5998,14 @@ var addSelfHostedTinaAuthToConfig = async (config2, configFile) => {
7987
5998
  );
7988
5999
  const { configImports, configAuthProviderClass, extraTinaCollections } = config2.authProvider;
7989
6000
  const importMap = {
7990
- ...configImports.reduce((acc, { from, imported }) => {
7991
- acc[from] = imported;
7992
- return acc;
7993
- }, {})
6001
+ // iterate over configImports and add them to the import map
6002
+ ...configImports.reduce(
6003
+ (acc, { from, imported }) => {
6004
+ acc[from] = imported;
6005
+ return acc;
6006
+ },
6007
+ {}
6008
+ )
7994
6009
  };
7995
6010
  const transformedSourceFileResult = import_typescript3.default.transform(
7996
6011
  sourceFile,
@@ -8146,8 +6161,8 @@ async function apply({
8146
6161
  await addConfigFile({
8147
6162
  configArgs: {
8148
6163
  config: config2,
8149
- publicFolder: import_path12.default.join(
8150
- import_path12.default.relative(process.cwd(), pathToForestryConfig),
6164
+ publicFolder: import_path11.default.join(
6165
+ import_path11.default.relative(process.cwd(), pathToForestryConfig),
8151
6166
  config2.publicFolder
8152
6167
  ),
8153
6168
  collections,
@@ -8161,7 +6176,13 @@ async function apply({
8161
6176
  config: config2
8162
6177
  });
8163
6178
  }
8164
- if (env.tinaConfigExists && params.isBackendInit && config2.hosting === "self-host" && (((_a = config2.authProvider) == null ? void 0 : _a.name) || "") !== "tina-cloud") {
6179
+ if (
6180
+ // if the config was just generated we do not need to update the config file because it will be generated correctly
6181
+ env.tinaConfigExists && // Are we running tinacms init backend
6182
+ params.isBackendInit && // Do the user choose the 'self-host' option
6183
+ config2.hosting === "self-host" && // the user did not choose the 'tina-cloud' auth provider
6184
+ (((_a = config2.authProvider) == null ? void 0 : _a.name) || "") !== "tina-cloud"
6185
+ ) {
8165
6186
  await addSelfHostedTinaAuthToConfig(config2, env.generatedFiles["config"]);
8166
6187
  }
8167
6188
  logNextSteps({
@@ -8214,18 +6235,18 @@ var createPackageJSON = async () => {
8214
6235
  };
8215
6236
  var createGitignore = async ({ baseDir }) => {
8216
6237
  logger.info(logText("No .gitignore found, creating one"));
8217
- import_fs_extra13.default.outputFileSync(import_path12.default.join(baseDir, ".gitignore"), "node_modules");
6238
+ import_fs_extra13.default.outputFileSync(import_path11.default.join(baseDir, ".gitignore"), "node_modules");
8218
6239
  };
8219
6240
  var updateGitIgnore = async ({
8220
6241
  baseDir,
8221
6242
  items
8222
6243
  }) => {
8223
6244
  logger.info(logText(`Adding ${items.join(",")} to .gitignore`));
8224
- const gitignoreContent = import_fs_extra13.default.readFileSync(import_path12.default.join(baseDir, ".gitignore")).toString();
6245
+ const gitignoreContent = import_fs_extra13.default.readFileSync(import_path11.default.join(baseDir, ".gitignore")).toString();
8225
6246
  const newGitignoreContent = [...gitignoreContent.split("\n"), ...items].join(
8226
6247
  "\n"
8227
6248
  );
8228
- await import_fs_extra13.default.writeFile(import_path12.default.join(baseDir, ".gitignore"), newGitignoreContent);
6249
+ await import_fs_extra13.default.writeFile(import_path11.default.join(baseDir, ".gitignore"), newGitignoreContent);
8229
6250
  };
8230
6251
  var addDependencies = async (config2, env, params) => {
8231
6252
  var _a, _b, _c, _d, _e, _f, _g, _h, _i;
@@ -8295,22 +6316,22 @@ var writeGeneratedFile = async ({
8295
6316
  content,
8296
6317
  typescript
8297
6318
  }) => {
8298
- const { exists, path: path15, parentPath } = generatedFile.resolve(typescript);
6319
+ const { exists, path: path14, parentPath } = generatedFile.resolve(typescript);
8299
6320
  if (exists) {
8300
6321
  if (overwrite) {
8301
- logger.info(`Overwriting file at ${path15}... \u2705`);
8302
- import_fs_extra13.default.outputFileSync(path15, content);
6322
+ logger.info(`Overwriting file at ${path14}... \u2705`);
6323
+ import_fs_extra13.default.outputFileSync(path14, content);
8303
6324
  } else {
8304
- logger.info(`Not overwriting file at ${path15}.`);
6325
+ logger.info(`Not overwriting file at ${path14}.`);
8305
6326
  logger.info(
8306
- logText(`Please add the following to ${path15}:
6327
+ logText(`Please add the following to ${path14}:
8307
6328
  ${indentText(content)}}`)
8308
6329
  );
8309
6330
  }
8310
6331
  } else {
8311
- logger.info(`Adding file at ${path15}... \u2705`);
6332
+ logger.info(`Adding file at ${path14}... \u2705`);
8312
6333
  await import_fs_extra13.default.ensureDir(parentPath);
8313
- import_fs_extra13.default.outputFileSync(path15, content);
6334
+ import_fs_extra13.default.outputFileSync(path14, content);
8314
6335
  }
8315
6336
  };
8316
6337
  var addConfigFile = async ({
@@ -8393,7 +6414,7 @@ var addContentFile = async ({
8393
6414
  return () => ({
8394
6415
  exists: env.sampleContentExists,
8395
6416
  path: env.sampleContentPath,
8396
- parentPath: import_path12.default.dirname(env.sampleContentPath)
6417
+ parentPath: import_path11.default.dirname(env.sampleContentPath)
8397
6418
  });
8398
6419
  }
8399
6420
  },
@@ -8416,7 +6437,7 @@ ${titleText(" TinaCMS ")} backend initialized!`));
8416
6437
  return `${x.key}=${x.value || "***"}`;
8417
6438
  }).join("\n") + `
8418
6439
  TINA_PUBLIC_IS_LOCAL=true`;
8419
- const envFile = import_path12.default.join(process.cwd(), ".env");
6440
+ const envFile = import_path11.default.join(process.cwd(), ".env");
8420
6441
  if (!import_fs_extra13.default.existsSync(envFile)) {
8421
6442
  logger.info(`Adding .env file to your project... \u2705`);
8422
6443
  import_fs_extra13.default.writeFileSync(envFile, envFileText);
@@ -8439,6 +6460,13 @@ ${titleText(" TinaCMS ")} has been initialized!`));
8439
6460
  logger.info(
8440
6461
  "To get started run: " + cmdText(frameworkDevCmds[framework.name]({ packageManager }))
8441
6462
  );
6463
+ if (framework.name === "hugo") {
6464
+ logger.info(
6465
+ focusText("Hugo is required. "),
6466
+ "Don't have Hugo installed? Follow this guide to set it up: ",
6467
+ linkText("https://gohugo.io/installation/")
6468
+ );
6469
+ }
8442
6470
  logger.info(
8443
6471
  "To get your site production ready, run: " + cmdText(`tinacms init backend`)
8444
6472
  );
@@ -8454,6 +6482,7 @@ var other = ({ packageManager }) => {
8454
6482
  const packageManagers = {
8455
6483
  pnpm: `pnpm`,
8456
6484
  npm: `npx`,
6485
+ // npx is the way to run executables that aren't in your "scripts"
8457
6486
  yarn: `yarn`
8458
6487
  };
8459
6488
  return `${packageManagers[packageManager]} tinacms dev -c "<your dev command>"`;
@@ -8466,6 +6495,7 @@ var frameworkDevCmds = {
8466
6495
  const packageManagers = {
8467
6496
  pnpm: `pnpm`,
8468
6497
  npm: `npm run`,
6498
+ // npx is the way to run executables that aren't in your "scripts"
8469
6499
  yarn: `yarn`
8470
6500
  };
8471
6501
  return `${packageManagers[packageManager]} dev`;
@@ -8480,7 +6510,7 @@ var addReactiveFile = {
8480
6510
  dataLayer
8481
6511
  }) => {
8482
6512
  var _a, _b;
8483
- const packageJsonPath = import_path12.default.join(baseDir, "package.json");
6513
+ const packageJsonPath = import_path11.default.join(baseDir, "package.json");
8484
6514
  await writeGeneratedFile({
8485
6515
  generatedFile,
8486
6516
  typescript: config2.typescript,
@@ -8722,6 +6752,4 @@ cli.register(SearchIndexCommand);
8722
6752
  cli.register(import_clipanion8.Builtins.DefinitionsCommand);
8723
6753
  cli.register(import_clipanion8.Builtins.HelpCommand);
8724
6754
  cli.register(import_clipanion8.Builtins.VersionCommand);
8725
- var src_default = cli;
8726
- // Annotate the CommonJS export names for ESM import in node:
8727
- 0 && (module.exports = {});
6755
+ var index_default = cli;