@tinacms/cli 1.7.0 → 1.8.0
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 +147 -36
- package/dist/next/vite/index.d.ts +1 -1
- package/package.json +7 -7
package/dist/index.js
CHANGED
|
@@ -17,6 +17,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
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.
|
|
20
24
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
25
|
mod
|
|
22
26
|
));
|
|
@@ -31,7 +35,7 @@ module.exports = __toCommonJS(src_exports);
|
|
|
31
35
|
var import_clipanion8 = require("clipanion");
|
|
32
36
|
|
|
33
37
|
// package.json
|
|
34
|
-
var version = "1.
|
|
38
|
+
var version = "1.8.0";
|
|
35
39
|
|
|
36
40
|
// src/next/commands/dev-command/index.ts
|
|
37
41
|
var import_clipanion2 = require("clipanion");
|
|
@@ -57,7 +61,10 @@ function isUnicodeSupported() {
|
|
|
57
61
|
if (process.platform !== "win32") {
|
|
58
62
|
return process.env.TERM !== "linux";
|
|
59
63
|
}
|
|
60
|
-
return Boolean(process.env.CI) || Boolean(process.env.WT_SESSION) ||
|
|
64
|
+
return Boolean(process.env.CI) || Boolean(process.env.WT_SESSION) || // Windows Terminal
|
|
65
|
+
Boolean(process.env.TERMINUS_SUBLIME) || // Terminus (<0.2.27)
|
|
66
|
+
process.env.ConEmuTask === "{cmd::Cmder}" || // ConEmu and cmder
|
|
67
|
+
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
68
|
}
|
|
62
69
|
|
|
63
70
|
// src/logger/index.ts
|
|
@@ -212,7 +219,7 @@ var ConfigManager = class {
|
|
|
212
219
|
this.generatedCachePath = import_path.default.join(
|
|
213
220
|
this.generatedFolderPath,
|
|
214
221
|
".cache",
|
|
215
|
-
String(new Date().getTime())
|
|
222
|
+
String((/* @__PURE__ */ new Date()).getTime())
|
|
216
223
|
);
|
|
217
224
|
this.generatedGraphQLGQLPath = import_path.default.join(
|
|
218
225
|
this.generatedFolderPath,
|
|
@@ -399,6 +406,9 @@ var ConfigManager = class {
|
|
|
399
406
|
}
|
|
400
407
|
throw `No path provided to print`;
|
|
401
408
|
}
|
|
409
|
+
/**
|
|
410
|
+
* Given a filepath without an extension, find the first match (eg. tsx, ts, jsx, js)
|
|
411
|
+
*/
|
|
402
412
|
async getPathWithExtension(filepath) {
|
|
403
413
|
const extensions = ["tsx", "ts", "jsx", "js"];
|
|
404
414
|
let result;
|
|
@@ -432,7 +442,10 @@ var ConfigManager = class {
|
|
|
432
442
|
}
|
|
433
443
|
async loadConfigFile(generatedFolderPath, configFilePath) {
|
|
434
444
|
const tmpdir = import_path.default.join(import_os.default.tmpdir(), Date.now().toString());
|
|
435
|
-
const
|
|
445
|
+
const preBuildConfigPath = import_path.default.join(
|
|
446
|
+
this.generatedFolderPath,
|
|
447
|
+
"config.prebuild.jsx"
|
|
448
|
+
);
|
|
436
449
|
const outfile = import_path.default.join(tmpdir, "config.build.jsx");
|
|
437
450
|
const outfile2 = import_path.default.join(tmpdir, "config.build.js");
|
|
438
451
|
const tempTSConfigFile = import_path.default.join(tmpdir, "tsconfig.json");
|
|
@@ -446,7 +459,7 @@ var ConfigManager = class {
|
|
|
446
459
|
logLevel: "silent",
|
|
447
460
|
packages: "external",
|
|
448
461
|
ignoreAnnotations: true,
|
|
449
|
-
outfile:
|
|
462
|
+
outfile: preBuildConfigPath,
|
|
450
463
|
loader: loaders,
|
|
451
464
|
metafile: true
|
|
452
465
|
});
|
|
@@ -469,6 +482,7 @@ var ConfigManager = class {
|
|
|
469
482
|
await esbuild.build({
|
|
470
483
|
entryPoints: [outfile],
|
|
471
484
|
bundle: true,
|
|
485
|
+
// Suppress warning about comparison with -0 from client module
|
|
472
486
|
logLevel: "silent",
|
|
473
487
|
platform: "node",
|
|
474
488
|
outfile: outfile2,
|
|
@@ -486,7 +500,7 @@ var ConfigManager = class {
|
|
|
486
500
|
import_fs_extra.default.removeSync(outfile2);
|
|
487
501
|
return {
|
|
488
502
|
config: result.default,
|
|
489
|
-
prebuildPath:
|
|
503
|
+
prebuildPath: preBuildConfigPath,
|
|
490
504
|
watchList: flattenedList
|
|
491
505
|
};
|
|
492
506
|
}
|
|
@@ -575,19 +589,19 @@ var devHTML = (port) => `<!DOCTYPE html>
|
|
|
575
589
|
window.$RefreshReg$ = () => {}
|
|
576
590
|
window.$RefreshSig$ = () => (type) => type
|
|
577
591
|
window.__vite_plugin_react_preamble_installed__ = true
|
|
578
|
-
|
|
579
|
-
<script type="module" src="http://localhost:${port}/@vite/client"
|
|
592
|
+
</script>
|
|
593
|
+
<script type="module" src="http://localhost:${port}/@vite/client"></script>
|
|
580
594
|
<script>
|
|
581
595
|
function handleLoadError() {
|
|
582
596
|
// Assets have failed to load
|
|
583
597
|
document.getElementById('root').innerHTML = '${errorHTML}';
|
|
584
598
|
}
|
|
585
|
-
|
|
599
|
+
</script>
|
|
586
600
|
<script
|
|
587
601
|
type="module"
|
|
588
602
|
src="http://localhost:${port}/src/main.tsx"
|
|
589
603
|
onerror="handleLoadError()"
|
|
590
|
-
|
|
604
|
+
></script>
|
|
591
605
|
<body class="tina-tailwind">
|
|
592
606
|
<div id="root"></div>
|
|
593
607
|
</body>
|
|
@@ -633,6 +647,7 @@ var import_defaultTheme = __toESM(require("tailwindcss/defaultTheme.js"));
|
|
|
633
647
|
var tinaTailwind = (spaPath, prebuildFilePath) => {
|
|
634
648
|
return {
|
|
635
649
|
name: "vite-plugin-tina",
|
|
650
|
+
// @ts-ignore
|
|
636
651
|
config: (viteConfig) => {
|
|
637
652
|
const plugins = [];
|
|
638
653
|
const content = [
|
|
@@ -944,7 +959,6 @@ async function listFilesRecursively({
|
|
|
944
959
|
}
|
|
945
960
|
var createConfig = async ({
|
|
946
961
|
configManager,
|
|
947
|
-
database,
|
|
948
962
|
apiURL,
|
|
949
963
|
plugins = [],
|
|
950
964
|
noWatch,
|
|
@@ -1017,15 +1031,33 @@ var createConfig = async ({
|
|
|
1017
1031
|
dedupe: ["graphql", "tinacms", "react", "react-dom", "react-router-dom"]
|
|
1018
1032
|
},
|
|
1019
1033
|
define: {
|
|
1034
|
+
/**
|
|
1035
|
+
* Since we prebuild the config.ts, it's possible for modules to be loaded which make
|
|
1036
|
+
* use of `process`. The main scenario where this is an issue is when co-locating schema
|
|
1037
|
+
* definitions with source files, and specifically source files which impor from NextJS.
|
|
1038
|
+
*
|
|
1039
|
+
* Some examples of what NextJS uses for `process.env` are:
|
|
1040
|
+
* - `process.env.__NEXT_TRAILING_SLASH`
|
|
1041
|
+
* - `process.env.__NEXT_CROSS_ORIGIN`
|
|
1042
|
+
* - `process.env.__NEXT_I18N_SUPPORT`
|
|
1043
|
+
*
|
|
1044
|
+
* Also, interestingly some of the advice for handling this doesn't work, references to replacing
|
|
1045
|
+
* `process.env` with `{}` are problematic, because browsers don't understand the `{}.` syntax,
|
|
1046
|
+
* but node does. This was a surprise, but using `new Object()` seems to do the trick.
|
|
1047
|
+
*/
|
|
1020
1048
|
"process.env": `new Object(${JSON.stringify(publicEnv)})`,
|
|
1049
|
+
// Used by picomatch https://github.com/micromatch/picomatch/blob/master/lib/utils.js#L4
|
|
1021
1050
|
"process.platform": `"${process.platform}"`,
|
|
1022
1051
|
__API_URL__: `"${apiURL}"`,
|
|
1023
1052
|
__BASE_PATH__: `"${((_e = (_d = configManager.config) == null ? void 0 : _d.build) == null ? void 0 : _e.basePath) || ""}"`,
|
|
1024
1053
|
__TINA_GRAPHQL_VERSION__: version2
|
|
1025
1054
|
},
|
|
1026
1055
|
logLevel: "error",
|
|
1056
|
+
// Vite import warnings are noisy
|
|
1027
1057
|
optimizeDeps: {
|
|
1028
1058
|
force: true,
|
|
1059
|
+
// Not 100% sure why this isn't being picked up automatically, this works from within the monorepo
|
|
1060
|
+
// but breaks externally
|
|
1029
1061
|
include: ["react/jsx-runtime", "react/jsx-dev-runtime"]
|
|
1030
1062
|
},
|
|
1031
1063
|
server: {
|
|
@@ -1033,6 +1065,7 @@ var createConfig = async ({
|
|
|
1033
1065
|
watch: noWatch ? {
|
|
1034
1066
|
ignored: ["**/*"]
|
|
1035
1067
|
} : {
|
|
1068
|
+
// Ignore everything except for the alias fields we specified above
|
|
1036
1069
|
ignored: [
|
|
1037
1070
|
`${configManager.tinaFolderPath}/**/!(config.prebuild.jsx|_graphql.json)`
|
|
1038
1071
|
]
|
|
@@ -1048,8 +1081,13 @@ var createConfig = async ({
|
|
|
1048
1081
|
rollupOptions
|
|
1049
1082
|
},
|
|
1050
1083
|
plugins: [
|
|
1084
|
+
/**
|
|
1085
|
+
* `splitVendorChunkPlugin` is needed because `tinacms` is quite large,
|
|
1086
|
+
* Vite's chunking strategy chokes on memory issues for smaller machines (ie. on CI).
|
|
1087
|
+
*/
|
|
1051
1088
|
(0, import_plugin_react.default)({
|
|
1052
1089
|
babel: {
|
|
1090
|
+
// Supresses the warning [NOTE] babel The code generator has deoptimised the styling of
|
|
1053
1091
|
compact: true
|
|
1054
1092
|
}
|
|
1055
1093
|
}),
|
|
@@ -1126,8 +1164,7 @@ var createMediaRouter = (config2) => {
|
|
|
1126
1164
|
};
|
|
1127
1165
|
var parseMediaFolder = (str) => {
|
|
1128
1166
|
let returnString = str;
|
|
1129
|
-
if (returnString.startsWith("/"))
|
|
1130
|
-
returnString = returnString.substr(1);
|
|
1167
|
+
if (returnString.startsWith("/")) returnString = returnString.substr(1);
|
|
1131
1168
|
if (returnString.endsWith("/"))
|
|
1132
1169
|
returnString = returnString.substr(0, returnString.length - 1);
|
|
1133
1170
|
return returnString;
|
|
@@ -1394,6 +1431,7 @@ function viteTransformExtension({
|
|
|
1394
1431
|
return {
|
|
1395
1432
|
code: res.code,
|
|
1396
1433
|
map: null
|
|
1434
|
+
// TODO:
|
|
1397
1435
|
};
|
|
1398
1436
|
}
|
|
1399
1437
|
}
|
|
@@ -1414,6 +1452,14 @@ var createDevServer = async (configManager, database, searchIndex, apiURL, noWat
|
|
|
1414
1452
|
apiURL,
|
|
1415
1453
|
plugins,
|
|
1416
1454
|
noWatch,
|
|
1455
|
+
/**
|
|
1456
|
+
* Ensure Vite's import scan uses the spaMainPath as the input
|
|
1457
|
+
* so it properly finds everything. This is for dev only, and when
|
|
1458
|
+
* running the server outside of this monorepo vite fails to find
|
|
1459
|
+
* and optimize the imports, so you get errors about it not being
|
|
1460
|
+
* able to find an export from a module, and it's always a CJS
|
|
1461
|
+
* module that Vite would usually transform to an ES module.
|
|
1462
|
+
*/
|
|
1417
1463
|
rollupOptions: {
|
|
1418
1464
|
input: configManager.spaMainPath,
|
|
1419
1465
|
onwarn(warning, warn) {
|
|
@@ -1539,6 +1585,7 @@ var GenericSdkVisitor = class extends import_visitor_plugin_common.ClientSideBas
|
|
|
1539
1585
|
node,
|
|
1540
1586
|
documentVariableName,
|
|
1541
1587
|
operationType,
|
|
1588
|
+
// This is the only line that is different
|
|
1542
1589
|
operationResultType: `{data: ${operationResultType}, errors?: { message: string, locations: { line: number, column: number }[], path: string[] }[], variables: ${operationVariablesTypes}, query: string}`,
|
|
1543
1590
|
operationVariablesTypes
|
|
1544
1591
|
});
|
|
@@ -1587,6 +1634,8 @@ var plugin = (schema, documents, config2) => {
|
|
|
1587
1634
|
const visitor = new GenericSdkVisitor(schema, allFragments, config2);
|
|
1588
1635
|
const visitorResult = (0, import_graphql3.visit)(allAst, { leave: visitor });
|
|
1589
1636
|
return {
|
|
1637
|
+
// We will take care of imports
|
|
1638
|
+
// prepend: visitor.getImports(),
|
|
1590
1639
|
content: [
|
|
1591
1640
|
visitor.fragments,
|
|
1592
1641
|
...visitorResult.definitions.filter((t) => typeof t === "string"),
|
|
@@ -1602,6 +1651,7 @@ var generateTypes = async (schema, queryPathGlob = process.cwd(), fragDocPath =
|
|
|
1602
1651
|
docs = await loadGraphQLDocuments(queryPathGlob);
|
|
1603
1652
|
fragDocs = await loadGraphQLDocuments(fragDocPath);
|
|
1604
1653
|
const res = await (0, import_core.codegen)({
|
|
1654
|
+
// Filename is not used. This is because the typescript plugin returns a string instead of writing to a file.
|
|
1605
1655
|
filename: process.cwd(),
|
|
1606
1656
|
schema: (0, import_graphql5.parse)((0, import_graphql5.printSchema)(schema)),
|
|
1607
1657
|
documents: [...docs, ...fragDocs],
|
|
@@ -1636,9 +1686,12 @@ var loadGraphQLDocuments = async (globPath) => {
|
|
|
1636
1686
|
loaders: [new import_graphql_file_loader.GraphQLFileLoader()]
|
|
1637
1687
|
});
|
|
1638
1688
|
} catch (e) {
|
|
1639
|
-
if (
|
|
1640
|
-
|
|
1641
|
-
|
|
1689
|
+
if (
|
|
1690
|
+
// https://www.graphql-tools.com/docs/documents-loading#no-files-found
|
|
1691
|
+
(e.message || "").includes(
|
|
1692
|
+
"Unable to find any GraphQL type definitions for the following pointers:"
|
|
1693
|
+
)
|
|
1694
|
+
) {
|
|
1642
1695
|
} else {
|
|
1643
1696
|
throw e;
|
|
1644
1697
|
}
|
|
@@ -1800,12 +1853,9 @@ var Codegen = class {
|
|
|
1800
1853
|
const baseUrl = ((_d = this.configManager.config.tinaioConfig) == null ? void 0 : _d.contentApiUrlOverride) || `https://${TINA_HOST}`;
|
|
1801
1854
|
if ((!branch || !clientId || !token) && !this.port && !this.configManager.config.contentApiUrlOverride) {
|
|
1802
1855
|
const missing = [];
|
|
1803
|
-
if (!branch)
|
|
1804
|
-
|
|
1805
|
-
if (!
|
|
1806
|
-
missing.push("clientId");
|
|
1807
|
-
if (!token)
|
|
1808
|
-
missing.push("token");
|
|
1856
|
+
if (!branch) missing.push("branch");
|
|
1857
|
+
if (!clientId) missing.push("clientId");
|
|
1858
|
+
if (!token) missing.push("token");
|
|
1809
1859
|
throw new Error(
|
|
1810
1860
|
`Client not configured properly. Missing ${missing.join(
|
|
1811
1861
|
", "
|
|
@@ -1959,7 +2009,11 @@ schema {
|
|
|
1959
2009
|
}
|
|
1960
2010
|
};
|
|
1961
2011
|
var maybeWarnFragmentSize = async (filepath) => {
|
|
1962
|
-
if (
|
|
2012
|
+
if (
|
|
2013
|
+
// is the file bigger than 100kb?
|
|
2014
|
+
(await import_fs_extra4.default.stat(filepath)).size > // convert to 100 kb to bytes
|
|
2015
|
+
100 * 1024
|
|
2016
|
+
) {
|
|
1963
2017
|
console.warn(
|
|
1964
2018
|
"Warning: frags.gql is very large (>100kb). Consider setting the reference depth to 1 or 0. See code snippet below."
|
|
1965
2019
|
);
|
|
@@ -1987,6 +2041,7 @@ var import_many_level = require("many-level");
|
|
|
1987
2041
|
var import_memory_level = require("memory-level");
|
|
1988
2042
|
var createDBServer = (port) => {
|
|
1989
2043
|
const levelHost = new import_many_level.ManyLevelHost(
|
|
2044
|
+
// @ts-ignore
|
|
1990
2045
|
new import_memory_level.MemoryLevel({
|
|
1991
2046
|
valueEncoding: "json"
|
|
1992
2047
|
})
|
|
@@ -2261,6 +2316,7 @@ var import_search = require("@tinacms/search");
|
|
|
2261
2316
|
var DevCommand = class extends BaseCommand {
|
|
2262
2317
|
constructor() {
|
|
2263
2318
|
super(...arguments);
|
|
2319
|
+
// NOTE: camelCase commands for string options don't work if there's an `=` used https://github.com/arcanis/clipanion/issues/141
|
|
2264
2320
|
this.watchFolders = import_clipanion2.Option.String("-w,--watchFolders", {
|
|
2265
2321
|
description: "DEPRECATED - a list of folders (relative to where this is being run) that the cli will watch for changes"
|
|
2266
2322
|
});
|
|
@@ -2479,6 +2535,20 @@ ${dangerText(e.message)}
|
|
|
2479
2535
|
heading: "Tina Dev Server is running...",
|
|
2480
2536
|
items: [
|
|
2481
2537
|
...summaryItems
|
|
2538
|
+
// {
|
|
2539
|
+
// emoji: '📚',
|
|
2540
|
+
// heading: 'Useful links',
|
|
2541
|
+
// subItems: [
|
|
2542
|
+
// {
|
|
2543
|
+
// key: 'Custom queries',
|
|
2544
|
+
// value: 'https://tina.io/querying',
|
|
2545
|
+
// },
|
|
2546
|
+
// {
|
|
2547
|
+
// key: 'Visual editing',
|
|
2548
|
+
// value: 'https://tina.io/visual-editing',
|
|
2549
|
+
// },
|
|
2550
|
+
// ],
|
|
2551
|
+
// },
|
|
2482
2552
|
]
|
|
2483
2553
|
});
|
|
2484
2554
|
await this.startSubCommand();
|
|
@@ -2721,6 +2791,9 @@ var BuildCommand = class extends BaseCommand {
|
|
|
2721
2791
|
this.tinaGraphQLVersion = import_clipanion3.Option.String("--tina-graphql-version", {
|
|
2722
2792
|
description: "Specify the version of @tinacms/graphql to use (defaults to latest)"
|
|
2723
2793
|
});
|
|
2794
|
+
/**
|
|
2795
|
+
* 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
|
|
2796
|
+
*/
|
|
2724
2797
|
this.skipCloudChecks = import_clipanion3.Option.Boolean("--skip-cloud-checks", false, {
|
|
2725
2798
|
description: "Skips checking the provided cloud config."
|
|
2726
2799
|
});
|
|
@@ -3461,6 +3534,7 @@ var auditDocuments = async (args) => {
|
|
|
3461
3534
|
logger.error(import_chalk5.default.red(err.message));
|
|
3462
3535
|
if (err.originalError.originalError) {
|
|
3463
3536
|
logger.error(
|
|
3537
|
+
// @ts-ignore FIXME: this doesn't seem right
|
|
3464
3538
|
import_chalk5.default.red(` ${err.originalError.originalError.message}`)
|
|
3465
3539
|
);
|
|
3466
3540
|
}
|
|
@@ -3666,7 +3740,9 @@ var detectEnvironment = async ({
|
|
|
3666
3740
|
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")));
|
|
3667
3741
|
const tinaFolder = import_path7.default.join(baseDir, "tina");
|
|
3668
3742
|
const tinaConfigExists = Boolean(
|
|
3669
|
-
|
|
3743
|
+
// Does the tina folder exist?
|
|
3744
|
+
await import_fs_extra8.default.pathExists(tinaFolder) && // Does the tina folder contain a config file?
|
|
3745
|
+
(await import_fs_extra8.default.readdir(tinaFolder)).find((x) => x.includes("config"))
|
|
3670
3746
|
);
|
|
3671
3747
|
const pagesDir = [baseDir, usingSrc ? "src" : false, "pages"].filter(
|
|
3672
3748
|
Boolean
|
|
@@ -3901,6 +3977,7 @@ var supportedDatabaseAdapters = {
|
|
|
3901
3977
|
{
|
|
3902
3978
|
from: "mongodb",
|
|
3903
3979
|
imported: [],
|
|
3980
|
+
// not explicitly imported
|
|
3904
3981
|
packageName: "mongodb"
|
|
3905
3982
|
}
|
|
3906
3983
|
]
|
|
@@ -3973,6 +4050,10 @@ var chooseDatabaseAdapter = async ({
|
|
|
3973
4050
|
title: "MongoDB",
|
|
3974
4051
|
value: "mongodb"
|
|
3975
4052
|
}
|
|
4053
|
+
// {
|
|
4054
|
+
// title: "I'll create my own database adapter",
|
|
4055
|
+
// value: 'other',
|
|
4056
|
+
// },
|
|
3976
4057
|
]
|
|
3977
4058
|
}
|
|
3978
4059
|
]);
|
|
@@ -4250,6 +4331,7 @@ async function configure(env, opts) {
|
|
|
4250
4331
|
packageManager,
|
|
4251
4332
|
forestryMigrate: false,
|
|
4252
4333
|
isLocalEnvVarName: "TINA_PUBLIC_IS_LOCAL",
|
|
4334
|
+
// TODO: give this a better default
|
|
4253
4335
|
typescript: false
|
|
4254
4336
|
};
|
|
4255
4337
|
if (config2.framework.name === "next") {
|
|
@@ -4353,15 +4435,25 @@ var import_js_yaml = __toESM(require("js-yaml"));
|
|
|
4353
4435
|
var import_zod = __toESM(require("zod"));
|
|
4354
4436
|
|
|
4355
4437
|
// src/cmds/forestry-migrate/util/errorSingleton.ts
|
|
4356
|
-
var ErrorSingleton = class {
|
|
4438
|
+
var ErrorSingleton = class _ErrorSingleton {
|
|
4439
|
+
/**
|
|
4440
|
+
* The Singleton's constructor should always be private to prevent direct
|
|
4441
|
+
* construction calls with the `new` operator.
|
|
4442
|
+
*/
|
|
4357
4443
|
constructor() {
|
|
4358
4444
|
}
|
|
4445
|
+
/**
|
|
4446
|
+
* The static method that controls the access to the singleton instance.
|
|
4447
|
+
*
|
|
4448
|
+
* This implementation let you subclass the Singleton class while keeping
|
|
4449
|
+
* just one instance of each subclass around.
|
|
4450
|
+
*/
|
|
4359
4451
|
static getInstance() {
|
|
4360
|
-
if (!
|
|
4361
|
-
|
|
4362
|
-
|
|
4452
|
+
if (!_ErrorSingleton.instance) {
|
|
4453
|
+
_ErrorSingleton.instance = new _ErrorSingleton();
|
|
4454
|
+
_ErrorSingleton.instance.collectionNameErrors = [];
|
|
4363
4455
|
}
|
|
4364
|
-
return
|
|
4456
|
+
return _ErrorSingleton.instance;
|
|
4365
4457
|
}
|
|
4366
4458
|
addErrorName(error) {
|
|
4367
4459
|
this.collectionNameErrors.push(error);
|
|
@@ -4404,8 +4496,7 @@ var makeFieldsWithInternalCode = ({
|
|
|
4404
4496
|
if (hasBody) {
|
|
4405
4497
|
return [bodyField, `__TINA_INTERNAL__:::...${field}():::`];
|
|
4406
4498
|
} else {
|
|
4407
|
-
if (spread)
|
|
4408
|
-
return `__TINA_INTERNAL__:::...${field}():::`;
|
|
4499
|
+
if (spread) return `__TINA_INTERNAL__:::...${field}():::`;
|
|
4409
4500
|
return `__TINA_INTERNAL__:::${field}():::`;
|
|
4410
4501
|
}
|
|
4411
4502
|
};
|
|
@@ -4489,6 +4580,7 @@ var forestryConfigSchema = import_zod.default.object({
|
|
|
4489
4580
|
)
|
|
4490
4581
|
});
|
|
4491
4582
|
var forestryFieldWithoutField = import_zod.default.object({
|
|
4583
|
+
// TODO: maybe better type this?
|
|
4492
4584
|
type: import_zod.default.union([
|
|
4493
4585
|
import_zod.default.literal("text"),
|
|
4494
4586
|
import_zod.default.literal("datetime"),
|
|
@@ -4512,6 +4604,7 @@ var forestryFieldWithoutField = import_zod.default.object({
|
|
|
4512
4604
|
default: import_zod.default.any().optional(),
|
|
4513
4605
|
template: import_zod.default.string().optional(),
|
|
4514
4606
|
config: import_zod.default.object({
|
|
4607
|
+
// min and max are used for lists
|
|
4515
4608
|
min: import_zod.default.number().optional().nullable(),
|
|
4516
4609
|
max: import_zod.default.number().optional().nullable(),
|
|
4517
4610
|
required: import_zod.default.boolean().optional().nullable(),
|
|
@@ -4525,6 +4618,7 @@ var forestryFieldWithoutField = import_zod.default.object({
|
|
|
4525
4618
|
import_zod.default.literal("pages"),
|
|
4526
4619
|
import_zod.default.literal("documents"),
|
|
4527
4620
|
import_zod.default.literal("simple"),
|
|
4621
|
+
// TODO: I want to ignore this key if its invalid
|
|
4528
4622
|
import_zod.default.string()
|
|
4529
4623
|
]).optional().nullable(),
|
|
4530
4624
|
section: import_zod.default.string().optional().nullable()
|
|
@@ -4560,6 +4654,7 @@ var transformForestryFieldsToTinaFields = ({
|
|
|
4560
4654
|
}
|
|
4561
4655
|
let field;
|
|
4562
4656
|
switch (forestryField2.type) {
|
|
4657
|
+
// Single filed types
|
|
4563
4658
|
case "text":
|
|
4564
4659
|
field = {
|
|
4565
4660
|
type: "string",
|
|
@@ -4639,6 +4734,7 @@ var transformForestryFieldsToTinaFields = ({
|
|
|
4639
4734
|
);
|
|
4640
4735
|
}
|
|
4641
4736
|
break;
|
|
4737
|
+
// List Types
|
|
4642
4738
|
case "list":
|
|
4643
4739
|
field = {
|
|
4644
4740
|
type: "string",
|
|
@@ -4661,6 +4757,7 @@ var transformForestryFieldsToTinaFields = ({
|
|
|
4661
4757
|
}
|
|
4662
4758
|
};
|
|
4663
4759
|
break;
|
|
4760
|
+
// Object (Group) types
|
|
4664
4761
|
case "field_group":
|
|
4665
4762
|
field = {
|
|
4666
4763
|
type: "object",
|
|
@@ -4701,6 +4798,7 @@ var transformForestryFieldsToTinaFields = ({
|
|
|
4701
4798
|
});
|
|
4702
4799
|
const fieldsString = stringifyLabelWithField(template2.label);
|
|
4703
4800
|
const t = {
|
|
4801
|
+
// @ts-ignore
|
|
4704
4802
|
fields: makeFieldsWithInternalCode({
|
|
4705
4803
|
hasBody: false,
|
|
4706
4804
|
field: fieldsString
|
|
@@ -4738,6 +4836,7 @@ var transformForestryFieldsToTinaFields = ({
|
|
|
4738
4836
|
spread: true
|
|
4739
4837
|
});
|
|
4740
4838
|
tinaFields.push(
|
|
4839
|
+
// @ts-ignore
|
|
4741
4840
|
field2
|
|
4742
4841
|
);
|
|
4743
4842
|
break;
|
|
@@ -4797,6 +4896,7 @@ var parseSections = ({ val }) => {
|
|
|
4797
4896
|
|
|
4798
4897
|
// src/cmds/forestry-migrate/index.ts
|
|
4799
4898
|
var BODY_FIELD = {
|
|
4899
|
+
// This is the body field
|
|
4800
4900
|
type: "rich-text",
|
|
4801
4901
|
name: "body",
|
|
4802
4902
|
label: "Body of Document",
|
|
@@ -4855,8 +4955,7 @@ var generateAllTemplates = async ({
|
|
|
4855
4955
|
};
|
|
4856
4956
|
var generateCollectionFromForestrySection = (args) => {
|
|
4857
4957
|
const { section, templateMap } = args;
|
|
4858
|
-
if (section.read_only)
|
|
4859
|
-
return;
|
|
4958
|
+
if (section.read_only) return;
|
|
4860
4959
|
let format3 = "md";
|
|
4861
4960
|
if (section.new_doc_ext) {
|
|
4862
4961
|
const ext = checkExt(section.new_doc_ext);
|
|
@@ -4923,12 +5022,14 @@ var generateCollectionFromForestrySection = (args) => {
|
|
|
4923
5022
|
if (((forestryTemplates == null ? void 0 : forestryTemplates.length) || 0) > 1) {
|
|
4924
5023
|
c = {
|
|
4925
5024
|
...baseCollection,
|
|
5025
|
+
// @ts-expect-error
|
|
4926
5026
|
templates: forestryTemplates.map((tem) => {
|
|
4927
5027
|
const currentTemplate = templateMap.get(tem);
|
|
4928
5028
|
const fieldsString = stringifyLabelWithField(
|
|
4929
5029
|
currentTemplate.templateObj.label
|
|
4930
5030
|
);
|
|
4931
5031
|
return {
|
|
5032
|
+
// fields: [BODY_FIELD],
|
|
4932
5033
|
fields: makeFieldsWithInternalCode({
|
|
4933
5034
|
hasBody,
|
|
4934
5035
|
field: fieldsString,
|
|
@@ -4946,6 +5047,8 @@ var generateCollectionFromForestrySection = (args) => {
|
|
|
4946
5047
|
const fieldsString = stringifyLabelWithField(template.templateObj.label);
|
|
4947
5048
|
c = {
|
|
4948
5049
|
...baseCollection,
|
|
5050
|
+
// fields: [BODY_FIELD],
|
|
5051
|
+
// @ts-expect-error
|
|
4949
5052
|
fields: makeFieldsWithInternalCode({
|
|
4950
5053
|
field: fieldsString,
|
|
4951
5054
|
hasBody,
|
|
@@ -5693,6 +5796,7 @@ var makeImportsVisitor = (sourceFile, importMap) => (ctx) => (node) => {
|
|
|
5693
5796
|
) : [];
|
|
5694
5797
|
const newImports = [
|
|
5695
5798
|
.../* @__PURE__ */ new Set([
|
|
5799
|
+
// we use Set to remove duplicates
|
|
5696
5800
|
...existingImports,
|
|
5697
5801
|
...imports
|
|
5698
5802
|
])
|
|
@@ -5847,6 +5951,7 @@ var addSelfHostedTinaAuthToConfig = async (config2, configFile) => {
|
|
|
5847
5951
|
);
|
|
5848
5952
|
const { configImports, configAuthProviderClass, extraTinaCollections } = config2.authProvider;
|
|
5849
5953
|
const importMap = {
|
|
5954
|
+
// iterate over configImports and add them to the import map
|
|
5850
5955
|
...configImports.reduce((acc, { from, imported }) => {
|
|
5851
5956
|
acc[from] = imported;
|
|
5852
5957
|
return acc;
|
|
@@ -6021,7 +6126,13 @@ async function apply({
|
|
|
6021
6126
|
config: config2
|
|
6022
6127
|
});
|
|
6023
6128
|
}
|
|
6024
|
-
if (
|
|
6129
|
+
if (
|
|
6130
|
+
// if the config was just generated we do not need to update the config file because it will be generated correctly
|
|
6131
|
+
env.tinaConfigExists && // Are we running tinacms init backend
|
|
6132
|
+
params.isBackendInit && // Do the user choose the 'self-host' option
|
|
6133
|
+
config2.hosting === "self-host" && // the user did not choose the 'tina-cloud' auth provider
|
|
6134
|
+
(((_a = config2.authProvider) == null ? void 0 : _a.name) || "") !== "tina-cloud"
|
|
6135
|
+
) {
|
|
6025
6136
|
await addSelfHostedTinaAuthToConfig(config2, env.generatedFiles["config"]);
|
|
6026
6137
|
}
|
|
6027
6138
|
logNextSteps({
|
|
@@ -6314,6 +6425,7 @@ var other = ({ packageManager }) => {
|
|
|
6314
6425
|
const packageManagers = {
|
|
6315
6426
|
pnpm: `pnpm`,
|
|
6316
6427
|
npm: `npx`,
|
|
6428
|
+
// npx is the way to run executables that aren't in your "scripts"
|
|
6317
6429
|
yarn: `yarn`
|
|
6318
6430
|
};
|
|
6319
6431
|
return `${packageManagers[packageManager]} tinacms dev -c "<your dev command>"`;
|
|
@@ -6326,6 +6438,7 @@ var frameworkDevCmds = {
|
|
|
6326
6438
|
const packageManagers = {
|
|
6327
6439
|
pnpm: `pnpm`,
|
|
6328
6440
|
npm: `npm run`,
|
|
6441
|
+
// npx is the way to run executables that aren't in your "scripts"
|
|
6329
6442
|
yarn: `yarn`
|
|
6330
6443
|
};
|
|
6331
6444
|
return `${packageManagers[packageManager]} dev`;
|
|
@@ -6583,5 +6696,3 @@ cli.register(import_clipanion8.Builtins.DefinitionsCommand);
|
|
|
6583
6696
|
cli.register(import_clipanion8.Builtins.HelpCommand);
|
|
6584
6697
|
cli.register(import_clipanion8.Builtins.VersionCommand);
|
|
6585
6698
|
var src_default = cli;
|
|
6586
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
6587
|
-
0 && (module.exports = {});
|
|
@@ -22,7 +22,7 @@ interface StaticMediaItem {
|
|
|
22
22
|
export interface StaticMedia {
|
|
23
23
|
[offset: string]: StaticMediaItem[];
|
|
24
24
|
}
|
|
25
|
-
export declare const createConfig: ({ configManager,
|
|
25
|
+
export declare const createConfig: ({ configManager, apiURL, plugins, noWatch, rollupOptions, }: {
|
|
26
26
|
configManager: ConfigManager;
|
|
27
27
|
database: Database;
|
|
28
28
|
apiURL: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tinacms/cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.8.0",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"typings": "dist/index.d.ts",
|
|
6
6
|
"files": [
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
"cors": "^2.8.5",
|
|
66
66
|
"crypto-js": "^4.2.0",
|
|
67
67
|
"dotenv": "^16.4.5",
|
|
68
|
-
"esbuild": "^0.
|
|
68
|
+
"esbuild": "^0.24.0",
|
|
69
69
|
"fs-extra": "^11.2.0",
|
|
70
70
|
"graphql": "15.8.0",
|
|
71
71
|
"js-yaml": "^4.1.0",
|
|
@@ -84,12 +84,12 @@
|
|
|
84
84
|
"vite": "^4.5.5",
|
|
85
85
|
"yup": "^1.4.0",
|
|
86
86
|
"zod": "^3.23.8",
|
|
87
|
-
"@tinacms/app": "2.1.
|
|
88
|
-
"@tinacms/graphql": "1.5.
|
|
87
|
+
"@tinacms/app": "2.1.15",
|
|
88
|
+
"@tinacms/graphql": "1.5.10",
|
|
89
89
|
"@tinacms/metrics": "1.0.8",
|
|
90
|
-
"
|
|
91
|
-
"tinacms": "
|
|
92
|
-
"@tinacms/search": "1.0.
|
|
90
|
+
"tinacms": "2.6.0",
|
|
91
|
+
"@tinacms/schema-tools": "1.7.0",
|
|
92
|
+
"@tinacms/search": "1.0.37"
|
|
93
93
|
},
|
|
94
94
|
"publishConfig": {
|
|
95
95
|
"registry": "https://registry.npmjs.org"
|