@tinacms/cli 0.0.0-b60b14f-20241030173304 → 0.0.0-b720fb9-20241203044105
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/cmds/forestry-migrate/util/index.d.ts +4 -4
- package/dist/index.js +851 -816
- package/dist/next/vite/index.d.ts +13 -2
- package/dist/server/server.d.ts +1 -1
- package/package.json +13 -14
package/dist/index.js
CHANGED
|
@@ -31,7 +31,7 @@ module.exports = __toCommonJS(src_exports);
|
|
|
31
31
|
var import_clipanion8 = require("clipanion");
|
|
32
32
|
|
|
33
33
|
// package.json
|
|
34
|
-
var version = "1.6.
|
|
34
|
+
var version = "1.6.12";
|
|
35
35
|
|
|
36
36
|
// src/next/commands/dev-command/index.ts
|
|
37
37
|
var import_clipanion2 = require("clipanion");
|
|
@@ -41,582 +41,20 @@ var import_chokidar = __toESM(require("chokidar"));
|
|
|
41
41
|
var import_graphql10 = require("@tinacms/graphql");
|
|
42
42
|
|
|
43
43
|
// src/next/config-manager.ts
|
|
44
|
-
var
|
|
44
|
+
var import_fs_extra2 = __toESM(require("fs-extra"));
|
|
45
45
|
var import_path = __toESM(require("path"));
|
|
46
46
|
var import_os = __toESM(require("os"));
|
|
47
47
|
var esbuild = __toESM(require("esbuild"));
|
|
48
48
|
var dotenv = __toESM(require("dotenv"));
|
|
49
|
-
var
|
|
49
|
+
var import_normalize_path2 = __toESM(require("normalize-path"));
|
|
50
50
|
var import_chalk2 = __toESM(require("chalk"));
|
|
51
51
|
|
|
52
|
-
// src/
|
|
53
|
-
var
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
return process.env.TERM !== "linux";
|
|
59
|
-
}
|
|
60
|
-
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";
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
// src/logger/index.ts
|
|
64
|
-
var import_log4js = __toESM(require("log4js"));
|
|
65
|
-
var logger = import_log4js.default.getLogger();
|
|
66
|
-
import_log4js.default.configure({
|
|
67
|
-
appenders: {
|
|
68
|
-
out: { type: "stdout", layout: { type: "messagePassThrough" } }
|
|
69
|
-
},
|
|
70
|
-
categories: { default: { appenders: ["out"], level: "info" } }
|
|
71
|
-
});
|
|
72
|
-
logger.level = "info";
|
|
73
|
-
function ansiRegex() {
|
|
74
|
-
const pattern = [
|
|
75
|
-
"[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)",
|
|
76
|
-
"(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"
|
|
77
|
-
].join("|");
|
|
78
|
-
return new RegExp(pattern, "g");
|
|
79
|
-
}
|
|
80
|
-
var bar = "\u2502";
|
|
81
|
-
var strip = (str) => str.replace(ansiRegex(), "");
|
|
82
|
-
var note = (message = "", title = "") => {
|
|
83
|
-
const lines = `
|
|
84
|
-
${message}
|
|
85
|
-
`.split("\n");
|
|
86
|
-
const len = lines.reduce((sum, ln) => {
|
|
87
|
-
ln = strip(ln);
|
|
88
|
-
return ln.length > sum ? ln.length : sum;
|
|
89
|
-
}, 0) + 2;
|
|
90
|
-
const msg = lines.map(
|
|
91
|
-
(ln) => `${import_chalk.default.gray(bar)} ${import_chalk.default.white(ln)}${" ".repeat(
|
|
92
|
-
len - strip(ln).length
|
|
93
|
-
)}${import_chalk.default.gray(bar)}`
|
|
94
|
-
).join("\n");
|
|
95
|
-
const underscoreLen = len - title.length - 1 > 0 ? len - title.length - 1 : 0;
|
|
96
|
-
process.stdout.write(
|
|
97
|
-
`${import_chalk.default.gray(bar)}
|
|
98
|
-
${import_chalk.default.green("\u25CB")} ${import_chalk.default.reset(
|
|
99
|
-
title
|
|
100
|
-
)} ${import_chalk.default.gray("\u2500".repeat(underscoreLen) + "\u256E")}
|
|
101
|
-
${msg}
|
|
102
|
-
${import_chalk.default.gray(
|
|
103
|
-
"\u251C" + "\u2500".repeat(len + 2) + "\u256F"
|
|
104
|
-
)}
|
|
105
|
-
`
|
|
106
|
-
);
|
|
107
|
-
};
|
|
108
|
-
var summary = (content) => {
|
|
109
|
-
const outString = [];
|
|
110
|
-
let longestKey = 0;
|
|
111
|
-
content.items.forEach((item) => {
|
|
112
|
-
item.subItems.forEach((subItem) => {
|
|
113
|
-
if (subItem.key.length > longestKey) {
|
|
114
|
-
longestKey = subItem.key.length;
|
|
115
|
-
}
|
|
116
|
-
});
|
|
117
|
-
});
|
|
118
|
-
content.items.forEach((item) => {
|
|
119
|
-
outString.push(`${item.emoji} ${import_chalk.default.cyan(item.heading)}`);
|
|
120
|
-
item.subItems.forEach((subItem) => {
|
|
121
|
-
const spaces = longestKey - subItem.key.length + 4;
|
|
122
|
-
outString.push(
|
|
123
|
-
` ${subItem.key}:${[...Array(spaces)].join(" ")}${import_chalk.default.cyan(
|
|
124
|
-
subItem.value
|
|
125
|
-
)}`
|
|
126
|
-
);
|
|
127
|
-
});
|
|
128
|
-
outString.push(``);
|
|
129
|
-
});
|
|
130
|
-
if (process.env.CI) {
|
|
131
|
-
logger.info(JSON.stringify(content, null, 2));
|
|
132
|
-
} else {
|
|
133
|
-
note(outString.join("\n"), content.heading);
|
|
134
|
-
}
|
|
135
|
-
};
|
|
136
|
-
var unicode = isUnicodeSupported();
|
|
137
|
-
var s = (c, fallback) => unicode ? c : fallback;
|
|
138
|
-
var S_STEP_ACTIVE = s("\u25C6", "*");
|
|
139
|
-
var S_STEP_CANCEL = s("\u25A0", "x");
|
|
140
|
-
var S_STEP_ERROR = s("\u25B2", "x");
|
|
141
|
-
var S_STEP_SUBMIT = s("\u25C7", "o");
|
|
142
|
-
var S_BAR_START = s("\u250C", "T");
|
|
143
|
-
var S_BAR = s("\u2502", "|");
|
|
144
|
-
var S_BAR_END = s("\u2514", "\u2014");
|
|
145
|
-
var S_RADIO_ACTIVE = s("\u25CF", ">");
|
|
146
|
-
var S_RADIO_INACTIVE = s("\u25CB", " ");
|
|
147
|
-
var S_CHECKBOX_ACTIVE = s("\u25FB", "[\u2022]");
|
|
148
|
-
var S_CHECKBOX_SELECTED = s("\u25FC", "[+]");
|
|
149
|
-
var S_CHECKBOX_INACTIVE = s("\u25FB", "[ ]");
|
|
150
|
-
var S_PASSWORD_MASK = s("\u25AA", "\u2022");
|
|
151
|
-
var S_BAR_H = s("\u2500", "-");
|
|
152
|
-
var S_CORNER_TOP_RIGHT = s("\u256E", "+");
|
|
153
|
-
var S_CONNECT_LEFT = s("\u251C", "+");
|
|
154
|
-
var S_CORNER_BOTTOM_RIGHT = s("\u256F", "+");
|
|
155
|
-
var S_INFO = s("\u25CF", "\u2022");
|
|
156
|
-
var S_SUCCESS = s("\u25C6", "*");
|
|
157
|
-
var S_WARN = s("\u25B2", "!");
|
|
158
|
-
var S_ERROR = s("\u25A0", "x");
|
|
159
|
-
|
|
160
|
-
// src/next/config-manager.ts
|
|
161
|
-
var TINA_FOLDER = "tina";
|
|
162
|
-
var LEGACY_TINA_FOLDER = ".tina";
|
|
163
|
-
var GENERATED_FOLDER = "__generated__";
|
|
164
|
-
var GRAPHQL_JSON_FILE = "_graphql.json";
|
|
165
|
-
var GRAPHQL_GQL_FILE = "schema.gql";
|
|
166
|
-
var SCHEMA_JSON_FILE = "_schema.json";
|
|
167
|
-
var LOOKUP_JSON_FILE = "_lookup.json";
|
|
168
|
-
var ConfigManager = class {
|
|
169
|
-
constructor({
|
|
170
|
-
rootPath = process.cwd(),
|
|
171
|
-
tinaGraphQLVersion,
|
|
172
|
-
legacyNoSDK
|
|
173
|
-
}) {
|
|
174
|
-
this.rootPath = (0, import_normalize_path.default)(rootPath);
|
|
175
|
-
this.tinaGraphQLVersionFromCLI = tinaGraphQLVersion;
|
|
176
|
-
this.legacyNoSDK = legacyNoSDK;
|
|
177
|
-
}
|
|
178
|
-
isUsingTs() {
|
|
179
|
-
return [".ts", ".tsx"].includes(import_path.default.extname(this.tinaConfigFilePath));
|
|
180
|
-
}
|
|
181
|
-
hasSelfHostedConfig() {
|
|
182
|
-
return !!this.selfHostedDatabaseFilePath;
|
|
183
|
-
}
|
|
184
|
-
hasSeparateContentRoot() {
|
|
185
|
-
return this.rootPath !== this.contentRootPath;
|
|
186
|
-
}
|
|
187
|
-
shouldSkipSDK() {
|
|
188
|
-
var _a;
|
|
189
|
-
if (this.legacyNoSDK) {
|
|
190
|
-
return this.legacyNoSDK;
|
|
191
|
-
}
|
|
192
|
-
return ((_a = this.config.client) == null ? void 0 : _a.skip) || false;
|
|
193
|
-
}
|
|
194
|
-
async processConfig() {
|
|
195
|
-
this.tinaFolderPath = await this.getTinaFolderPath(this.rootPath);
|
|
196
|
-
this.envFilePath = import_path.default.resolve(
|
|
197
|
-
import_path.default.join(this.tinaFolderPath, "..", ".env")
|
|
198
|
-
);
|
|
199
|
-
dotenv.config({ path: this.envFilePath });
|
|
200
|
-
this.tinaConfigFilePath = await this.getPathWithExtension(
|
|
201
|
-
import_path.default.join(this.tinaFolderPath, "config")
|
|
202
|
-
);
|
|
203
|
-
if (!this.tinaConfigFilePath) {
|
|
204
|
-
throw new Error(
|
|
205
|
-
`Unable to find config file in ${this.tinaFolderPath}. Looking for a file named "config.{ts,tsx,js,jsx}"`
|
|
206
|
-
);
|
|
207
|
-
}
|
|
208
|
-
this.selfHostedDatabaseFilePath = await this.getPathWithExtension(
|
|
209
|
-
import_path.default.join(this.tinaFolderPath, "database")
|
|
210
|
-
);
|
|
211
|
-
this.generatedFolderPath = import_path.default.join(this.tinaFolderPath, GENERATED_FOLDER);
|
|
212
|
-
this.generatedCachePath = import_path.default.join(
|
|
213
|
-
this.generatedFolderPath,
|
|
214
|
-
".cache",
|
|
215
|
-
String(new Date().getTime())
|
|
216
|
-
);
|
|
217
|
-
this.generatedGraphQLGQLPath = import_path.default.join(
|
|
218
|
-
this.generatedFolderPath,
|
|
219
|
-
GRAPHQL_GQL_FILE
|
|
220
|
-
);
|
|
221
|
-
this.generatedGraphQLJSONPath = import_path.default.join(
|
|
222
|
-
this.generatedFolderPath,
|
|
223
|
-
GRAPHQL_JSON_FILE
|
|
224
|
-
);
|
|
225
|
-
this.generatedSchemaJSONPath = import_path.default.join(
|
|
226
|
-
this.generatedFolderPath,
|
|
227
|
-
SCHEMA_JSON_FILE
|
|
228
|
-
);
|
|
229
|
-
this.generatedLookupJSONPath = import_path.default.join(
|
|
230
|
-
this.generatedFolderPath,
|
|
231
|
-
LOOKUP_JSON_FILE
|
|
232
|
-
);
|
|
233
|
-
this.generatedQueriesFilePath = import_path.default.join(
|
|
234
|
-
this.generatedFolderPath,
|
|
235
|
-
"queries.gql"
|
|
236
|
-
);
|
|
237
|
-
this.generatedFragmentsFilePath = import_path.default.join(
|
|
238
|
-
this.generatedFolderPath,
|
|
239
|
-
"frags.gql"
|
|
240
|
-
);
|
|
241
|
-
this.generatedTypesTSFilePath = import_path.default.join(
|
|
242
|
-
this.generatedFolderPath,
|
|
243
|
-
"types.ts"
|
|
244
|
-
);
|
|
245
|
-
this.generatedTypesJSFilePath = import_path.default.join(
|
|
246
|
-
this.generatedFolderPath,
|
|
247
|
-
"types.js"
|
|
248
|
-
);
|
|
249
|
-
this.generatedTypesDFilePath = import_path.default.join(
|
|
250
|
-
this.generatedFolderPath,
|
|
251
|
-
"types.d.ts"
|
|
252
|
-
);
|
|
253
|
-
this.userQueriesAndFragmentsGlob = import_path.default.join(
|
|
254
|
-
this.tinaFolderPath,
|
|
255
|
-
"queries/**/*.{graphql,gql}"
|
|
256
|
-
);
|
|
257
|
-
this.generatedQueriesAndFragmentsGlob = import_path.default.join(
|
|
258
|
-
this.generatedFolderPath,
|
|
259
|
-
"*.{graphql,gql}"
|
|
260
|
-
);
|
|
261
|
-
this.generatedClientTSFilePath = import_path.default.join(
|
|
262
|
-
this.generatedFolderPath,
|
|
263
|
-
"client.ts"
|
|
264
|
-
);
|
|
265
|
-
this.generatedClientJSFilePath = import_path.default.join(
|
|
266
|
-
this.generatedFolderPath,
|
|
267
|
-
"client.js"
|
|
268
|
-
);
|
|
269
|
-
this.generatedClientDFilePath = import_path.default.join(
|
|
270
|
-
this.generatedFolderPath,
|
|
271
|
-
"client.d.ts"
|
|
272
|
-
);
|
|
273
|
-
this.generatedDatabaseClientDFilePath = import_path.default.join(
|
|
274
|
-
this.generatedFolderPath,
|
|
275
|
-
"databaseClient.d.ts"
|
|
276
|
-
);
|
|
277
|
-
this.generatedDatabaseClientTSFilePath = import_path.default.join(
|
|
278
|
-
this.generatedFolderPath,
|
|
279
|
-
"databaseClient.ts"
|
|
280
|
-
);
|
|
281
|
-
this.generatedDatabaseClientJSFilePath = import_path.default.join(
|
|
282
|
-
this.generatedFolderPath,
|
|
283
|
-
"databaseClient.js"
|
|
284
|
-
);
|
|
285
|
-
const clientExists = this.isUsingTs() ? await import_fs_extra.default.pathExists(this.generatedClientTSFilePath) : await import_fs_extra.default.pathExists(this.generatedClientJSFilePath);
|
|
286
|
-
if (!clientExists) {
|
|
287
|
-
const file = "export default ()=>({})\nexport const client = ()=>({})";
|
|
288
|
-
if (this.isUsingTs()) {
|
|
289
|
-
await import_fs_extra.default.outputFile(this.generatedClientTSFilePath, file);
|
|
290
|
-
} else {
|
|
291
|
-
await import_fs_extra.default.outputFile(this.generatedClientJSFilePath, file);
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
const { config: config2, prebuildPath, watchList } = await this.loadConfigFile(
|
|
295
|
-
this.generatedFolderPath,
|
|
296
|
-
this.tinaConfigFilePath
|
|
297
|
-
);
|
|
298
|
-
this.watchList = watchList;
|
|
299
|
-
this.config = config2;
|
|
300
|
-
this.prebuildFilePath = prebuildPath;
|
|
301
|
-
this.publicFolderPath = import_path.default.join(
|
|
302
|
-
this.rootPath,
|
|
303
|
-
this.config.build.publicFolder
|
|
304
|
-
);
|
|
305
|
-
this.outputFolderPath = import_path.default.join(
|
|
306
|
-
this.publicFolderPath,
|
|
307
|
-
this.config.build.outputFolder
|
|
308
|
-
);
|
|
309
|
-
this.outputHTMLFilePath = import_path.default.join(this.outputFolderPath, "index.html");
|
|
310
|
-
this.outputGitignorePath = import_path.default.join(this.outputFolderPath, ".gitignore");
|
|
311
|
-
const fullLocalContentPath = import_path.default.join(
|
|
312
|
-
this.tinaFolderPath,
|
|
313
|
-
this.config.localContentPath || ""
|
|
314
|
-
);
|
|
315
|
-
if (this.config.localContentPath) {
|
|
316
|
-
const localContentPathExists = await import_fs_extra.default.pathExists(fullLocalContentPath);
|
|
317
|
-
if (localContentPathExists) {
|
|
318
|
-
logger.info(`Using separate content repo at ${fullLocalContentPath}`);
|
|
319
|
-
this.contentRootPath = fullLocalContentPath;
|
|
320
|
-
} else {
|
|
321
|
-
logger.warn(
|
|
322
|
-
`${import_chalk2.default.yellow("Warning:")} The localContentPath ${import_chalk2.default.cyan(
|
|
323
|
-
fullLocalContentPath
|
|
324
|
-
)} does not exist. Please create it or remove the localContentPath from your config file at ${import_chalk2.default.cyan(
|
|
325
|
-
this.tinaConfigFilePath
|
|
326
|
-
)}`
|
|
327
|
-
);
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
if (!this.contentRootPath) {
|
|
331
|
-
this.contentRootPath = this.rootPath;
|
|
332
|
-
}
|
|
333
|
-
this.generatedFolderPathContentRepo = import_path.default.join(
|
|
334
|
-
await this.getTinaFolderPath(this.contentRootPath),
|
|
335
|
-
GENERATED_FOLDER
|
|
336
|
-
);
|
|
337
|
-
this.spaMainPath = require.resolve("@tinacms/app");
|
|
338
|
-
this.spaRootPath = import_path.default.join(this.spaMainPath, "..", "..");
|
|
339
|
-
}
|
|
340
|
-
async getTinaFolderPath(rootPath) {
|
|
341
|
-
const tinaFolderPath = import_path.default.join(rootPath, TINA_FOLDER);
|
|
342
|
-
const tinaFolderExists = await import_fs_extra.default.pathExists(tinaFolderPath);
|
|
343
|
-
if (tinaFolderExists) {
|
|
344
|
-
this.isUsingLegacyFolder = false;
|
|
345
|
-
return tinaFolderPath;
|
|
346
|
-
}
|
|
347
|
-
const legacyFolderPath = import_path.default.join(rootPath, LEGACY_TINA_FOLDER);
|
|
348
|
-
const legacyFolderExists = await import_fs_extra.default.pathExists(legacyFolderPath);
|
|
349
|
-
if (legacyFolderExists) {
|
|
350
|
-
this.isUsingLegacyFolder = true;
|
|
351
|
-
return legacyFolderPath;
|
|
352
|
-
}
|
|
353
|
-
throw new Error(
|
|
354
|
-
`Unable to find Tina folder, if you're working in folder outside of the Tina config be sure to specify --rootPath`
|
|
355
|
-
);
|
|
356
|
-
}
|
|
357
|
-
getTinaGraphQLVersion() {
|
|
358
|
-
var _a, _b;
|
|
359
|
-
if (this.tinaGraphQLVersionFromCLI) {
|
|
360
|
-
return this.tinaGraphQLVersionFromCLI;
|
|
361
|
-
}
|
|
362
|
-
const generatedSchema = import_fs_extra.default.readJSONSync(this.generatedSchemaJSONPath);
|
|
363
|
-
if (!generatedSchema || !(typeof (generatedSchema == null ? void 0 : generatedSchema.version) !== "undefined") || !(typeof ((_a = generatedSchema == null ? void 0 : generatedSchema.version) == null ? void 0 : _a.major) === "string") || !(typeof ((_b = generatedSchema == null ? void 0 : generatedSchema.version) == null ? void 0 : _b.minor) === "string")) {
|
|
364
|
-
throw new Error(
|
|
365
|
-
`Can not find Tina GraphQL version in ${this.generatedSchemaJSONPath}`
|
|
366
|
-
);
|
|
367
|
-
}
|
|
368
|
-
return `${generatedSchema.version.major}.${generatedSchema.version.minor}`;
|
|
369
|
-
}
|
|
370
|
-
printGeneratedClientFilePath() {
|
|
371
|
-
if (this.isUsingTs()) {
|
|
372
|
-
return this.generatedClientTSFilePath.replace(`${this.rootPath}/`, "");
|
|
373
|
-
}
|
|
374
|
-
return this.generatedClientJSFilePath.replace(`${this.rootPath}/`, "");
|
|
375
|
-
}
|
|
376
|
-
printGeneratedTypesFilePath() {
|
|
377
|
-
return this.generatedTypesTSFilePath.replace(`${this.rootPath}/`, "");
|
|
378
|
-
}
|
|
379
|
-
printoutputHTMLFilePath() {
|
|
380
|
-
return this.outputHTMLFilePath.replace(`${this.publicFolderPath}/`, "");
|
|
381
|
-
}
|
|
382
|
-
printRelativePath(filename) {
|
|
383
|
-
if (filename) {
|
|
384
|
-
return filename.replace(/\\/g, "/").replace(`${this.rootPath}/`, "");
|
|
385
|
-
}
|
|
386
|
-
throw `No path provided to print`;
|
|
387
|
-
}
|
|
388
|
-
printPrebuildFilePath() {
|
|
389
|
-
return this.prebuildFilePath.replace(/\\/g, "/").replace(`${this.rootPath}/${this.tinaFolderPath}/`, "");
|
|
390
|
-
}
|
|
391
|
-
printContentRelativePath(filename) {
|
|
392
|
-
if (filename) {
|
|
393
|
-
return filename.replace(/\\/g, "/").replace(`${this.contentRootPath}/`, "");
|
|
394
|
-
}
|
|
395
|
-
throw `No path provided to print`;
|
|
396
|
-
}
|
|
397
|
-
async getPathWithExtension(filepath) {
|
|
398
|
-
const extensions = ["tsx", "ts", "jsx", "js"];
|
|
399
|
-
let result;
|
|
400
|
-
await Promise.all(
|
|
401
|
-
extensions.map(async (ext) => {
|
|
402
|
-
if (result) {
|
|
403
|
-
return;
|
|
404
|
-
}
|
|
405
|
-
const filepathWithExtension = `${filepath}.${ext}`;
|
|
406
|
-
const exists = import_fs_extra.default.existsSync(filepathWithExtension);
|
|
407
|
-
if (exists) {
|
|
408
|
-
result = filepathWithExtension;
|
|
409
|
-
}
|
|
410
|
-
})
|
|
411
|
-
);
|
|
412
|
-
return result;
|
|
413
|
-
}
|
|
414
|
-
async loadDatabaseFile() {
|
|
415
|
-
const tmpdir = import_path.default.join(import_os.default.tmpdir(), Date.now().toString());
|
|
416
|
-
const outfile = import_path.default.join(tmpdir, "database.build.js");
|
|
417
|
-
await esbuild.build({
|
|
418
|
-
entryPoints: [this.selfHostedDatabaseFilePath],
|
|
419
|
-
bundle: true,
|
|
420
|
-
platform: "node",
|
|
421
|
-
outfile,
|
|
422
|
-
loader: loaders
|
|
423
|
-
});
|
|
424
|
-
const result = require(outfile);
|
|
425
|
-
import_fs_extra.default.removeSync(outfile);
|
|
426
|
-
return result.default;
|
|
427
|
-
}
|
|
428
|
-
async loadConfigFile(generatedFolderPath, configFilePath) {
|
|
429
|
-
const tmpdir = import_path.default.join(import_os.default.tmpdir(), Date.now().toString());
|
|
430
|
-
const prebuild = import_path.default.join(this.generatedFolderPath, "config.prebuild.jsx");
|
|
431
|
-
const outfile = import_path.default.join(tmpdir, "config.build.jsx");
|
|
432
|
-
const outfile2 = import_path.default.join(tmpdir, "config.build.js");
|
|
433
|
-
const tempTSConfigFile = import_path.default.join(tmpdir, "tsconfig.json");
|
|
434
|
-
import_fs_extra.default.outputFileSync(tempTSConfigFile, "{}");
|
|
435
|
-
const result2 = await esbuild.build({
|
|
436
|
-
entryPoints: [configFilePath],
|
|
437
|
-
bundle: true,
|
|
438
|
-
target: ["es2020"],
|
|
439
|
-
platform: "browser",
|
|
440
|
-
format: "esm",
|
|
441
|
-
logLevel: "silent",
|
|
442
|
-
packages: "external",
|
|
443
|
-
ignoreAnnotations: true,
|
|
444
|
-
outfile: prebuild,
|
|
445
|
-
loader: loaders,
|
|
446
|
-
metafile: true
|
|
447
|
-
});
|
|
448
|
-
const flattenedList = [];
|
|
449
|
-
Object.keys(result2.metafile.inputs).forEach((key) => {
|
|
450
|
-
if (key.includes("node_modules") || key.includes("__generated__")) {
|
|
451
|
-
return;
|
|
452
|
-
}
|
|
453
|
-
flattenedList.push(key);
|
|
454
|
-
});
|
|
455
|
-
await esbuild.build({
|
|
456
|
-
entryPoints: [configFilePath],
|
|
457
|
-
bundle: true,
|
|
458
|
-
target: ["es2020"],
|
|
459
|
-
logLevel: "silent",
|
|
460
|
-
platform: "node",
|
|
461
|
-
outfile,
|
|
462
|
-
loader: loaders
|
|
463
|
-
});
|
|
464
|
-
await esbuild.build({
|
|
465
|
-
entryPoints: [outfile],
|
|
466
|
-
bundle: true,
|
|
467
|
-
logLevel: "silent",
|
|
468
|
-
platform: "node",
|
|
469
|
-
outfile: outfile2,
|
|
470
|
-
loader: loaders
|
|
471
|
-
});
|
|
472
|
-
let result;
|
|
473
|
-
try {
|
|
474
|
-
result = require(outfile2);
|
|
475
|
-
} catch (e) {
|
|
476
|
-
console.error("Unexpected error loading config");
|
|
477
|
-
console.error(e);
|
|
478
|
-
throw e;
|
|
479
|
-
}
|
|
480
|
-
import_fs_extra.default.removeSync(outfile);
|
|
481
|
-
import_fs_extra.default.removeSync(outfile2);
|
|
482
|
-
return {
|
|
483
|
-
config: result.default,
|
|
484
|
-
prebuildPath: prebuild,
|
|
485
|
-
watchList: flattenedList
|
|
486
|
-
};
|
|
487
|
-
}
|
|
488
|
-
};
|
|
489
|
-
var loaders = {
|
|
490
|
-
".aac": "file",
|
|
491
|
-
".css": "file",
|
|
492
|
-
".eot": "file",
|
|
493
|
-
".flac": "file",
|
|
494
|
-
".gif": "file",
|
|
495
|
-
".jpeg": "file",
|
|
496
|
-
".jpg": "file",
|
|
497
|
-
".json": "json",
|
|
498
|
-
".mp3": "file",
|
|
499
|
-
".mp4": "file",
|
|
500
|
-
".ogg": "file",
|
|
501
|
-
".otf": "file",
|
|
502
|
-
".png": "file",
|
|
503
|
-
".svg": "file",
|
|
504
|
-
".ttf": "file",
|
|
505
|
-
".wav": "file",
|
|
506
|
-
".webm": "file",
|
|
507
|
-
".webp": "file",
|
|
508
|
-
".woff": "file",
|
|
509
|
-
".woff2": "file",
|
|
510
|
-
".js": "jsx",
|
|
511
|
-
".jsx": "jsx",
|
|
512
|
-
".tsx": "tsx"
|
|
513
|
-
};
|
|
514
|
-
|
|
515
|
-
// src/next/commands/dev-command/html.ts
|
|
516
|
-
var errorHTML = `<style type="text/css">
|
|
517
|
-
#no-assets-placeholder body {
|
|
518
|
-
font-family: sans-serif;
|
|
519
|
-
font-size: 16px;
|
|
520
|
-
line-height: 1.4;
|
|
521
|
-
color: #333;
|
|
522
|
-
background-color: #f5f5f5;
|
|
523
|
-
}
|
|
524
|
-
#no-assets-placeholder {
|
|
525
|
-
max-width: 600px;
|
|
526
|
-
margin: 0 auto;
|
|
527
|
-
padding: 40px;
|
|
528
|
-
text-align: center;
|
|
529
|
-
background-color: #fff;
|
|
530
|
-
box-shadow: 0px 0px 20px rgba(0, 0, 0, 0.1);
|
|
531
|
-
}
|
|
532
|
-
#no-assets-placeholder h1 {
|
|
533
|
-
font-size: 24px;
|
|
534
|
-
margin-bottom: 20px;
|
|
535
|
-
}
|
|
536
|
-
#no-assets-placeholder p {
|
|
537
|
-
margin-bottom: 10px;
|
|
538
|
-
}
|
|
539
|
-
#no-assets-placeholder a {
|
|
540
|
-
color: #0077cc;
|
|
541
|
-
text-decoration: none;
|
|
542
|
-
}
|
|
543
|
-
#no-assets-placeholder a:hover {
|
|
544
|
-
text-decoration: underline;
|
|
545
|
-
}
|
|
546
|
-
</style>
|
|
547
|
-
<div id="no-assets-placeholder">
|
|
548
|
-
<h1>Failed loading TinaCMS assets</h1>
|
|
549
|
-
<p>
|
|
550
|
-
Your TinaCMS configuration may be misconfigured, and we could not load
|
|
551
|
-
the assets for this page.
|
|
552
|
-
</p>
|
|
553
|
-
<p>
|
|
554
|
-
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.
|
|
555
|
-
</p>
|
|
556
|
-
</div>
|
|
557
|
-
</div>`.trim().replace(/[\r\n\s]+/g, " ");
|
|
558
|
-
var devHTML = (port) => `<!DOCTYPE html>
|
|
559
|
-
<html lang="en">
|
|
560
|
-
<head>
|
|
561
|
-
<meta charset="UTF-8" />
|
|
562
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
563
|
-
<title>TinaCMS</title>
|
|
564
|
-
</head>
|
|
565
|
-
|
|
566
|
-
<!-- if development -->
|
|
567
|
-
<script type="module">
|
|
568
|
-
import RefreshRuntime from 'http://localhost:${port}/@react-refresh'
|
|
569
|
-
RefreshRuntime.injectIntoGlobalHook(window)
|
|
570
|
-
window.$RefreshReg$ = () => {}
|
|
571
|
-
window.$RefreshSig$ = () => (type) => type
|
|
572
|
-
window.__vite_plugin_react_preamble_installed__ = true
|
|
573
|
-
<\/script>
|
|
574
|
-
<script type="module" src="http://localhost:${port}/@vite/client"><\/script>
|
|
575
|
-
<script>
|
|
576
|
-
function handleLoadError() {
|
|
577
|
-
// Assets have failed to load
|
|
578
|
-
document.getElementById('root').innerHTML = '${errorHTML}';
|
|
579
|
-
}
|
|
580
|
-
<\/script>
|
|
581
|
-
<script
|
|
582
|
-
type="module"
|
|
583
|
-
src="http://localhost:${port}/src/main.tsx"
|
|
584
|
-
onerror="handleLoadError()"
|
|
585
|
-
><\/script>
|
|
586
|
-
<body class="tina-tailwind">
|
|
587
|
-
<div id="root"></div>
|
|
588
|
-
</body>
|
|
589
|
-
</html>`;
|
|
590
|
-
|
|
591
|
-
// src/utils/theme.ts
|
|
592
|
-
var import_chalk3 = __toESM(require("chalk"));
|
|
593
|
-
var successText = import_chalk3.default.bold.green;
|
|
594
|
-
var focusText = import_chalk3.default.bold;
|
|
595
|
-
var dangerText = import_chalk3.default.bold.red;
|
|
596
|
-
var neutralText = import_chalk3.default.bold.cyan;
|
|
597
|
-
var linkText = import_chalk3.default.bold.cyan;
|
|
598
|
-
var labelText = import_chalk3.default.bold;
|
|
599
|
-
var cmdText = import_chalk3.default.inverse;
|
|
600
|
-
var indentedCmd = (str) => {
|
|
601
|
-
return ` \u2503 ` + str;
|
|
602
|
-
};
|
|
603
|
-
var indentText = (str) => {
|
|
604
|
-
return String(str).split("\n").map((line) => ` ${line}`).join("\n");
|
|
605
|
-
};
|
|
606
|
-
var logText = import_chalk3.default.italic.gray;
|
|
607
|
-
var warnText = import_chalk3.default.yellowBright.bgBlack;
|
|
608
|
-
var titleText = import_chalk3.default.bgHex("d2f1f8").hex("ec4816");
|
|
609
|
-
var CONFIRMATION_TEXT = import_chalk3.default.dim("enter to confirm");
|
|
610
|
-
|
|
611
|
-
// src/next/commands/dev-command/server/index.ts
|
|
612
|
-
var import_vite3 = require("vite");
|
|
613
|
-
|
|
614
|
-
// src/next/vite/index.ts
|
|
615
|
-
var import_node_path2 = __toESM(require("path"));
|
|
616
|
-
var import_plugin_react = __toESM(require("@vitejs/plugin-react"));
|
|
617
|
-
var import_fs_extra2 = __toESM(require("fs-extra"));
|
|
618
|
-
var import_normalize_path2 = __toESM(require("normalize-path"));
|
|
619
|
-
var import_vite = require("vite");
|
|
52
|
+
// src/next/vite/index.ts
|
|
53
|
+
var import_node_path2 = __toESM(require("path"));
|
|
54
|
+
var import_plugin_react = __toESM(require("@vitejs/plugin-react"));
|
|
55
|
+
var import_fs_extra = __toESM(require("fs-extra"));
|
|
56
|
+
var import_normalize_path = __toESM(require("normalize-path"));
|
|
57
|
+
var import_vite = require("vite");
|
|
620
58
|
|
|
621
59
|
// src/next/vite/tailwind.ts
|
|
622
60
|
var import_node_path = __toESM(require("path"));
|
|
@@ -873,191 +311,786 @@ var tinaTailwind = (spaPath, prebuildFilePath) => {
|
|
|
873
311
|
import_aspect_ratio.default,
|
|
874
312
|
import_container_queries.default
|
|
875
313
|
]
|
|
876
|
-
});
|
|
877
|
-
plugins.push(tw);
|
|
878
|
-
return {
|
|
879
|
-
css: {
|
|
880
|
-
postcss: {
|
|
881
|
-
plugins
|
|
882
|
-
}
|
|
314
|
+
});
|
|
315
|
+
plugins.push(tw);
|
|
316
|
+
return {
|
|
317
|
+
css: {
|
|
318
|
+
postcss: {
|
|
319
|
+
plugins
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
};
|
|
323
|
+
}
|
|
324
|
+
};
|
|
325
|
+
};
|
|
326
|
+
|
|
327
|
+
// src/next/vite/index.ts
|
|
328
|
+
async function listFilesRecursively({
|
|
329
|
+
directoryPath,
|
|
330
|
+
config: config2,
|
|
331
|
+
roothPath
|
|
332
|
+
}) {
|
|
333
|
+
const fullDirectoryPath = import_node_path2.default.join(
|
|
334
|
+
roothPath,
|
|
335
|
+
config2.publicFolder,
|
|
336
|
+
directoryPath
|
|
337
|
+
);
|
|
338
|
+
const exists = await import_fs_extra.default.pathExists(fullDirectoryPath);
|
|
339
|
+
if (!exists) {
|
|
340
|
+
return { "0": [] };
|
|
341
|
+
}
|
|
342
|
+
const items = await import_fs_extra.default.readdir(fullDirectoryPath);
|
|
343
|
+
const staticMediaItems = [];
|
|
344
|
+
for (const item of items) {
|
|
345
|
+
const itemPath = import_node_path2.default.join(fullDirectoryPath, item);
|
|
346
|
+
const stats = await import_fs_extra.default.promises.lstat(itemPath);
|
|
347
|
+
const staticMediaItem = {
|
|
348
|
+
id: item,
|
|
349
|
+
filename: item,
|
|
350
|
+
type: stats.isDirectory() ? "dir" : "file",
|
|
351
|
+
directory: `${directoryPath.replace(config2.mediaRoot, "")}`,
|
|
352
|
+
src: `/${import_node_path2.default.join(directoryPath, item)}`,
|
|
353
|
+
thumbnails: {
|
|
354
|
+
"75x75": `/${import_node_path2.default.join(directoryPath, item)}`,
|
|
355
|
+
"400x400": `/${import_node_path2.default.join(directoryPath, item)}`,
|
|
356
|
+
"1000x1000": `/${import_node_path2.default.join(directoryPath, item)}`
|
|
357
|
+
}
|
|
358
|
+
};
|
|
359
|
+
if (stats.isDirectory()) {
|
|
360
|
+
staticMediaItem.children = await listFilesRecursively({
|
|
361
|
+
directoryPath: import_node_path2.default.join(directoryPath, item),
|
|
362
|
+
config: config2,
|
|
363
|
+
roothPath
|
|
364
|
+
});
|
|
365
|
+
}
|
|
366
|
+
staticMediaItems.push(staticMediaItem);
|
|
367
|
+
}
|
|
368
|
+
function chunkArrayIntoObject(array, chunkSize) {
|
|
369
|
+
const result = {};
|
|
370
|
+
for (let i = 0; i < array.length; i += chunkSize) {
|
|
371
|
+
const chunkKey = `${i / chunkSize * 20}`;
|
|
372
|
+
result[chunkKey] = array.slice(i, i + chunkSize);
|
|
373
|
+
}
|
|
374
|
+
return result;
|
|
375
|
+
}
|
|
376
|
+
return chunkArrayIntoObject(staticMediaItems, 20);
|
|
377
|
+
}
|
|
378
|
+
var loadProjectConfig = async ({
|
|
379
|
+
rootPath,
|
|
380
|
+
viteConfigEnv
|
|
381
|
+
}) => {
|
|
382
|
+
if (viteConfigEnv) {
|
|
383
|
+
const configFileJs = import_node_path2.default.join(rootPath, "vite.config.js");
|
|
384
|
+
const configFileTs = import_node_path2.default.join(rootPath, "vite.config.ts");
|
|
385
|
+
if (import_fs_extra.default.existsSync(configFileJs)) {
|
|
386
|
+
return await (0, import_vite.loadConfigFromFile)(viteConfigEnv, configFileJs);
|
|
387
|
+
} else if (import_fs_extra.default.existsSync(configFileTs)) {
|
|
388
|
+
return await (0, import_vite.loadConfigFromFile)(viteConfigEnv, configFileTs);
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
return { config: {} };
|
|
392
|
+
};
|
|
393
|
+
var createConfig = async ({
|
|
394
|
+
configManager,
|
|
395
|
+
database,
|
|
396
|
+
apiURL,
|
|
397
|
+
plugins = [],
|
|
398
|
+
noWatch,
|
|
399
|
+
rollupOptions,
|
|
400
|
+
viteConfigEnv
|
|
401
|
+
}) => {
|
|
402
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
403
|
+
const projectConfig = await loadProjectConfig({
|
|
404
|
+
rootPath: configManager.rootPath,
|
|
405
|
+
viteConfigEnv
|
|
406
|
+
});
|
|
407
|
+
const publicEnv = {};
|
|
408
|
+
Object.keys(process.env).forEach((key) => {
|
|
409
|
+
if (key.startsWith("TINA_PUBLIC_") || key.startsWith("NEXT_PUBLIC_") || key === "NODE_ENV" || key === "HEAD") {
|
|
410
|
+
try {
|
|
411
|
+
if (typeof process.env[key] === "string") {
|
|
412
|
+
publicEnv[key] = process.env[key];
|
|
413
|
+
} else {
|
|
414
|
+
publicEnv[key] = JSON.stringify(process.env[key]);
|
|
415
|
+
}
|
|
416
|
+
} catch (error) {
|
|
417
|
+
console.warn(
|
|
418
|
+
`Could not stringify public env process.env.${key} env variable`
|
|
419
|
+
);
|
|
420
|
+
console.warn(error);
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
});
|
|
424
|
+
const staticMediaPath = import_node_path2.default.join(
|
|
425
|
+
configManager.generatedFolderPath,
|
|
426
|
+
"static-media.json"
|
|
427
|
+
);
|
|
428
|
+
if ((_b = (_a = configManager.config.media) == null ? void 0 : _a.tina) == null ? void 0 : _b.static) {
|
|
429
|
+
const staticMedia = await listFilesRecursively({
|
|
430
|
+
directoryPath: ((_c = configManager.config.media.tina) == null ? void 0 : _c.mediaRoot) || "",
|
|
431
|
+
config: configManager.config.media.tina,
|
|
432
|
+
roothPath: configManager.rootPath
|
|
433
|
+
});
|
|
434
|
+
await import_fs_extra.default.outputFile(staticMediaPath, JSON.stringify(staticMedia, null, 2));
|
|
435
|
+
} else {
|
|
436
|
+
await import_fs_extra.default.outputFile(staticMediaPath, `[]`);
|
|
437
|
+
}
|
|
438
|
+
const alias = {
|
|
439
|
+
TINA_IMPORT: configManager.prebuildFilePath,
|
|
440
|
+
SCHEMA_IMPORT: configManager.generatedGraphQLJSONPath,
|
|
441
|
+
STATIC_MEDIA_IMPORT: staticMediaPath,
|
|
442
|
+
crypto: import_node_path2.default.join(configManager.spaRootPath, "src", "dummy-client.ts"),
|
|
443
|
+
fs: import_node_path2.default.join(configManager.spaRootPath, "src", "dummy-client.ts"),
|
|
444
|
+
os: import_node_path2.default.join(configManager.spaRootPath, "src", "dummy-client.ts"),
|
|
445
|
+
path: import_node_path2.default.join(configManager.spaRootPath, "src", "dummy-client.ts")
|
|
446
|
+
};
|
|
447
|
+
if (configManager.shouldSkipSDK()) {
|
|
448
|
+
alias["CLIENT_IMPORT"] = import_node_path2.default.join(
|
|
449
|
+
configManager.spaRootPath,
|
|
450
|
+
"src",
|
|
451
|
+
"dummy-client.ts"
|
|
452
|
+
);
|
|
453
|
+
} else {
|
|
454
|
+
alias["CLIENT_IMPORT"] = configManager.isUsingTs() ? configManager.generatedTypesTSFilePath : configManager.generatedTypesJSFilePath;
|
|
455
|
+
}
|
|
456
|
+
let basePath;
|
|
457
|
+
if (configManager.config.build.basePath) {
|
|
458
|
+
basePath = configManager.config.build.basePath;
|
|
459
|
+
}
|
|
460
|
+
const config2 = {
|
|
461
|
+
root: configManager.spaRootPath,
|
|
462
|
+
base: `/${basePath ? `${(0, import_normalize_path.default)(basePath)}/` : ""}${(0, import_normalize_path.default)(
|
|
463
|
+
configManager.config.build.outputFolder
|
|
464
|
+
)}/`,
|
|
465
|
+
appType: "spa",
|
|
466
|
+
resolve: {
|
|
467
|
+
alias: {
|
|
468
|
+
...(_d = projectConfig.config.resolve) == null ? void 0 : _d.alias,
|
|
469
|
+
...alias
|
|
470
|
+
},
|
|
471
|
+
dedupe: ["graphql", "tinacms", "react", "react-dom", "react-router-dom"]
|
|
472
|
+
},
|
|
473
|
+
define: {
|
|
474
|
+
"process.env": `new Object(${JSON.stringify(publicEnv)})`,
|
|
475
|
+
"process.platform": `"${process.platform}"`,
|
|
476
|
+
__API_URL__: `"${apiURL}"`,
|
|
477
|
+
__BASE_PATH__: `"${((_f = (_e = configManager.config) == null ? void 0 : _e.build) == null ? void 0 : _f.basePath) || ""}"`,
|
|
478
|
+
__TINA_GRAPHQL_VERSION__: `"${configManager.getTinaGraphQLVersion()}"`
|
|
479
|
+
},
|
|
480
|
+
logLevel: "error",
|
|
481
|
+
optimizeDeps: {
|
|
482
|
+
force: true,
|
|
483
|
+
include: ["react/jsx-runtime", "react/jsx-dev-runtime"]
|
|
484
|
+
},
|
|
485
|
+
server: {
|
|
486
|
+
host: (_i = (_h = (_g = configManager.config) == null ? void 0 : _g.build) == null ? void 0 : _h.host) != null ? _i : false,
|
|
487
|
+
watch: noWatch ? {
|
|
488
|
+
ignored: ["**/*"]
|
|
489
|
+
} : {
|
|
490
|
+
ignored: [
|
|
491
|
+
`${configManager.tinaFolderPath}/**/!(config.prebuild.jsx|_graphql.json)`
|
|
492
|
+
]
|
|
493
|
+
},
|
|
494
|
+
fs: {
|
|
495
|
+
strict: false
|
|
496
|
+
}
|
|
497
|
+
},
|
|
498
|
+
build: {
|
|
499
|
+
sourcemap: false,
|
|
500
|
+
outDir: configManager.outputFolderPath,
|
|
501
|
+
emptyOutDir: true,
|
|
502
|
+
rollupOptions
|
|
503
|
+
},
|
|
504
|
+
plugins: [
|
|
505
|
+
(0, import_plugin_react.default)({
|
|
506
|
+
babel: {
|
|
507
|
+
compact: true
|
|
883
508
|
}
|
|
884
|
-
}
|
|
509
|
+
}),
|
|
510
|
+
(0, import_vite.splitVendorChunkPlugin)(),
|
|
511
|
+
tinaTailwind(configManager.spaRootPath, configManager.prebuildFilePath),
|
|
512
|
+
...plugins
|
|
513
|
+
]
|
|
514
|
+
};
|
|
515
|
+
return config2;
|
|
516
|
+
};
|
|
517
|
+
|
|
518
|
+
// src/logger/index.ts
|
|
519
|
+
var import_chalk = __toESM(require("chalk"));
|
|
520
|
+
|
|
521
|
+
// src/logger/is-unicode-supported.ts
|
|
522
|
+
function isUnicodeSupported() {
|
|
523
|
+
if (process.platform !== "win32") {
|
|
524
|
+
return process.env.TERM !== "linux";
|
|
525
|
+
}
|
|
526
|
+
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";
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
// src/logger/index.ts
|
|
530
|
+
var import_log4js = __toESM(require("log4js"));
|
|
531
|
+
var logger = import_log4js.default.getLogger();
|
|
532
|
+
import_log4js.default.configure({
|
|
533
|
+
appenders: {
|
|
534
|
+
out: { type: "stdout", layout: { type: "messagePassThrough" } }
|
|
535
|
+
},
|
|
536
|
+
categories: { default: { appenders: ["out"], level: "info" } }
|
|
537
|
+
});
|
|
538
|
+
logger.level = "info";
|
|
539
|
+
function ansiRegex() {
|
|
540
|
+
const pattern = [
|
|
541
|
+
"[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)",
|
|
542
|
+
"(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"
|
|
543
|
+
].join("|");
|
|
544
|
+
return new RegExp(pattern, "g");
|
|
545
|
+
}
|
|
546
|
+
var bar = "\u2502";
|
|
547
|
+
var strip = (str) => str.replace(ansiRegex(), "");
|
|
548
|
+
var note = (message = "", title = "") => {
|
|
549
|
+
const lines = `
|
|
550
|
+
${message}
|
|
551
|
+
`.split("\n");
|
|
552
|
+
const len = lines.reduce((sum, ln) => {
|
|
553
|
+
ln = strip(ln);
|
|
554
|
+
return ln.length > sum ? ln.length : sum;
|
|
555
|
+
}, 0) + 2;
|
|
556
|
+
const msg = lines.map(
|
|
557
|
+
(ln) => `${import_chalk.default.gray(bar)} ${import_chalk.default.white(ln)}${" ".repeat(
|
|
558
|
+
len - strip(ln).length
|
|
559
|
+
)}${import_chalk.default.gray(bar)}`
|
|
560
|
+
).join("\n");
|
|
561
|
+
const underscoreLen = len - title.length - 1 > 0 ? len - title.length - 1 : 0;
|
|
562
|
+
process.stdout.write(
|
|
563
|
+
`${import_chalk.default.gray(bar)}
|
|
564
|
+
${import_chalk.default.green("\u25CB")} ${import_chalk.default.reset(
|
|
565
|
+
title
|
|
566
|
+
)} ${import_chalk.default.gray("\u2500".repeat(underscoreLen) + "\u256E")}
|
|
567
|
+
${msg}
|
|
568
|
+
${import_chalk.default.gray(
|
|
569
|
+
"\u251C" + "\u2500".repeat(len + 2) + "\u256F"
|
|
570
|
+
)}
|
|
571
|
+
`
|
|
572
|
+
);
|
|
573
|
+
};
|
|
574
|
+
var summary = (content) => {
|
|
575
|
+
const outString = [];
|
|
576
|
+
let longestKey = 0;
|
|
577
|
+
content.items.forEach((item) => {
|
|
578
|
+
item.subItems.forEach((subItem) => {
|
|
579
|
+
if (subItem.key.length > longestKey) {
|
|
580
|
+
longestKey = subItem.key.length;
|
|
581
|
+
}
|
|
582
|
+
});
|
|
583
|
+
});
|
|
584
|
+
content.items.forEach((item) => {
|
|
585
|
+
outString.push(`${item.emoji} ${import_chalk.default.cyan(item.heading)}`);
|
|
586
|
+
item.subItems.forEach((subItem) => {
|
|
587
|
+
const spaces = longestKey - subItem.key.length + 4;
|
|
588
|
+
outString.push(
|
|
589
|
+
` ${subItem.key}:${[...Array(spaces)].join(" ")}${import_chalk.default.cyan(
|
|
590
|
+
subItem.value
|
|
591
|
+
)}`
|
|
592
|
+
);
|
|
593
|
+
});
|
|
594
|
+
outString.push(``);
|
|
595
|
+
});
|
|
596
|
+
if (process.env.CI) {
|
|
597
|
+
logger.info(JSON.stringify(content, null, 2));
|
|
598
|
+
} else {
|
|
599
|
+
note(outString.join("\n"), content.heading);
|
|
600
|
+
}
|
|
601
|
+
};
|
|
602
|
+
var unicode = isUnicodeSupported();
|
|
603
|
+
var s = (c, fallback) => unicode ? c : fallback;
|
|
604
|
+
var S_STEP_ACTIVE = s("\u25C6", "*");
|
|
605
|
+
var S_STEP_CANCEL = s("\u25A0", "x");
|
|
606
|
+
var S_STEP_ERROR = s("\u25B2", "x");
|
|
607
|
+
var S_STEP_SUBMIT = s("\u25C7", "o");
|
|
608
|
+
var S_BAR_START = s("\u250C", "T");
|
|
609
|
+
var S_BAR = s("\u2502", "|");
|
|
610
|
+
var S_BAR_END = s("\u2514", "\u2014");
|
|
611
|
+
var S_RADIO_ACTIVE = s("\u25CF", ">");
|
|
612
|
+
var S_RADIO_INACTIVE = s("\u25CB", " ");
|
|
613
|
+
var S_CHECKBOX_ACTIVE = s("\u25FB", "[\u2022]");
|
|
614
|
+
var S_CHECKBOX_SELECTED = s("\u25FC", "[+]");
|
|
615
|
+
var S_CHECKBOX_INACTIVE = s("\u25FB", "[ ]");
|
|
616
|
+
var S_PASSWORD_MASK = s("\u25AA", "\u2022");
|
|
617
|
+
var S_BAR_H = s("\u2500", "-");
|
|
618
|
+
var S_CORNER_TOP_RIGHT = s("\u256E", "+");
|
|
619
|
+
var S_CONNECT_LEFT = s("\u251C", "+");
|
|
620
|
+
var S_CORNER_BOTTOM_RIGHT = s("\u256F", "+");
|
|
621
|
+
var S_INFO = s("\u25CF", "\u2022");
|
|
622
|
+
var S_SUCCESS = s("\u25C6", "*");
|
|
623
|
+
var S_WARN = s("\u25B2", "!");
|
|
624
|
+
var S_ERROR = s("\u25A0", "x");
|
|
625
|
+
|
|
626
|
+
// src/next/config-manager.ts
|
|
627
|
+
var TINA_FOLDER = "tina";
|
|
628
|
+
var LEGACY_TINA_FOLDER = ".tina";
|
|
629
|
+
var GENERATED_FOLDER = "__generated__";
|
|
630
|
+
var GRAPHQL_JSON_FILE = "_graphql.json";
|
|
631
|
+
var GRAPHQL_GQL_FILE = "schema.gql";
|
|
632
|
+
var SCHEMA_JSON_FILE = "_schema.json";
|
|
633
|
+
var LOOKUP_JSON_FILE = "_lookup.json";
|
|
634
|
+
var ConfigManager = class {
|
|
635
|
+
constructor({
|
|
636
|
+
rootPath = process.cwd(),
|
|
637
|
+
tinaGraphQLVersion,
|
|
638
|
+
legacyNoSDK
|
|
639
|
+
}) {
|
|
640
|
+
this.rootPath = (0, import_normalize_path2.default)(rootPath);
|
|
641
|
+
this.tinaGraphQLVersionFromCLI = tinaGraphQLVersion;
|
|
642
|
+
this.legacyNoSDK = legacyNoSDK;
|
|
643
|
+
}
|
|
644
|
+
isUsingTs() {
|
|
645
|
+
return [".ts", ".tsx"].includes(import_path.default.extname(this.tinaConfigFilePath));
|
|
646
|
+
}
|
|
647
|
+
hasSelfHostedConfig() {
|
|
648
|
+
return !!this.selfHostedDatabaseFilePath;
|
|
649
|
+
}
|
|
650
|
+
hasSeparateContentRoot() {
|
|
651
|
+
return this.rootPath !== this.contentRootPath;
|
|
652
|
+
}
|
|
653
|
+
shouldSkipSDK() {
|
|
654
|
+
var _a;
|
|
655
|
+
if (this.legacyNoSDK) {
|
|
656
|
+
return this.legacyNoSDK;
|
|
657
|
+
}
|
|
658
|
+
return ((_a = this.config.client) == null ? void 0 : _a.skip) || false;
|
|
659
|
+
}
|
|
660
|
+
async processConfig() {
|
|
661
|
+
this.tinaFolderPath = await this.getTinaFolderPath(this.rootPath);
|
|
662
|
+
this.envFilePath = import_path.default.resolve(
|
|
663
|
+
import_path.default.join(this.tinaFolderPath, "..", ".env")
|
|
664
|
+
);
|
|
665
|
+
dotenv.config({ path: this.envFilePath });
|
|
666
|
+
this.tinaConfigFilePath = await this.getPathWithExtension(
|
|
667
|
+
import_path.default.join(this.tinaFolderPath, "config")
|
|
668
|
+
);
|
|
669
|
+
if (!this.tinaConfigFilePath) {
|
|
670
|
+
throw new Error(
|
|
671
|
+
`Unable to find config file in ${this.tinaFolderPath}. Looking for a file named "config.{ts,tsx,js,jsx}"`
|
|
672
|
+
);
|
|
673
|
+
}
|
|
674
|
+
this.selfHostedDatabaseFilePath = await this.getPathWithExtension(
|
|
675
|
+
import_path.default.join(this.tinaFolderPath, "database")
|
|
676
|
+
);
|
|
677
|
+
this.generatedFolderPath = import_path.default.join(this.tinaFolderPath, GENERATED_FOLDER);
|
|
678
|
+
this.generatedCachePath = import_path.default.join(
|
|
679
|
+
this.generatedFolderPath,
|
|
680
|
+
".cache",
|
|
681
|
+
String(new Date().getTime())
|
|
682
|
+
);
|
|
683
|
+
this.generatedGraphQLGQLPath = import_path.default.join(
|
|
684
|
+
this.generatedFolderPath,
|
|
685
|
+
GRAPHQL_GQL_FILE
|
|
686
|
+
);
|
|
687
|
+
this.generatedGraphQLJSONPath = import_path.default.join(
|
|
688
|
+
this.generatedFolderPath,
|
|
689
|
+
GRAPHQL_JSON_FILE
|
|
690
|
+
);
|
|
691
|
+
this.generatedSchemaJSONPath = import_path.default.join(
|
|
692
|
+
this.generatedFolderPath,
|
|
693
|
+
SCHEMA_JSON_FILE
|
|
694
|
+
);
|
|
695
|
+
this.generatedLookupJSONPath = import_path.default.join(
|
|
696
|
+
this.generatedFolderPath,
|
|
697
|
+
LOOKUP_JSON_FILE
|
|
698
|
+
);
|
|
699
|
+
this.generatedQueriesFilePath = import_path.default.join(
|
|
700
|
+
this.generatedFolderPath,
|
|
701
|
+
"queries.gql"
|
|
702
|
+
);
|
|
703
|
+
this.generatedFragmentsFilePath = import_path.default.join(
|
|
704
|
+
this.generatedFolderPath,
|
|
705
|
+
"frags.gql"
|
|
706
|
+
);
|
|
707
|
+
this.generatedTypesTSFilePath = import_path.default.join(
|
|
708
|
+
this.generatedFolderPath,
|
|
709
|
+
"types.ts"
|
|
710
|
+
);
|
|
711
|
+
this.generatedTypesJSFilePath = import_path.default.join(
|
|
712
|
+
this.generatedFolderPath,
|
|
713
|
+
"types.js"
|
|
714
|
+
);
|
|
715
|
+
this.generatedTypesDFilePath = import_path.default.join(
|
|
716
|
+
this.generatedFolderPath,
|
|
717
|
+
"types.d.ts"
|
|
718
|
+
);
|
|
719
|
+
this.userQueriesAndFragmentsGlob = import_path.default.join(
|
|
720
|
+
this.tinaFolderPath,
|
|
721
|
+
"queries/**/*.{graphql,gql}"
|
|
722
|
+
);
|
|
723
|
+
this.generatedQueriesAndFragmentsGlob = import_path.default.join(
|
|
724
|
+
this.generatedFolderPath,
|
|
725
|
+
"*.{graphql,gql}"
|
|
726
|
+
);
|
|
727
|
+
this.generatedClientTSFilePath = import_path.default.join(
|
|
728
|
+
this.generatedFolderPath,
|
|
729
|
+
"client.ts"
|
|
730
|
+
);
|
|
731
|
+
this.generatedClientJSFilePath = import_path.default.join(
|
|
732
|
+
this.generatedFolderPath,
|
|
733
|
+
"client.js"
|
|
734
|
+
);
|
|
735
|
+
this.generatedClientDFilePath = import_path.default.join(
|
|
736
|
+
this.generatedFolderPath,
|
|
737
|
+
"client.d.ts"
|
|
738
|
+
);
|
|
739
|
+
this.generatedDatabaseClientDFilePath = import_path.default.join(
|
|
740
|
+
this.generatedFolderPath,
|
|
741
|
+
"databaseClient.d.ts"
|
|
742
|
+
);
|
|
743
|
+
this.generatedDatabaseClientTSFilePath = import_path.default.join(
|
|
744
|
+
this.generatedFolderPath,
|
|
745
|
+
"databaseClient.ts"
|
|
746
|
+
);
|
|
747
|
+
this.generatedDatabaseClientJSFilePath = import_path.default.join(
|
|
748
|
+
this.generatedFolderPath,
|
|
749
|
+
"databaseClient.js"
|
|
750
|
+
);
|
|
751
|
+
const clientExists = this.isUsingTs() ? await import_fs_extra2.default.pathExists(this.generatedClientTSFilePath) : await import_fs_extra2.default.pathExists(this.generatedClientJSFilePath);
|
|
752
|
+
if (!clientExists) {
|
|
753
|
+
const file = "export default ()=>({})\nexport const client = ()=>({})";
|
|
754
|
+
if (this.isUsingTs()) {
|
|
755
|
+
await import_fs_extra2.default.outputFile(this.generatedClientTSFilePath, file);
|
|
756
|
+
} else {
|
|
757
|
+
await import_fs_extra2.default.outputFile(this.generatedClientJSFilePath, file);
|
|
758
|
+
}
|
|
885
759
|
}
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
760
|
+
const { config: config2, prebuildPath, watchList } = await this.loadConfigFile(
|
|
761
|
+
this.generatedFolderPath,
|
|
762
|
+
this.tinaConfigFilePath
|
|
763
|
+
);
|
|
764
|
+
this.watchList = watchList;
|
|
765
|
+
this.config = config2;
|
|
766
|
+
this.prebuildFilePath = prebuildPath;
|
|
767
|
+
this.publicFolderPath = import_path.default.join(
|
|
768
|
+
this.rootPath,
|
|
769
|
+
this.config.build.publicFolder
|
|
770
|
+
);
|
|
771
|
+
this.outputFolderPath = import_path.default.join(
|
|
772
|
+
this.publicFolderPath,
|
|
773
|
+
this.config.build.outputFolder
|
|
774
|
+
);
|
|
775
|
+
this.outputHTMLFilePath = import_path.default.join(this.outputFolderPath, "index.html");
|
|
776
|
+
this.outputGitignorePath = import_path.default.join(this.outputFolderPath, ".gitignore");
|
|
777
|
+
const fullLocalContentPath = import_path.default.join(
|
|
778
|
+
this.tinaFolderPath,
|
|
779
|
+
this.config.localContentPath || ""
|
|
780
|
+
);
|
|
781
|
+
if (this.config.localContentPath) {
|
|
782
|
+
const localContentPathExists = await import_fs_extra2.default.pathExists(fullLocalContentPath);
|
|
783
|
+
if (localContentPathExists) {
|
|
784
|
+
logger.info(`Using separate content repo at ${fullLocalContentPath}`);
|
|
785
|
+
this.contentRootPath = fullLocalContentPath;
|
|
786
|
+
} else {
|
|
787
|
+
logger.warn(
|
|
788
|
+
`${import_chalk2.default.yellow("Warning:")} The localContentPath ${import_chalk2.default.cyan(
|
|
789
|
+
fullLocalContentPath
|
|
790
|
+
)} does not exist. Please create it or remove the localContentPath from your config file at ${import_chalk2.default.cyan(
|
|
791
|
+
this.tinaConfigFilePath
|
|
792
|
+
)}`
|
|
793
|
+
);
|
|
919
794
|
}
|
|
920
|
-
};
|
|
921
|
-
if (stats.isDirectory()) {
|
|
922
|
-
staticMediaItem.children = await listFilesRecursively({
|
|
923
|
-
directoryPath: import_node_path2.default.join(directoryPath, item),
|
|
924
|
-
config: config2,
|
|
925
|
-
roothPath
|
|
926
|
-
});
|
|
927
795
|
}
|
|
928
|
-
|
|
796
|
+
if (!this.contentRootPath) {
|
|
797
|
+
this.contentRootPath = this.rootPath;
|
|
798
|
+
}
|
|
799
|
+
this.generatedFolderPathContentRepo = import_path.default.join(
|
|
800
|
+
await this.getTinaFolderPath(this.contentRootPath),
|
|
801
|
+
GENERATED_FOLDER
|
|
802
|
+
);
|
|
803
|
+
this.spaMainPath = require.resolve("@tinacms/app");
|
|
804
|
+
this.spaRootPath = import_path.default.join(this.spaMainPath, "..", "..");
|
|
929
805
|
}
|
|
930
|
-
|
|
931
|
-
const
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
806
|
+
async getTinaFolderPath(rootPath) {
|
|
807
|
+
const tinaFolderPath = import_path.default.join(rootPath, TINA_FOLDER);
|
|
808
|
+
const tinaFolderExists = await import_fs_extra2.default.pathExists(tinaFolderPath);
|
|
809
|
+
if (tinaFolderExists) {
|
|
810
|
+
this.isUsingLegacyFolder = false;
|
|
811
|
+
return tinaFolderPath;
|
|
935
812
|
}
|
|
936
|
-
|
|
813
|
+
const legacyFolderPath = import_path.default.join(rootPath, LEGACY_TINA_FOLDER);
|
|
814
|
+
const legacyFolderExists = await import_fs_extra2.default.pathExists(legacyFolderPath);
|
|
815
|
+
if (legacyFolderExists) {
|
|
816
|
+
this.isUsingLegacyFolder = true;
|
|
817
|
+
return legacyFolderPath;
|
|
818
|
+
}
|
|
819
|
+
throw new Error(
|
|
820
|
+
`Unable to find Tina folder, if you're working in folder outside of the Tina config be sure to specify --rootPath`
|
|
821
|
+
);
|
|
937
822
|
}
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
823
|
+
getTinaGraphQLVersion() {
|
|
824
|
+
var _a, _b;
|
|
825
|
+
if (this.tinaGraphQLVersionFromCLI) {
|
|
826
|
+
return this.tinaGraphQLVersionFromCLI;
|
|
827
|
+
}
|
|
828
|
+
const generatedSchema = import_fs_extra2.default.readJSONSync(this.generatedSchemaJSONPath);
|
|
829
|
+
if (!generatedSchema || !(typeof (generatedSchema == null ? void 0 : generatedSchema.version) !== "undefined") || !(typeof ((_a = generatedSchema == null ? void 0 : generatedSchema.version) == null ? void 0 : _a.major) === "string") || !(typeof ((_b = generatedSchema == null ? void 0 : generatedSchema.version) == null ? void 0 : _b.minor) === "string")) {
|
|
830
|
+
throw new Error(
|
|
831
|
+
`Can not find Tina GraphQL version in ${this.generatedSchemaJSONPath}`
|
|
832
|
+
);
|
|
833
|
+
}
|
|
834
|
+
return `${generatedSchema.version.major}.${generatedSchema.version.minor}`;
|
|
835
|
+
}
|
|
836
|
+
printGeneratedClientFilePath() {
|
|
837
|
+
if (this.isUsingTs()) {
|
|
838
|
+
return this.generatedClientTSFilePath.replace(`${this.rootPath}/`, "");
|
|
839
|
+
}
|
|
840
|
+
return this.generatedClientJSFilePath.replace(`${this.rootPath}/`, "");
|
|
841
|
+
}
|
|
842
|
+
printGeneratedTypesFilePath() {
|
|
843
|
+
return this.generatedTypesTSFilePath.replace(`${this.rootPath}/`, "");
|
|
844
|
+
}
|
|
845
|
+
printoutputHTMLFilePath() {
|
|
846
|
+
return this.outputHTMLFilePath.replace(`${this.publicFolderPath}/`, "");
|
|
847
|
+
}
|
|
848
|
+
printRelativePath(filename) {
|
|
849
|
+
if (filename) {
|
|
850
|
+
return filename.replace(/\\/g, "/").replace(`${this.rootPath}/`, "");
|
|
851
|
+
}
|
|
852
|
+
throw `No path provided to print`;
|
|
853
|
+
}
|
|
854
|
+
printPrebuildFilePath() {
|
|
855
|
+
return this.prebuildFilePath.replace(/\\/g, "/").replace(`${this.rootPath}/${this.tinaFolderPath}/`, "");
|
|
856
|
+
}
|
|
857
|
+
printContentRelativePath(filename) {
|
|
858
|
+
if (filename) {
|
|
859
|
+
return filename.replace(/\\/g, "/").replace(`${this.contentRootPath}/`, "");
|
|
860
|
+
}
|
|
861
|
+
throw `No path provided to print`;
|
|
862
|
+
}
|
|
863
|
+
async getPathWithExtension(filepath) {
|
|
864
|
+
const extensions = ["tsx", "ts", "jsx", "js"];
|
|
865
|
+
let result;
|
|
866
|
+
await Promise.all(
|
|
867
|
+
extensions.map(async (ext) => {
|
|
868
|
+
if (result) {
|
|
869
|
+
return;
|
|
957
870
|
}
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
871
|
+
const filepathWithExtension = `${filepath}.${ext}`;
|
|
872
|
+
const exists = import_fs_extra2.default.existsSync(filepathWithExtension);
|
|
873
|
+
if (exists) {
|
|
874
|
+
result = filepathWithExtension;
|
|
875
|
+
}
|
|
876
|
+
})
|
|
877
|
+
);
|
|
878
|
+
return result;
|
|
879
|
+
}
|
|
880
|
+
async loadDatabaseFile() {
|
|
881
|
+
const tmpdir = import_path.default.join(import_os.default.tmpdir(), Date.now().toString());
|
|
882
|
+
const outfile = import_path.default.join(tmpdir, "database.build.js");
|
|
883
|
+
await esbuild.build({
|
|
884
|
+
entryPoints: [this.selfHostedDatabaseFilePath],
|
|
885
|
+
bundle: true,
|
|
886
|
+
platform: "node",
|
|
887
|
+
outfile,
|
|
888
|
+
loader: loaders
|
|
889
|
+
});
|
|
890
|
+
const result = require(outfile);
|
|
891
|
+
import_fs_extra2.default.removeSync(outfile);
|
|
892
|
+
return result.default;
|
|
893
|
+
}
|
|
894
|
+
async loadConfigFile(generatedFolderPath, configFilePath) {
|
|
895
|
+
var _a, _b;
|
|
896
|
+
const tmpdir = import_path.default.join(import_os.default.tmpdir(), Date.now().toString());
|
|
897
|
+
const prebuild = import_path.default.join(this.generatedFolderPath, "config.prebuild.jsx");
|
|
898
|
+
const outfile = import_path.default.join(tmpdir, "config.build.jsx");
|
|
899
|
+
const outfile2 = import_path.default.join(tmpdir, "config.build.js");
|
|
900
|
+
const tempTSConfigFile = import_path.default.join(tmpdir, "tsconfig.json");
|
|
901
|
+
const viteConfig = await loadProjectConfig({
|
|
902
|
+
rootPath: this.rootPath,
|
|
903
|
+
viteConfigEnv: {
|
|
904
|
+
command: "build",
|
|
905
|
+
mode: "production"
|
|
963
906
|
}
|
|
964
|
-
}
|
|
965
|
-
});
|
|
966
|
-
const staticMediaPath = import_node_path2.default.join(
|
|
967
|
-
configManager.generatedFolderPath,
|
|
968
|
-
"static-media.json"
|
|
969
|
-
);
|
|
970
|
-
if ((_b = (_a = configManager.config.media) == null ? void 0 : _a.tina) == null ? void 0 : _b.static) {
|
|
971
|
-
const staticMedia = await listFilesRecursively({
|
|
972
|
-
directoryPath: ((_c = configManager.config.media.tina) == null ? void 0 : _c.mediaRoot) || "",
|
|
973
|
-
config: configManager.config.media.tina,
|
|
974
|
-
roothPath: configManager.rootPath
|
|
975
907
|
});
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
"
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
908
|
+
import_fs_extra2.default.outputFileSync(tempTSConfigFile, "{}");
|
|
909
|
+
const result2 = await esbuild.build({
|
|
910
|
+
entryPoints: [configFilePath],
|
|
911
|
+
bundle: true,
|
|
912
|
+
target: ["es2020"],
|
|
913
|
+
platform: "browser",
|
|
914
|
+
format: "esm",
|
|
915
|
+
logLevel: "silent",
|
|
916
|
+
packages: "external",
|
|
917
|
+
ignoreAnnotations: true,
|
|
918
|
+
outfile: prebuild,
|
|
919
|
+
loader: loaders,
|
|
920
|
+
metafile: true,
|
|
921
|
+
alias: (_a = viteConfig.config.resolve) == null ? void 0 : _a.alias
|
|
922
|
+
});
|
|
923
|
+
const flattenedList = [];
|
|
924
|
+
Object.keys(result2.metafile.inputs).forEach((key) => {
|
|
925
|
+
if (key.includes("node_modules") || key.includes("__generated__")) {
|
|
926
|
+
return;
|
|
927
|
+
}
|
|
928
|
+
flattenedList.push(key);
|
|
929
|
+
});
|
|
930
|
+
await esbuild.build({
|
|
931
|
+
entryPoints: [configFilePath],
|
|
932
|
+
bundle: true,
|
|
933
|
+
target: ["es2020"],
|
|
934
|
+
logLevel: "silent",
|
|
935
|
+
platform: "node",
|
|
936
|
+
outfile,
|
|
937
|
+
loader: loaders,
|
|
938
|
+
alias: (_b = viteConfig.config.resolve) == null ? void 0 : _b.alias
|
|
939
|
+
});
|
|
940
|
+
await esbuild.build({
|
|
941
|
+
entryPoints: [outfile],
|
|
942
|
+
bundle: true,
|
|
943
|
+
logLevel: "silent",
|
|
944
|
+
platform: "node",
|
|
945
|
+
outfile: outfile2,
|
|
946
|
+
loader: loaders
|
|
947
|
+
});
|
|
948
|
+
let result;
|
|
949
|
+
try {
|
|
950
|
+
result = require(outfile2);
|
|
951
|
+
} catch (e) {
|
|
952
|
+
console.error("Unexpected error loading config");
|
|
953
|
+
console.error(e);
|
|
954
|
+
throw e;
|
|
955
|
+
}
|
|
956
|
+
import_fs_extra2.default.removeSync(outfile);
|
|
957
|
+
import_fs_extra2.default.removeSync(outfile2);
|
|
958
|
+
return {
|
|
959
|
+
config: result.default,
|
|
960
|
+
prebuildPath: prebuild,
|
|
961
|
+
watchList: flattenedList
|
|
962
|
+
};
|
|
997
963
|
}
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
964
|
+
};
|
|
965
|
+
var loaders = {
|
|
966
|
+
".aac": "file",
|
|
967
|
+
".css": "file",
|
|
968
|
+
".eot": "file",
|
|
969
|
+
".flac": "file",
|
|
970
|
+
".gif": "file",
|
|
971
|
+
".jpeg": "file",
|
|
972
|
+
".jpg": "file",
|
|
973
|
+
".json": "json",
|
|
974
|
+
".mp3": "file",
|
|
975
|
+
".mp4": "file",
|
|
976
|
+
".ogg": "file",
|
|
977
|
+
".otf": "file",
|
|
978
|
+
".png": "file",
|
|
979
|
+
".svg": "file",
|
|
980
|
+
".ttf": "file",
|
|
981
|
+
".wav": "file",
|
|
982
|
+
".webm": "file",
|
|
983
|
+
".webp": "file",
|
|
984
|
+
".woff": "file",
|
|
985
|
+
".woff2": "file",
|
|
986
|
+
".js": "jsx",
|
|
987
|
+
".jsx": "jsx",
|
|
988
|
+
".tsx": "tsx"
|
|
989
|
+
};
|
|
990
|
+
|
|
991
|
+
// src/next/commands/dev-command/html.ts
|
|
992
|
+
var errorHTML = `<style type="text/css">
|
|
993
|
+
#no-assets-placeholder body {
|
|
994
|
+
font-family: sans-serif;
|
|
995
|
+
font-size: 16px;
|
|
996
|
+
line-height: 1.4;
|
|
997
|
+
color: #333;
|
|
998
|
+
background-color: #f5f5f5;
|
|
999
|
+
}
|
|
1000
|
+
#no-assets-placeholder {
|
|
1001
|
+
max-width: 600px;
|
|
1002
|
+
margin: 0 auto;
|
|
1003
|
+
padding: 40px;
|
|
1004
|
+
text-align: center;
|
|
1005
|
+
background-color: #fff;
|
|
1006
|
+
box-shadow: 0px 0px 20px rgba(0, 0, 0, 0.1);
|
|
1007
|
+
}
|
|
1008
|
+
#no-assets-placeholder h1 {
|
|
1009
|
+
font-size: 24px;
|
|
1010
|
+
margin-bottom: 20px;
|
|
1011
|
+
}
|
|
1012
|
+
#no-assets-placeholder p {
|
|
1013
|
+
margin-bottom: 10px;
|
|
1014
|
+
}
|
|
1015
|
+
#no-assets-placeholder a {
|
|
1016
|
+
color: #0077cc;
|
|
1017
|
+
text-decoration: none;
|
|
1018
|
+
}
|
|
1019
|
+
#no-assets-placeholder a:hover {
|
|
1020
|
+
text-decoration: underline;
|
|
1021
|
+
}
|
|
1022
|
+
</style>
|
|
1023
|
+
<div id="no-assets-placeholder">
|
|
1024
|
+
<h1>Failed loading TinaCMS assets</h1>
|
|
1025
|
+
<p>
|
|
1026
|
+
Your TinaCMS configuration may be misconfigured, and we could not load
|
|
1027
|
+
the assets for this page.
|
|
1028
|
+
</p>
|
|
1029
|
+
<p>
|
|
1030
|
+
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.
|
|
1031
|
+
</p>
|
|
1032
|
+
</div>
|
|
1033
|
+
</div>`.trim().replace(/[\r\n\s]+/g, " ");
|
|
1034
|
+
var devHTML = (port) => `<!DOCTYPE html>
|
|
1035
|
+
<html lang="en">
|
|
1036
|
+
<head>
|
|
1037
|
+
<meta charset="UTF-8" />
|
|
1038
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
1039
|
+
<title>TinaCMS</title>
|
|
1040
|
+
</head>
|
|
1041
|
+
|
|
1042
|
+
<!-- if development -->
|
|
1043
|
+
<script type="module">
|
|
1044
|
+
import RefreshRuntime from 'http://localhost:${port}/@react-refresh'
|
|
1045
|
+
RefreshRuntime.injectIntoGlobalHook(window)
|
|
1046
|
+
window.$RefreshReg$ = () => {}
|
|
1047
|
+
window.$RefreshSig$ = () => (type) => type
|
|
1048
|
+
window.__vite_plugin_react_preamble_installed__ = true
|
|
1049
|
+
<\/script>
|
|
1050
|
+
<script type="module" src="http://localhost:${port}/@vite/client"><\/script>
|
|
1051
|
+
<script>
|
|
1052
|
+
function handleLoadError() {
|
|
1053
|
+
// Assets have failed to load
|
|
1054
|
+
document.getElementById('root').innerHTML = '${errorHTML}';
|
|
1001
1055
|
}
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
)
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
ignored: ["**/*"]
|
|
1028
|
-
} : {
|
|
1029
|
-
ignored: [
|
|
1030
|
-
`${configManager.tinaFolderPath}/**/!(config.prebuild.jsx|_graphql.json)`
|
|
1031
|
-
]
|
|
1032
|
-
},
|
|
1033
|
-
fs: {
|
|
1034
|
-
strict: false
|
|
1035
|
-
}
|
|
1036
|
-
},
|
|
1037
|
-
build: {
|
|
1038
|
-
sourcemap: false,
|
|
1039
|
-
outDir: configManager.outputFolderPath,
|
|
1040
|
-
emptyOutDir: true,
|
|
1041
|
-
rollupOptions
|
|
1042
|
-
},
|
|
1043
|
-
plugins: [
|
|
1044
|
-
(0, import_plugin_react.default)({
|
|
1045
|
-
babel: {
|
|
1046
|
-
compact: true
|
|
1047
|
-
}
|
|
1048
|
-
}),
|
|
1049
|
-
(0, import_vite.splitVendorChunkPlugin)(),
|
|
1050
|
-
tinaTailwind(configManager.spaRootPath, configManager.prebuildFilePath),
|
|
1051
|
-
...plugins
|
|
1052
|
-
]
|
|
1053
|
-
};
|
|
1054
|
-
return config2;
|
|
1056
|
+
<\/script>
|
|
1057
|
+
<script
|
|
1058
|
+
type="module"
|
|
1059
|
+
src="http://localhost:${port}/src/main.tsx"
|
|
1060
|
+
onerror="handleLoadError()"
|
|
1061
|
+
><\/script>
|
|
1062
|
+
<body class="tina-tailwind">
|
|
1063
|
+
<div id="root"></div>
|
|
1064
|
+
</body>
|
|
1065
|
+
</html>`;
|
|
1066
|
+
|
|
1067
|
+
// src/utils/theme.ts
|
|
1068
|
+
var import_chalk3 = __toESM(require("chalk"));
|
|
1069
|
+
var successText = import_chalk3.default.bold.green;
|
|
1070
|
+
var focusText = import_chalk3.default.bold;
|
|
1071
|
+
var dangerText = import_chalk3.default.bold.red;
|
|
1072
|
+
var neutralText = import_chalk3.default.bold.cyan;
|
|
1073
|
+
var linkText = import_chalk3.default.bold.cyan;
|
|
1074
|
+
var labelText = import_chalk3.default.bold;
|
|
1075
|
+
var cmdText = import_chalk3.default.inverse;
|
|
1076
|
+
var indentedCmd = (str) => {
|
|
1077
|
+
return ` \u2503 ` + str;
|
|
1078
|
+
};
|
|
1079
|
+
var indentText = (str) => {
|
|
1080
|
+
return String(str).split("\n").map((line) => ` ${line}`).join("\n");
|
|
1055
1081
|
};
|
|
1082
|
+
var logText = import_chalk3.default.italic.gray;
|
|
1083
|
+
var warnText = import_chalk3.default.yellowBright.bgBlack;
|
|
1084
|
+
var titleText = import_chalk3.default.bgHex("d2f1f8").hex("ec4816");
|
|
1085
|
+
var CONFIRMATION_TEXT = import_chalk3.default.dim("enter to confirm");
|
|
1086
|
+
|
|
1087
|
+
// src/next/commands/dev-command/server/index.ts
|
|
1088
|
+
var import_vite4 = require("vite");
|
|
1056
1089
|
|
|
1057
1090
|
// src/next/vite/plugins.ts
|
|
1058
1091
|
var import_pluginutils = require("@rollup/pluginutils");
|
|
1059
1092
|
var import_fs = __toESM(require("fs"));
|
|
1060
|
-
var
|
|
1093
|
+
var import_vite3 = require("vite");
|
|
1061
1094
|
var import_esbuild = require("esbuild");
|
|
1062
1095
|
var import_path3 = __toESM(require("path"));
|
|
1063
1096
|
var import_body_parser = __toESM(require("body-parser"));
|
|
@@ -1380,7 +1413,7 @@ function viteTransformExtension({
|
|
|
1380
1413
|
previousExport: exportAsDefault ? null : code
|
|
1381
1414
|
}
|
|
1382
1415
|
});
|
|
1383
|
-
const res = await (0,
|
|
1416
|
+
const res = await (0, import_vite3.transformWithEsbuild)(componentCode, id, {
|
|
1384
1417
|
loader: "jsx",
|
|
1385
1418
|
...esbuildOptions
|
|
1386
1419
|
});
|
|
@@ -1400,7 +1433,7 @@ var createDevServer = async (configManager, database, searchIndex, apiURL, noWat
|
|
|
1400
1433
|
devServerEndPointsPlugin({ apiURL, configManager, database, searchIndex }),
|
|
1401
1434
|
viteTransformExtension()
|
|
1402
1435
|
];
|
|
1403
|
-
return (0,
|
|
1436
|
+
return (0, import_vite4.createServer)(
|
|
1404
1437
|
await createConfig({
|
|
1405
1438
|
configManager,
|
|
1406
1439
|
database,
|
|
@@ -1415,6 +1448,10 @@ var createDevServer = async (configManager, database, searchIndex, apiURL, noWat
|
|
|
1415
1448
|
}
|
|
1416
1449
|
warn(warning);
|
|
1417
1450
|
}
|
|
1451
|
+
},
|
|
1452
|
+
viteConfigEnv: {
|
|
1453
|
+
command: "serve",
|
|
1454
|
+
mode: "development"
|
|
1418
1455
|
}
|
|
1419
1456
|
})
|
|
1420
1457
|
);
|
|
@@ -2209,7 +2246,7 @@ var BaseCommand = class extends import_clipanion.Command {
|
|
|
2209
2246
|
pathFilter
|
|
2210
2247
|
});
|
|
2211
2248
|
const tinaPathUpdates = modified.filter(
|
|
2212
|
-
(
|
|
2249
|
+
(path14) => path14.startsWith(".tina/__generated__/_schema.json") || path14.startsWith("tina/tina-lock.json")
|
|
2213
2250
|
);
|
|
2214
2251
|
if (tinaPathUpdates.length > 0) {
|
|
2215
2252
|
res = await database.indexContent({
|
|
@@ -2538,10 +2575,11 @@ var import_clipanion3 = require("clipanion");
|
|
|
2538
2575
|
var import_progress2 = __toESM(require("progress"));
|
|
2539
2576
|
var import_fs_extra7 = __toESM(require("fs-extra"));
|
|
2540
2577
|
var import_crypto = __toESM(require("crypto"));
|
|
2578
|
+
var import_path6 = __toESM(require("path"));
|
|
2541
2579
|
var import_graphql11 = require("@tinacms/graphql");
|
|
2542
2580
|
|
|
2543
2581
|
// src/next/commands/build-command/server.ts
|
|
2544
|
-
var
|
|
2582
|
+
var import_vite6 = require("vite");
|
|
2545
2583
|
var buildProductionSpa = async (configManager, database, apiURL) => {
|
|
2546
2584
|
const publicEnv = {};
|
|
2547
2585
|
Object.keys(process.env).forEach((key) => {
|
|
@@ -2573,9 +2611,13 @@ var buildProductionSpa = async (configManager, database, apiURL) => {
|
|
|
2573
2611
|
}
|
|
2574
2612
|
warn(warning);
|
|
2575
2613
|
}
|
|
2614
|
+
},
|
|
2615
|
+
viteConfigEnv: {
|
|
2616
|
+
command: "build",
|
|
2617
|
+
mode: "production"
|
|
2576
2618
|
}
|
|
2577
2619
|
});
|
|
2578
|
-
return (0,
|
|
2620
|
+
return (0, import_vite6.build)(config2);
|
|
2579
2621
|
};
|
|
2580
2622
|
|
|
2581
2623
|
// src/next/commands/build-command/index.ts
|
|
@@ -3174,7 +3216,6 @@ Additional info: Branch: ${config2.branch}, Client ID: ${config2.clientId} `;
|
|
|
3174
3216
|
url: `https://${host}/db/${clientId}/${previewName || branch}/schemaSha`,
|
|
3175
3217
|
token
|
|
3176
3218
|
});
|
|
3177
|
-
console.log({ remoteTinaSchemaSha });
|
|
3178
3219
|
if (!remoteTinaSchemaSha) {
|
|
3179
3220
|
bar2.tick({
|
|
3180
3221
|
prog: "\u274C"
|
|
@@ -3190,31 +3231,28 @@ Additional info: Branch: ${config2.branch}, Client ID: ${config2.clientId} `;
|
|
|
3190
3231
|
if (!database.bridge) {
|
|
3191
3232
|
throw new Error(`No bridge configured`);
|
|
3192
3233
|
}
|
|
3193
|
-
|
|
3194
|
-
|
|
3195
|
-
|
|
3196
|
-
)
|
|
3197
|
-
|
|
3198
|
-
|
|
3199
|
-
|
|
3200
|
-
|
|
3201
|
-
|
|
3202
|
-
|
|
3203
|
-
|
|
3204
|
-
|
|
3205
|
-
|
|
3206
|
-
|
|
3207
|
-
|
|
3208
|
-
|
|
3209
|
-
|
|
3210
|
-
|
|
3234
|
+
const localTinaSchema = JSON.parse(
|
|
3235
|
+
await database.bridge.get(
|
|
3236
|
+
import_path6.default.join(database.tinaDirectory, "__generated__", "_schema.json")
|
|
3237
|
+
)
|
|
3238
|
+
);
|
|
3239
|
+
localTinaSchema.version = void 0;
|
|
3240
|
+
const localTinaSchemaSha = import_crypto.default.createHash("sha256").update(JSON.stringify(localTinaSchema)).digest("hex");
|
|
3241
|
+
if (localTinaSchemaSha === remoteTinaSchemaSha) {
|
|
3242
|
+
bar2.tick({
|
|
3243
|
+
prog: "\u2705"
|
|
3244
|
+
});
|
|
3245
|
+
} else {
|
|
3246
|
+
bar2.tick({
|
|
3247
|
+
prog: "\u274C"
|
|
3248
|
+
});
|
|
3249
|
+
let errorMessage = `The local Tina schema doesn't match the remote Tina schema. Please push up your changes to GitHub to update your remote tina schema.`;
|
|
3250
|
+
if (config2 == null ? void 0 : config2.branch) {
|
|
3251
|
+
errorMessage += `
|
|
3211
3252
|
|
|
3212
3253
|
Additional info: Branch: ${config2.branch}, Client ID: ${config2.clientId} `;
|
|
3213
|
-
}
|
|
3214
|
-
throw new Error(errorMessage);
|
|
3215
3254
|
}
|
|
3216
|
-
|
|
3217
|
-
throw e;
|
|
3255
|
+
throw new Error(errorMessage);
|
|
3218
3256
|
}
|
|
3219
3257
|
}
|
|
3220
3258
|
};
|
|
@@ -3289,7 +3327,6 @@ var fetchSchemaSha = async ({
|
|
|
3289
3327
|
url,
|
|
3290
3328
|
token
|
|
3291
3329
|
}) => {
|
|
3292
|
-
console.log(url);
|
|
3293
3330
|
const headers = new Headers();
|
|
3294
3331
|
if (token) {
|
|
3295
3332
|
headers.append("X-API-KEY", token);
|
|
@@ -3299,9 +3336,7 @@ var fetchSchemaSha = async ({
|
|
|
3299
3336
|
headers,
|
|
3300
3337
|
cache: "no-cache"
|
|
3301
3338
|
});
|
|
3302
|
-
|
|
3303
|
-
console.log({ data });
|
|
3304
|
-
return (data == null ? void 0 : data.data) || {};
|
|
3339
|
+
return res.json();
|
|
3305
3340
|
};
|
|
3306
3341
|
|
|
3307
3342
|
// src/next/commands/audit-command/index.ts
|
|
@@ -3556,25 +3591,25 @@ var import_clipanion6 = require("clipanion");
|
|
|
3556
3591
|
|
|
3557
3592
|
// src/cmds/init/detectEnvironment.ts
|
|
3558
3593
|
var import_fs_extra8 = __toESM(require("fs-extra"));
|
|
3559
|
-
var
|
|
3594
|
+
var import_path7 = __toESM(require("path"));
|
|
3560
3595
|
var checkGitignoreForItem = async ({
|
|
3561
3596
|
baseDir,
|
|
3562
3597
|
line
|
|
3563
3598
|
}) => {
|
|
3564
|
-
const gitignoreContent = import_fs_extra8.default.readFileSync(
|
|
3599
|
+
const gitignoreContent = import_fs_extra8.default.readFileSync(import_path7.default.join(baseDir, ".gitignore")).toString();
|
|
3565
3600
|
return gitignoreContent.split("\n").some((item) => item === line);
|
|
3566
3601
|
};
|
|
3567
3602
|
var makeGeneratedFile = async (name2, generatedFileType, parentPath, opts) => {
|
|
3568
3603
|
const result = {
|
|
3569
|
-
fullPathTS:
|
|
3604
|
+
fullPathTS: import_path7.default.join(
|
|
3570
3605
|
parentPath,
|
|
3571
3606
|
`${name2}.${(opts == null ? void 0 : opts.typescriptSuffix) || (opts == null ? void 0 : opts.extensionOverride) || "ts"}`
|
|
3572
3607
|
),
|
|
3573
|
-
fullPathJS:
|
|
3608
|
+
fullPathJS: import_path7.default.join(
|
|
3574
3609
|
parentPath,
|
|
3575
3610
|
`${name2}.${(opts == null ? void 0 : opts.extensionOverride) || "js"}`
|
|
3576
3611
|
),
|
|
3577
|
-
fullPathOverride: (opts == null ? void 0 : opts.extensionOverride) ?
|
|
3612
|
+
fullPathOverride: (opts == null ? void 0 : opts.extensionOverride) ? import_path7.default.join(parentPath, `${name2}.${opts == null ? void 0 : opts.extensionOverride}`) : "",
|
|
3578
3613
|
generatedFileType,
|
|
3579
3614
|
name: name2,
|
|
3580
3615
|
parentPath,
|
|
@@ -3604,16 +3639,16 @@ var detectEnvironment = async ({
|
|
|
3604
3639
|
}) => {
|
|
3605
3640
|
var _a;
|
|
3606
3641
|
const hasForestryConfig = await import_fs_extra8.default.pathExists(
|
|
3607
|
-
|
|
3642
|
+
import_path7.default.join(pathToForestryConfig, ".forestry", "settings.yml")
|
|
3608
3643
|
);
|
|
3609
|
-
const sampleContentPath =
|
|
3644
|
+
const sampleContentPath = import_path7.default.join(
|
|
3610
3645
|
baseDir,
|
|
3611
3646
|
"content",
|
|
3612
3647
|
"posts",
|
|
3613
3648
|
"hello-world.md"
|
|
3614
3649
|
);
|
|
3615
|
-
const usingSrc = import_fs_extra8.default.pathExistsSync(
|
|
3616
|
-
const tinaFolder =
|
|
3650
|
+
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")));
|
|
3651
|
+
const tinaFolder = import_path7.default.join(baseDir, "tina");
|
|
3617
3652
|
const tinaConfigExists = Boolean(
|
|
3618
3653
|
await import_fs_extra8.default.pathExists(tinaFolder) && (await import_fs_extra8.default.readdir(tinaFolder)).find((x) => x.includes("config"))
|
|
3619
3654
|
);
|
|
@@ -3627,12 +3662,12 @@ var detectEnvironment = async ({
|
|
|
3627
3662
|
"next-api-handler": await makeGeneratedFile(
|
|
3628
3663
|
"[...routes]",
|
|
3629
3664
|
"next-api-handler",
|
|
3630
|
-
|
|
3665
|
+
import_path7.default.join(...pagesDir, "api", "tina")
|
|
3631
3666
|
),
|
|
3632
3667
|
"reactive-example": await makeGeneratedFile(
|
|
3633
3668
|
"[filename]",
|
|
3634
3669
|
"reactive-example",
|
|
3635
|
-
|
|
3670
|
+
import_path7.default.join(...pagesDir, "demo", "blog"),
|
|
3636
3671
|
{
|
|
3637
3672
|
typescriptSuffix: "tsx"
|
|
3638
3673
|
}
|
|
@@ -3640,13 +3675,13 @@ var detectEnvironment = async ({
|
|
|
3640
3675
|
"users-json": await makeGeneratedFile(
|
|
3641
3676
|
"index",
|
|
3642
3677
|
"users-json",
|
|
3643
|
-
|
|
3678
|
+
import_path7.default.join(baseDir, "content", "users"),
|
|
3644
3679
|
{ extensionOverride: "json" }
|
|
3645
3680
|
),
|
|
3646
3681
|
"sample-content": await makeGeneratedFile(
|
|
3647
3682
|
"hello-world",
|
|
3648
3683
|
"sample-content",
|
|
3649
|
-
|
|
3684
|
+
import_path7.default.join(baseDir, "content", "posts"),
|
|
3650
3685
|
{ extensionOverride: "md" }
|
|
3651
3686
|
)
|
|
3652
3687
|
};
|
|
@@ -3672,13 +3707,13 @@ var detectEnvironment = async ({
|
|
|
3672
3707
|
);
|
|
3673
3708
|
}
|
|
3674
3709
|
}
|
|
3675
|
-
const hasGitIgnore = await import_fs_extra8.default.pathExists(
|
|
3710
|
+
const hasGitIgnore = await import_fs_extra8.default.pathExists(import_path7.default.join(".gitignore"));
|
|
3676
3711
|
const hasGitIgnoreNodeModules = hasGitIgnore && await checkGitignoreForItem({ baseDir, line: "node_modules" });
|
|
3677
3712
|
const hasEnvTina = hasGitIgnore && await checkGitignoreForItem({ baseDir, line: ".env.tina" });
|
|
3678
3713
|
const hasGitIgnoreEnv = hasGitIgnore && await checkGitignoreForItem({ baseDir, line: ".env" });
|
|
3679
3714
|
let frontMatterFormat;
|
|
3680
3715
|
if (hasForestryConfig) {
|
|
3681
|
-
const hugoConfigPath =
|
|
3716
|
+
const hugoConfigPath = import_path7.default.join(rootPath, "config.toml");
|
|
3682
3717
|
if (await import_fs_extra8.default.pathExists(hugoConfigPath)) {
|
|
3683
3718
|
const hugoConfig = await import_fs_extra8.default.readFile(hugoConfigPath, "utf8");
|
|
3684
3719
|
const metaDataFormat = (_a = hugoConfig.match(/metaDataFormat = "(.*)"/)) == null ? void 0 : _a[1];
|
|
@@ -4286,18 +4321,18 @@ var CLICommand = class {
|
|
|
4286
4321
|
};
|
|
4287
4322
|
|
|
4288
4323
|
// src/cmds/init/apply.ts
|
|
4289
|
-
var
|
|
4324
|
+
var import_path11 = __toESM(require("path"));
|
|
4290
4325
|
|
|
4291
4326
|
// src/cmds/forestry-migrate/index.ts
|
|
4292
4327
|
var import_fs_extra10 = __toESM(require("fs-extra"));
|
|
4293
|
-
var
|
|
4328
|
+
var import_path9 = __toESM(require("path"));
|
|
4294
4329
|
var import_js_yaml2 = __toESM(require("js-yaml"));
|
|
4295
4330
|
var import_minimatch = __toESM(require("minimatch"));
|
|
4296
4331
|
var import_graphql16 = require("@tinacms/graphql");
|
|
4297
4332
|
|
|
4298
4333
|
// src/cmds/forestry-migrate/util/index.ts
|
|
4299
4334
|
var import_fs_extra9 = __toESM(require("fs-extra"));
|
|
4300
|
-
var
|
|
4335
|
+
var import_path8 = __toESM(require("path"));
|
|
4301
4336
|
var import_js_yaml = __toESM(require("js-yaml"));
|
|
4302
4337
|
var import_zod = __toESM(require("zod"));
|
|
4303
4338
|
|
|
@@ -4708,7 +4743,7 @@ var transformForestryFieldsToTinaFields = ({
|
|
|
4708
4743
|
return tinaFields;
|
|
4709
4744
|
};
|
|
4710
4745
|
var getFieldsFromTemplates = ({ tem, pathToForestryConfig, skipBlocks = false }) => {
|
|
4711
|
-
const templatePath =
|
|
4746
|
+
const templatePath = import_path8.default.join(
|
|
4712
4747
|
pathToForestryConfig,
|
|
4713
4748
|
".forestry",
|
|
4714
4749
|
"front_matter",
|
|
@@ -4783,8 +4818,8 @@ var generateAllTemplates = async ({
|
|
|
4783
4818
|
pathToForestryConfig
|
|
4784
4819
|
}) => {
|
|
4785
4820
|
const allTemplates = (await import_fs_extra10.default.readdir(
|
|
4786
|
-
|
|
4787
|
-
)).map((tem) =>
|
|
4821
|
+
import_path9.default.join(pathToForestryConfig, ".forestry", "front_matter", "templates")
|
|
4822
|
+
)).map((tem) => import_path9.default.basename(tem, ".yml"));
|
|
4788
4823
|
const templateMap = /* @__PURE__ */ new Map();
|
|
4789
4824
|
const proms = allTemplates.map(async (tem) => {
|
|
4790
4825
|
try {
|
|
@@ -4926,9 +4961,9 @@ var generateCollectionFromForestrySection = (args) => {
|
|
|
4926
4961
|
return c;
|
|
4927
4962
|
} else if (section.type === "document") {
|
|
4928
4963
|
const filePath = section.path;
|
|
4929
|
-
const extname =
|
|
4930
|
-
const fileName =
|
|
4931
|
-
const dir =
|
|
4964
|
+
const extname = import_path9.default.extname(filePath);
|
|
4965
|
+
const fileName = import_path9.default.basename(filePath, extname);
|
|
4966
|
+
const dir = import_path9.default.dirname(filePath);
|
|
4932
4967
|
const ext = checkExt(extname);
|
|
4933
4968
|
if (ext) {
|
|
4934
4969
|
const fields = [];
|
|
@@ -4991,7 +5026,7 @@ var generateCollections = async ({
|
|
|
4991
5026
|
usingTypescript
|
|
4992
5027
|
});
|
|
4993
5028
|
const forestryConfig = await import_fs_extra10.default.readFile(
|
|
4994
|
-
|
|
5029
|
+
import_path9.default.join(pathToForestryConfig, ".forestry", "settings.yml")
|
|
4995
5030
|
);
|
|
4996
5031
|
rewriteTemplateKeysInDocs({
|
|
4997
5032
|
templateMap,
|
|
@@ -5022,11 +5057,11 @@ var rewriteTemplateKeysInDocs = (args) => {
|
|
|
5022
5057
|
const { templateObj } = templateMap.get(templateKey);
|
|
5023
5058
|
(_a = templateObj == null ? void 0 : templateObj.pages) == null ? void 0 : _a.forEach((page) => {
|
|
5024
5059
|
try {
|
|
5025
|
-
const filePath =
|
|
5060
|
+
const filePath = import_path9.default.join(page);
|
|
5026
5061
|
if (import_fs_extra10.default.lstatSync(filePath).isDirectory()) {
|
|
5027
5062
|
return;
|
|
5028
5063
|
}
|
|
5029
|
-
const extname =
|
|
5064
|
+
const extname = import_path9.default.extname(filePath);
|
|
5030
5065
|
const fileContent = import_fs_extra10.default.readFileSync(filePath).toString();
|
|
5031
5066
|
const content = (0, import_graphql16.parseFile)(
|
|
5032
5067
|
fileContent,
|
|
@@ -5058,7 +5093,7 @@ var import_fs_extra13 = __toESM(require("fs-extra"));
|
|
|
5058
5093
|
// src/next/commands/codemod-command/index.ts
|
|
5059
5094
|
var import_clipanion5 = require("clipanion");
|
|
5060
5095
|
var import_fs_extra11 = __toESM(require("fs-extra"));
|
|
5061
|
-
var
|
|
5096
|
+
var import_path10 = __toESM(require("path"));
|
|
5062
5097
|
var CodemodCommand = class extends import_clipanion5.Command {
|
|
5063
5098
|
constructor() {
|
|
5064
5099
|
super(...arguments);
|
|
@@ -5102,7 +5137,7 @@ var moveTinaFolder = async (rootPath = process.cwd()) => {
|
|
|
5102
5137
|
logger.error(e.message);
|
|
5103
5138
|
process.exit(1);
|
|
5104
5139
|
}
|
|
5105
|
-
const tinaDestination =
|
|
5140
|
+
const tinaDestination = import_path10.default.join(configManager.rootPath, "tina");
|
|
5106
5141
|
if (await import_fs_extra11.default.existsSync(tinaDestination)) {
|
|
5107
5142
|
logger.info(
|
|
5108
5143
|
`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.`
|
|
@@ -5117,7 +5152,7 @@ var moveTinaFolder = async (rootPath = process.cwd()) => {
|
|
|
5117
5152
|
};
|
|
5118
5153
|
var writeGitignore = async (rootPath) => {
|
|
5119
5154
|
await import_fs_extra11.default.outputFileSync(
|
|
5120
|
-
|
|
5155
|
+
import_path10.default.join(rootPath, "tina", ".gitignore"),
|
|
5121
5156
|
"__generated__"
|
|
5122
5157
|
);
|
|
5123
5158
|
};
|
|
@@ -5955,8 +5990,8 @@ async function apply({
|
|
|
5955
5990
|
await addConfigFile({
|
|
5956
5991
|
configArgs: {
|
|
5957
5992
|
config: config2,
|
|
5958
|
-
publicFolder:
|
|
5959
|
-
|
|
5993
|
+
publicFolder: import_path11.default.join(
|
|
5994
|
+
import_path11.default.relative(process.cwd(), pathToForestryConfig),
|
|
5960
5995
|
config2.publicFolder
|
|
5961
5996
|
),
|
|
5962
5997
|
collections,
|
|
@@ -6023,18 +6058,18 @@ var createPackageJSON = async () => {
|
|
|
6023
6058
|
};
|
|
6024
6059
|
var createGitignore = async ({ baseDir }) => {
|
|
6025
6060
|
logger.info(logText("No .gitignore found, creating one"));
|
|
6026
|
-
import_fs_extra13.default.outputFileSync(
|
|
6061
|
+
import_fs_extra13.default.outputFileSync(import_path11.default.join(baseDir, ".gitignore"), "node_modules");
|
|
6027
6062
|
};
|
|
6028
6063
|
var updateGitIgnore = async ({
|
|
6029
6064
|
baseDir,
|
|
6030
6065
|
items
|
|
6031
6066
|
}) => {
|
|
6032
6067
|
logger.info(logText(`Adding ${items.join(",")} to .gitignore`));
|
|
6033
|
-
const gitignoreContent = import_fs_extra13.default.readFileSync(
|
|
6068
|
+
const gitignoreContent = import_fs_extra13.default.readFileSync(import_path11.default.join(baseDir, ".gitignore")).toString();
|
|
6034
6069
|
const newGitignoreContent = [...gitignoreContent.split("\n"), ...items].join(
|
|
6035
6070
|
"\n"
|
|
6036
6071
|
);
|
|
6037
|
-
await import_fs_extra13.default.writeFile(
|
|
6072
|
+
await import_fs_extra13.default.writeFile(import_path11.default.join(baseDir, ".gitignore"), newGitignoreContent);
|
|
6038
6073
|
};
|
|
6039
6074
|
var addDependencies = async (config2, env, params) => {
|
|
6040
6075
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
@@ -6104,22 +6139,22 @@ var writeGeneratedFile = async ({
|
|
|
6104
6139
|
content,
|
|
6105
6140
|
typescript
|
|
6106
6141
|
}) => {
|
|
6107
|
-
const { exists, path:
|
|
6142
|
+
const { exists, path: path14, parentPath } = generatedFile.resolve(typescript);
|
|
6108
6143
|
if (exists) {
|
|
6109
6144
|
if (overwrite) {
|
|
6110
|
-
logger.info(`Overwriting file at ${
|
|
6111
|
-
import_fs_extra13.default.outputFileSync(
|
|
6145
|
+
logger.info(`Overwriting file at ${path14}... \u2705`);
|
|
6146
|
+
import_fs_extra13.default.outputFileSync(path14, content);
|
|
6112
6147
|
} else {
|
|
6113
|
-
logger.info(`Not overwriting file at ${
|
|
6148
|
+
logger.info(`Not overwriting file at ${path14}.`);
|
|
6114
6149
|
logger.info(
|
|
6115
|
-
logText(`Please add the following to ${
|
|
6150
|
+
logText(`Please add the following to ${path14}:
|
|
6116
6151
|
${indentText(content)}}`)
|
|
6117
6152
|
);
|
|
6118
6153
|
}
|
|
6119
6154
|
} else {
|
|
6120
|
-
logger.info(`Adding file at ${
|
|
6155
|
+
logger.info(`Adding file at ${path14}... \u2705`);
|
|
6121
6156
|
await import_fs_extra13.default.ensureDir(parentPath);
|
|
6122
|
-
import_fs_extra13.default.outputFileSync(
|
|
6157
|
+
import_fs_extra13.default.outputFileSync(path14, content);
|
|
6123
6158
|
}
|
|
6124
6159
|
};
|
|
6125
6160
|
var addConfigFile = async ({
|
|
@@ -6202,7 +6237,7 @@ var addContentFile = async ({
|
|
|
6202
6237
|
return () => ({
|
|
6203
6238
|
exists: env.sampleContentExists,
|
|
6204
6239
|
path: env.sampleContentPath,
|
|
6205
|
-
parentPath:
|
|
6240
|
+
parentPath: import_path11.default.dirname(env.sampleContentPath)
|
|
6206
6241
|
});
|
|
6207
6242
|
}
|
|
6208
6243
|
},
|
|
@@ -6225,7 +6260,7 @@ ${titleText(" TinaCMS ")} backend initialized!`));
|
|
|
6225
6260
|
return `${x.key}=${x.value || "***"}`;
|
|
6226
6261
|
}).join("\n") + `
|
|
6227
6262
|
TINA_PUBLIC_IS_LOCAL=true`;
|
|
6228
|
-
const envFile =
|
|
6263
|
+
const envFile = import_path11.default.join(process.cwd(), ".env");
|
|
6229
6264
|
if (!import_fs_extra13.default.existsSync(envFile)) {
|
|
6230
6265
|
logger.info(`Adding .env file to your project... \u2705`);
|
|
6231
6266
|
import_fs_extra13.default.writeFileSync(envFile, envFileText);
|
|
@@ -6289,7 +6324,7 @@ var addReactiveFile = {
|
|
|
6289
6324
|
dataLayer
|
|
6290
6325
|
}) => {
|
|
6291
6326
|
var _a, _b;
|
|
6292
|
-
const packageJsonPath =
|
|
6327
|
+
const packageJsonPath = import_path11.default.join(baseDir, "package.json");
|
|
6293
6328
|
await writeGeneratedFile({
|
|
6294
6329
|
generatedFile,
|
|
6295
6330
|
typescript: config2.typescript,
|