@tinacms/cli 2.2.4 → 2.2.5
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 +313 -295
- package/dist/next/resolve-content-root.d.ts +19 -0
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -2,16 +2,16 @@
|
|
|
2
2
|
import { Cli, Builtins } from "clipanion";
|
|
3
3
|
|
|
4
4
|
// package.json
|
|
5
|
-
var version = "2.2.
|
|
5
|
+
var version = "2.2.5";
|
|
6
6
|
|
|
7
7
|
// src/next/commands/dev-command/index.ts
|
|
8
|
-
import
|
|
8
|
+
import path9 from "path";
|
|
9
9
|
import { FilesystemBridge as FilesystemBridge2, buildSchema } from "@tinacms/graphql";
|
|
10
10
|
import { LocalSearchIndexClient, SearchIndexer } from "@tinacms/search";
|
|
11
11
|
import AsyncLock from "async-lock";
|
|
12
12
|
import chokidar from "chokidar";
|
|
13
13
|
import { Command as Command2, Option as Option2 } from "clipanion";
|
|
14
|
-
import
|
|
14
|
+
import fs8 from "fs-extra";
|
|
15
15
|
|
|
16
16
|
// src/logger/index.ts
|
|
17
17
|
import chalk from "chalk";
|
|
@@ -819,16 +819,22 @@ var unlinkIfExists = async (filepath) => {
|
|
|
819
819
|
};
|
|
820
820
|
|
|
821
821
|
// src/next/config-manager.ts
|
|
822
|
-
import
|
|
823
|
-
import
|
|
822
|
+
import fs3 from "fs-extra";
|
|
823
|
+
import path4 from "path";
|
|
824
824
|
import os from "os";
|
|
825
825
|
import { pathToFileURL } from "url";
|
|
826
826
|
import * as esbuild from "esbuild";
|
|
827
827
|
import * as dotenv from "dotenv";
|
|
828
828
|
import normalizePath2 from "normalize-path";
|
|
829
|
-
import
|
|
829
|
+
import chalk4 from "chalk";
|
|
830
830
|
import { createRequire } from "module";
|
|
831
831
|
|
|
832
|
+
// src/next/resolve-content-root.ts
|
|
833
|
+
import fs2 from "fs-extra";
|
|
834
|
+
import path3 from "path";
|
|
835
|
+
import chalk3 from "chalk";
|
|
836
|
+
import { z } from "zod";
|
|
837
|
+
|
|
832
838
|
// src/utils/path.ts
|
|
833
839
|
import path2 from "path";
|
|
834
840
|
function stripNativeTrailingSlash(p) {
|
|
@@ -848,6 +854,33 @@ var PathTraversalError = class extends Error {
|
|
|
848
854
|
}
|
|
849
855
|
};
|
|
850
856
|
|
|
857
|
+
// src/next/resolve-content-root.ts
|
|
858
|
+
var localContentPathSchema = z.string().min(1).optional();
|
|
859
|
+
async function resolveContentRootPath(params) {
|
|
860
|
+
const localContentPath = localContentPathSchema.parse(
|
|
861
|
+
params.localContentPath
|
|
862
|
+
);
|
|
863
|
+
if (!localContentPath) {
|
|
864
|
+
return params.rootPath;
|
|
865
|
+
}
|
|
866
|
+
const fullLocalContentPath = stripNativeTrailingSlash(
|
|
867
|
+
path3.join(params.tinaFolderPath, localContentPath)
|
|
868
|
+
);
|
|
869
|
+
const exists = await fs2.pathExists(fullLocalContentPath);
|
|
870
|
+
if (exists) {
|
|
871
|
+
logger.info(`Using separate content repo at ${fullLocalContentPath}`);
|
|
872
|
+
return fullLocalContentPath;
|
|
873
|
+
}
|
|
874
|
+
logger.warn(
|
|
875
|
+
`${chalk3.yellow("Warning:")} The localContentPath ${chalk3.cyan(
|
|
876
|
+
fullLocalContentPath
|
|
877
|
+
)} does not exist. Please create it or remove the localContentPath from your config file at ${chalk3.cyan(
|
|
878
|
+
params.tinaConfigFilePath
|
|
879
|
+
)}`
|
|
880
|
+
);
|
|
881
|
+
return params.rootPath;
|
|
882
|
+
}
|
|
883
|
+
|
|
851
884
|
// src/next/config-manager.ts
|
|
852
885
|
var TINA_FOLDER = "tina";
|
|
853
886
|
var LEGACY_TINA_FOLDER = ".tina";
|
|
@@ -907,7 +940,7 @@ var ConfigManager = class {
|
|
|
907
940
|
this.legacyNoSDK = legacyNoSDK;
|
|
908
941
|
}
|
|
909
942
|
isUsingTs() {
|
|
910
|
-
return [".ts", ".tsx"].includes(
|
|
943
|
+
return [".ts", ".tsx"].includes(path4.extname(this.tinaConfigFilePath));
|
|
911
944
|
}
|
|
912
945
|
hasSelfHostedConfig() {
|
|
913
946
|
return !!this.selfHostedDatabaseFilePath;
|
|
@@ -924,12 +957,12 @@ var ConfigManager = class {
|
|
|
924
957
|
async processConfig() {
|
|
925
958
|
const require2 = createRequire(import.meta.url);
|
|
926
959
|
this.tinaFolderPath = await this.getTinaFolderPath(this.rootPath);
|
|
927
|
-
this.envFilePath =
|
|
928
|
-
|
|
960
|
+
this.envFilePath = path4.resolve(
|
|
961
|
+
path4.join(this.tinaFolderPath, "..", ".env")
|
|
929
962
|
);
|
|
930
963
|
dotenv.config({ path: this.envFilePath });
|
|
931
964
|
this.tinaConfigFilePath = await this.getPathWithExtension(
|
|
932
|
-
|
|
965
|
+
path4.join(this.tinaFolderPath, "config")
|
|
933
966
|
);
|
|
934
967
|
if (!this.tinaConfigFilePath) {
|
|
935
968
|
throw new Error(
|
|
@@ -937,89 +970,89 @@ var ConfigManager = class {
|
|
|
937
970
|
);
|
|
938
971
|
}
|
|
939
972
|
this.selfHostedDatabaseFilePath = await this.getPathWithExtension(
|
|
940
|
-
|
|
973
|
+
path4.join(this.tinaFolderPath, "database")
|
|
941
974
|
);
|
|
942
|
-
this.generatedFolderPath =
|
|
943
|
-
this.generatedCachePath =
|
|
975
|
+
this.generatedFolderPath = path4.join(this.tinaFolderPath, GENERATED_FOLDER);
|
|
976
|
+
this.generatedCachePath = path4.join(
|
|
944
977
|
this.generatedFolderPath,
|
|
945
978
|
".cache",
|
|
946
979
|
String((/* @__PURE__ */ new Date()).getTime())
|
|
947
980
|
);
|
|
948
|
-
this.generatedGraphQLGQLPath =
|
|
981
|
+
this.generatedGraphQLGQLPath = path4.join(
|
|
949
982
|
this.generatedFolderPath,
|
|
950
983
|
GRAPHQL_GQL_FILE
|
|
951
984
|
);
|
|
952
|
-
this.generatedGraphQLJSONPath =
|
|
985
|
+
this.generatedGraphQLJSONPath = path4.join(
|
|
953
986
|
this.generatedFolderPath,
|
|
954
987
|
GRAPHQL_JSON_FILE
|
|
955
988
|
);
|
|
956
|
-
this.generatedSchemaJSONPath =
|
|
989
|
+
this.generatedSchemaJSONPath = path4.join(
|
|
957
990
|
this.generatedFolderPath,
|
|
958
991
|
SCHEMA_JSON_FILE
|
|
959
992
|
);
|
|
960
|
-
this.generatedLookupJSONPath =
|
|
993
|
+
this.generatedLookupJSONPath = path4.join(
|
|
961
994
|
this.generatedFolderPath,
|
|
962
995
|
LOOKUP_JSON_FILE
|
|
963
996
|
);
|
|
964
|
-
this.generatedQueriesFilePath =
|
|
997
|
+
this.generatedQueriesFilePath = path4.join(
|
|
965
998
|
this.generatedFolderPath,
|
|
966
999
|
"queries.gql"
|
|
967
1000
|
);
|
|
968
|
-
this.generatedFragmentsFilePath =
|
|
1001
|
+
this.generatedFragmentsFilePath = path4.join(
|
|
969
1002
|
this.generatedFolderPath,
|
|
970
1003
|
"frags.gql"
|
|
971
1004
|
);
|
|
972
|
-
this.generatedTypesTSFilePath =
|
|
1005
|
+
this.generatedTypesTSFilePath = path4.join(
|
|
973
1006
|
this.generatedFolderPath,
|
|
974
1007
|
"types.ts"
|
|
975
1008
|
);
|
|
976
|
-
this.generatedTypesJSFilePath =
|
|
1009
|
+
this.generatedTypesJSFilePath = path4.join(
|
|
977
1010
|
this.generatedFolderPath,
|
|
978
1011
|
"types.js"
|
|
979
1012
|
);
|
|
980
|
-
this.generatedTypesDFilePath =
|
|
1013
|
+
this.generatedTypesDFilePath = path4.join(
|
|
981
1014
|
this.generatedFolderPath,
|
|
982
1015
|
"types.d.ts"
|
|
983
1016
|
);
|
|
984
|
-
this.userQueriesAndFragmentsGlob =
|
|
1017
|
+
this.userQueriesAndFragmentsGlob = path4.join(
|
|
985
1018
|
this.tinaFolderPath,
|
|
986
1019
|
"queries/**/*.{graphql,gql}"
|
|
987
1020
|
);
|
|
988
|
-
this.generatedQueriesAndFragmentsGlob =
|
|
1021
|
+
this.generatedQueriesAndFragmentsGlob = path4.join(
|
|
989
1022
|
this.generatedFolderPath,
|
|
990
1023
|
"*.{graphql,gql}"
|
|
991
1024
|
);
|
|
992
|
-
this.generatedClientTSFilePath =
|
|
1025
|
+
this.generatedClientTSFilePath = path4.join(
|
|
993
1026
|
this.generatedFolderPath,
|
|
994
1027
|
"client.ts"
|
|
995
1028
|
);
|
|
996
|
-
this.generatedClientJSFilePath =
|
|
1029
|
+
this.generatedClientJSFilePath = path4.join(
|
|
997
1030
|
this.generatedFolderPath,
|
|
998
1031
|
"client.js"
|
|
999
1032
|
);
|
|
1000
|
-
this.generatedClientDFilePath =
|
|
1033
|
+
this.generatedClientDFilePath = path4.join(
|
|
1001
1034
|
this.generatedFolderPath,
|
|
1002
1035
|
"client.d.ts"
|
|
1003
1036
|
);
|
|
1004
|
-
this.generatedDatabaseClientDFilePath =
|
|
1037
|
+
this.generatedDatabaseClientDFilePath = path4.join(
|
|
1005
1038
|
this.generatedFolderPath,
|
|
1006
1039
|
"databaseClient.d.ts"
|
|
1007
1040
|
);
|
|
1008
|
-
this.generatedDatabaseClientTSFilePath =
|
|
1041
|
+
this.generatedDatabaseClientTSFilePath = path4.join(
|
|
1009
1042
|
this.generatedFolderPath,
|
|
1010
1043
|
"databaseClient.ts"
|
|
1011
1044
|
);
|
|
1012
|
-
this.generatedDatabaseClientJSFilePath =
|
|
1045
|
+
this.generatedDatabaseClientJSFilePath = path4.join(
|
|
1013
1046
|
this.generatedFolderPath,
|
|
1014
1047
|
"databaseClient.js"
|
|
1015
1048
|
);
|
|
1016
|
-
const clientExists = this.isUsingTs() ? await
|
|
1049
|
+
const clientExists = this.isUsingTs() ? await fs3.pathExists(this.generatedClientTSFilePath) : await fs3.pathExists(this.generatedClientJSFilePath);
|
|
1017
1050
|
if (!clientExists) {
|
|
1018
1051
|
const file = "export default ()=>({})\nexport const client = ()=>({})";
|
|
1019
1052
|
if (this.isUsingTs()) {
|
|
1020
|
-
await
|
|
1053
|
+
await fs3.outputFile(this.generatedClientTSFilePath, file);
|
|
1021
1054
|
} else {
|
|
1022
|
-
await
|
|
1055
|
+
await fs3.outputFile(this.generatedClientJSFilePath, file);
|
|
1023
1056
|
}
|
|
1024
1057
|
}
|
|
1025
1058
|
const { config: config2, prebuildPath, watchList } = await this.loadConfigFile(
|
|
@@ -1029,62 +1062,47 @@ var ConfigManager = class {
|
|
|
1029
1062
|
this.watchList = watchList;
|
|
1030
1063
|
this.config = config2;
|
|
1031
1064
|
this.prebuildFilePath = prebuildPath;
|
|
1032
|
-
this.publicFolderPath =
|
|
1065
|
+
this.publicFolderPath = path4.join(
|
|
1033
1066
|
this.rootPath,
|
|
1034
1067
|
this.config.build.publicFolder
|
|
1035
1068
|
);
|
|
1036
|
-
this.outputFolderPath =
|
|
1069
|
+
this.outputFolderPath = path4.join(
|
|
1037
1070
|
this.publicFolderPath,
|
|
1038
1071
|
this.config.build.outputFolder
|
|
1039
1072
|
);
|
|
1040
|
-
this.outputHTMLFilePath =
|
|
1041
|
-
this.outputGitignorePath =
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
this.contentRootPath = fullLocalContentPath;
|
|
1050
|
-
} else {
|
|
1051
|
-
logger.warn(
|
|
1052
|
-
`${chalk3.yellow("Warning:")} The localContentPath ${chalk3.cyan(
|
|
1053
|
-
fullLocalContentPath
|
|
1054
|
-
)} does not exist. Please create it or remove the localContentPath from your config file at ${chalk3.cyan(
|
|
1055
|
-
this.tinaConfigFilePath
|
|
1056
|
-
)}`
|
|
1057
|
-
);
|
|
1058
|
-
}
|
|
1059
|
-
}
|
|
1060
|
-
if (!this.contentRootPath) {
|
|
1061
|
-
this.contentRootPath = this.rootPath;
|
|
1062
|
-
}
|
|
1063
|
-
this.generatedFolderPathContentRepo = path3.join(
|
|
1073
|
+
this.outputHTMLFilePath = path4.join(this.outputFolderPath, "index.html");
|
|
1074
|
+
this.outputGitignorePath = path4.join(this.outputFolderPath, ".gitignore");
|
|
1075
|
+
this.contentRootPath = await resolveContentRootPath({
|
|
1076
|
+
rootPath: this.rootPath,
|
|
1077
|
+
tinaFolderPath: this.tinaFolderPath,
|
|
1078
|
+
tinaConfigFilePath: this.tinaConfigFilePath,
|
|
1079
|
+
localContentPath: this.config.localContentPath
|
|
1080
|
+
});
|
|
1081
|
+
this.generatedFolderPathContentRepo = path4.join(
|
|
1064
1082
|
await this.getTinaFolderPath(this.contentRootPath, {
|
|
1065
1083
|
isContentRoot: this.hasSeparateContentRoot()
|
|
1066
1084
|
}),
|
|
1067
1085
|
GENERATED_FOLDER
|
|
1068
1086
|
);
|
|
1069
1087
|
this.spaMainPath = require2.resolve("@tinacms/app");
|
|
1070
|
-
this.spaRootPath =
|
|
1088
|
+
this.spaRootPath = path4.join(this.spaMainPath, "..", "..");
|
|
1071
1089
|
}
|
|
1072
1090
|
async getTinaFolderPath(rootPath, { isContentRoot } = {}) {
|
|
1073
|
-
const tinaFolderPath =
|
|
1074
|
-
const tinaFolderExists = await
|
|
1091
|
+
const tinaFolderPath = path4.join(rootPath, TINA_FOLDER);
|
|
1092
|
+
const tinaFolderExists = await fs3.pathExists(tinaFolderPath);
|
|
1075
1093
|
if (tinaFolderExists) {
|
|
1076
1094
|
this.isUsingLegacyFolder = false;
|
|
1077
1095
|
return tinaFolderPath;
|
|
1078
1096
|
}
|
|
1079
|
-
const legacyFolderPath =
|
|
1080
|
-
const legacyFolderExists = await
|
|
1097
|
+
const legacyFolderPath = path4.join(rootPath, LEGACY_TINA_FOLDER);
|
|
1098
|
+
const legacyFolderExists = await fs3.pathExists(legacyFolderPath);
|
|
1081
1099
|
if (legacyFolderExists) {
|
|
1082
1100
|
this.isUsingLegacyFolder = true;
|
|
1083
1101
|
return legacyFolderPath;
|
|
1084
1102
|
}
|
|
1085
1103
|
if (isContentRoot) {
|
|
1086
1104
|
throw new Error(
|
|
1087
|
-
`Unable to find a ${
|
|
1105
|
+
`Unable to find a ${chalk4.cyan("tina/")} folder in your content root at ${chalk4.cyan(rootPath)}. When using localContentPath, the content directory must contain a ${chalk4.cyan("tina/")} folder for generated files. Create one with: mkdir ${path4.join(rootPath, TINA_FOLDER)}`
|
|
1088
1106
|
);
|
|
1089
1107
|
}
|
|
1090
1108
|
throw new Error(
|
|
@@ -1101,7 +1119,7 @@ var ConfigManager = class {
|
|
|
1101
1119
|
patch: version2[2] || "x"
|
|
1102
1120
|
};
|
|
1103
1121
|
}
|
|
1104
|
-
const generatedSchema =
|
|
1122
|
+
const generatedSchema = fs3.readJSONSync(this.generatedSchemaJSONPath);
|
|
1105
1123
|
if (!generatedSchema || !(typeof generatedSchema?.version !== "undefined")) {
|
|
1106
1124
|
throw new Error(
|
|
1107
1125
|
`Can not find Tina GraphQL version in ${this.generatedSchemaJSONPath}`
|
|
@@ -1148,7 +1166,7 @@ var ConfigManager = class {
|
|
|
1148
1166
|
return;
|
|
1149
1167
|
}
|
|
1150
1168
|
const filepathWithExtension = `${filepath}.${ext}`;
|
|
1151
|
-
const exists =
|
|
1169
|
+
const exists = fs3.existsSync(filepathWithExtension);
|
|
1152
1170
|
if (exists) {
|
|
1153
1171
|
result = filepathWithExtension;
|
|
1154
1172
|
}
|
|
@@ -1157,8 +1175,8 @@ var ConfigManager = class {
|
|
|
1157
1175
|
return result;
|
|
1158
1176
|
}
|
|
1159
1177
|
async loadDatabaseFile() {
|
|
1160
|
-
const tmpdir =
|
|
1161
|
-
const outfile =
|
|
1178
|
+
const tmpdir = path4.join(os.tmpdir(), Date.now().toString());
|
|
1179
|
+
const outfile = path4.join(tmpdir, "database.build.mjs");
|
|
1162
1180
|
await esbuild.build({
|
|
1163
1181
|
entryPoints: [this.selfHostedDatabaseFilePath],
|
|
1164
1182
|
bundle: true,
|
|
@@ -1176,22 +1194,22 @@ var ConfigManager = class {
|
|
|
1176
1194
|
}
|
|
1177
1195
|
});
|
|
1178
1196
|
const result = await import(pathToFileURL(outfile).href);
|
|
1179
|
-
|
|
1197
|
+
fs3.removeSync(outfile);
|
|
1180
1198
|
return result.default;
|
|
1181
1199
|
}
|
|
1182
1200
|
async loadConfigFile(generatedFolderPath, configFilePath) {
|
|
1183
|
-
const tmpdir =
|
|
1184
|
-
const preBuildConfigPath =
|
|
1201
|
+
const tmpdir = path4.join(os.tmpdir(), Date.now().toString());
|
|
1202
|
+
const preBuildConfigPath = path4.join(
|
|
1185
1203
|
this.generatedFolderPath,
|
|
1186
1204
|
"config.prebuild.jsx"
|
|
1187
1205
|
);
|
|
1188
|
-
const outfile =
|
|
1189
|
-
const outfile2 =
|
|
1190
|
-
const tempTSConfigFile =
|
|
1206
|
+
const outfile = path4.join(tmpdir, "config.build.jsx");
|
|
1207
|
+
const outfile2 = path4.join(tmpdir, "config.build.mjs");
|
|
1208
|
+
const tempTSConfigFile = path4.join(tmpdir, "tsconfig.json");
|
|
1191
1209
|
const esmRequireBanner = {
|
|
1192
1210
|
js: `import { createRequire } from 'module';const require = createRequire(import.meta.url);`
|
|
1193
1211
|
};
|
|
1194
|
-
|
|
1212
|
+
fs3.outputFileSync(tempTSConfigFile, "{}");
|
|
1195
1213
|
const result2 = await esbuild.build({
|
|
1196
1214
|
entryPoints: [configFilePath],
|
|
1197
1215
|
bundle: true,
|
|
@@ -1241,8 +1259,8 @@ var ConfigManager = class {
|
|
|
1241
1259
|
console.error(e);
|
|
1242
1260
|
throw e;
|
|
1243
1261
|
}
|
|
1244
|
-
|
|
1245
|
-
|
|
1262
|
+
fs3.removeSync(outfile);
|
|
1263
|
+
fs3.removeSync(outfile2);
|
|
1246
1264
|
return {
|
|
1247
1265
|
config: result.default,
|
|
1248
1266
|
prebuildPath: preBuildConfigPath,
|
|
@@ -1333,7 +1351,7 @@ async function createAndInitializeDatabase(configManager, datalayerPort, bridgeO
|
|
|
1333
1351
|
|
|
1334
1352
|
// src/next/commands/baseCommands.ts
|
|
1335
1353
|
import { Command, Option } from "clipanion";
|
|
1336
|
-
import
|
|
1354
|
+
import chalk5 from "chalk";
|
|
1337
1355
|
|
|
1338
1356
|
// src/utils/start-subprocess.ts
|
|
1339
1357
|
import childProcess from "child_process";
|
|
@@ -1367,7 +1385,7 @@ stack: ${code.stack || "No stack was provided"}`);
|
|
|
1367
1385
|
|
|
1368
1386
|
// src/next/commands/baseCommands.ts
|
|
1369
1387
|
import { getChangedFiles, getSha, shaExists } from "@tinacms/graphql";
|
|
1370
|
-
import
|
|
1388
|
+
import fs4 from "fs-extra";
|
|
1371
1389
|
var BaseCommand = class extends Command {
|
|
1372
1390
|
experimentalDataLayer = Option.Boolean("--experimentalData", {
|
|
1373
1391
|
description: "DEPRECATED - Build the server with additional data querying capabilities"
|
|
@@ -1401,7 +1419,7 @@ var BaseCommand = class extends Command {
|
|
|
1401
1419
|
if (this.subCommand) {
|
|
1402
1420
|
subProc = await startSubprocess2({ command: this.subCommand });
|
|
1403
1421
|
logger.info(
|
|
1404
|
-
`Running web application with command: ${
|
|
1422
|
+
`Running web application with command: ${chalk5.cyan(this.subCommand)}`
|
|
1405
1423
|
);
|
|
1406
1424
|
}
|
|
1407
1425
|
function exitHandler(options, exitCode) {
|
|
@@ -1449,7 +1467,7 @@ var BaseCommand = class extends Command {
|
|
|
1449
1467
|
const rootPath = configManager.rootPath;
|
|
1450
1468
|
let sha;
|
|
1451
1469
|
try {
|
|
1452
|
-
sha = await getSha({ fs:
|
|
1470
|
+
sha = await getSha({ fs: fs4, dir: rootPath });
|
|
1453
1471
|
} catch (e) {
|
|
1454
1472
|
if (partialReindex) {
|
|
1455
1473
|
console.error(
|
|
@@ -1459,7 +1477,7 @@ var BaseCommand = class extends Command {
|
|
|
1459
1477
|
}
|
|
1460
1478
|
}
|
|
1461
1479
|
const lastSha = await database.getMetadata("lastSha");
|
|
1462
|
-
const exists = lastSha && await shaExists({ fs:
|
|
1480
|
+
const exists = lastSha && await shaExists({ fs: fs4, dir: rootPath, sha: lastSha });
|
|
1463
1481
|
let res;
|
|
1464
1482
|
if (partialReindex && lastSha && exists && sha) {
|
|
1465
1483
|
const pathFilter = {};
|
|
@@ -1474,14 +1492,14 @@ var BaseCommand = class extends Command {
|
|
|
1474
1492
|
};
|
|
1475
1493
|
}
|
|
1476
1494
|
const { added, modified, deleted } = await getChangedFiles({
|
|
1477
|
-
fs:
|
|
1495
|
+
fs: fs4,
|
|
1478
1496
|
dir: rootPath,
|
|
1479
1497
|
from: lastSha,
|
|
1480
1498
|
to: sha,
|
|
1481
1499
|
pathFilter
|
|
1482
1500
|
});
|
|
1483
1501
|
const tinaPathUpdates = modified.filter(
|
|
1484
|
-
(
|
|
1502
|
+
(path16) => path16.startsWith(".tina/__generated__/_schema.json") || path16.startsWith("tina/tina-lock.json")
|
|
1485
1503
|
);
|
|
1486
1504
|
if (tinaPathUpdates.length > 0) {
|
|
1487
1505
|
res = await database.indexContent({
|
|
@@ -1600,9 +1618,9 @@ var devHTML = (port) => `<!DOCTYPE html>
|
|
|
1600
1618
|
import { createServer as createViteServer } from "vite";
|
|
1601
1619
|
|
|
1602
1620
|
// src/next/vite/index.ts
|
|
1603
|
-
import
|
|
1621
|
+
import path6 from "node:path";
|
|
1604
1622
|
import react from "@vitejs/plugin-react";
|
|
1605
|
-
import
|
|
1623
|
+
import fs5 from "fs-extra";
|
|
1606
1624
|
import normalizePath3 from "normalize-path";
|
|
1607
1625
|
import {
|
|
1608
1626
|
splitVendorChunkPlugin
|
|
@@ -1669,7 +1687,7 @@ function filterPublicEnv(env = process.env) {
|
|
|
1669
1687
|
}
|
|
1670
1688
|
|
|
1671
1689
|
// src/next/vite/tailwind.ts
|
|
1672
|
-
import
|
|
1690
|
+
import path5 from "node:path";
|
|
1673
1691
|
import aspectRatio from "@tailwindcss/aspect-ratio";
|
|
1674
1692
|
import containerQueries from "@tailwindcss/container-queries";
|
|
1675
1693
|
import twTypography from "@tailwindcss/typography";
|
|
@@ -1684,7 +1702,7 @@ var tinaTailwind = (spaPath, prebuildFilePath) => {
|
|
|
1684
1702
|
const require2 = createRequire2(import.meta.url);
|
|
1685
1703
|
const plugins = [];
|
|
1686
1704
|
const content = [
|
|
1687
|
-
|
|
1705
|
+
path5.join(spaPath, "src/**/*.{vue,js,ts,jsx,tsx,svelte}"),
|
|
1688
1706
|
prebuildFilePath,
|
|
1689
1707
|
require2.resolve("tinacms")
|
|
1690
1708
|
];
|
|
@@ -1948,35 +1966,35 @@ async function listFilesRecursively({
|
|
|
1948
1966
|
config: config2,
|
|
1949
1967
|
roothPath
|
|
1950
1968
|
}) {
|
|
1951
|
-
const fullDirectoryPath =
|
|
1969
|
+
const fullDirectoryPath = path6.join(
|
|
1952
1970
|
roothPath,
|
|
1953
1971
|
config2.publicFolder,
|
|
1954
1972
|
directoryPath
|
|
1955
1973
|
);
|
|
1956
|
-
const exists = await
|
|
1974
|
+
const exists = await fs5.pathExists(fullDirectoryPath);
|
|
1957
1975
|
if (!exists) {
|
|
1958
1976
|
return { "0": [] };
|
|
1959
1977
|
}
|
|
1960
|
-
const items = await
|
|
1978
|
+
const items = await fs5.readdir(fullDirectoryPath);
|
|
1961
1979
|
const staticMediaItems = [];
|
|
1962
1980
|
for (const item of items) {
|
|
1963
|
-
const itemPath =
|
|
1964
|
-
const stats = await
|
|
1981
|
+
const itemPath = path6.join(fullDirectoryPath, item);
|
|
1982
|
+
const stats = await fs5.promises.lstat(itemPath);
|
|
1965
1983
|
const staticMediaItem = {
|
|
1966
1984
|
id: item,
|
|
1967
1985
|
filename: item,
|
|
1968
1986
|
type: stats.isDirectory() ? "dir" : "file",
|
|
1969
1987
|
directory: `${directoryPath.replace(config2.mediaRoot, "")}`,
|
|
1970
|
-
src: `/${
|
|
1988
|
+
src: `/${path6.join(directoryPath, item)}`,
|
|
1971
1989
|
thumbnails: {
|
|
1972
|
-
"75x75": `/${
|
|
1973
|
-
"400x400": `/${
|
|
1974
|
-
"1000x1000": `/${
|
|
1990
|
+
"75x75": `/${path6.join(directoryPath, item)}`,
|
|
1991
|
+
"400x400": `/${path6.join(directoryPath, item)}`,
|
|
1992
|
+
"1000x1000": `/${path6.join(directoryPath, item)}`
|
|
1975
1993
|
}
|
|
1976
1994
|
};
|
|
1977
1995
|
if (stats.isDirectory()) {
|
|
1978
1996
|
staticMediaItem.children = await listFilesRecursively({
|
|
1979
|
-
directoryPath:
|
|
1997
|
+
directoryPath: path6.join(directoryPath, item),
|
|
1980
1998
|
config: config2,
|
|
1981
1999
|
roothPath
|
|
1982
2000
|
});
|
|
@@ -2001,7 +2019,7 @@ var createConfig = async ({
|
|
|
2001
2019
|
rollupOptions
|
|
2002
2020
|
}) => {
|
|
2003
2021
|
const publicEnv = filterPublicEnv();
|
|
2004
|
-
const staticMediaPath =
|
|
2022
|
+
const staticMediaPath = path6.join(
|
|
2005
2023
|
configManager.generatedFolderPath,
|
|
2006
2024
|
"static-media.json"
|
|
2007
2025
|
);
|
|
@@ -2011,21 +2029,21 @@ var createConfig = async ({
|
|
|
2011
2029
|
config: configManager.config.media.tina,
|
|
2012
2030
|
roothPath: configManager.rootPath
|
|
2013
2031
|
});
|
|
2014
|
-
await
|
|
2032
|
+
await fs5.outputFile(staticMediaPath, JSON.stringify(staticMedia, null, 2));
|
|
2015
2033
|
} else {
|
|
2016
|
-
await
|
|
2034
|
+
await fs5.outputFile(staticMediaPath, `[]`);
|
|
2017
2035
|
}
|
|
2018
2036
|
const alias = {
|
|
2019
2037
|
TINA_IMPORT: configManager.prebuildFilePath,
|
|
2020
2038
|
SCHEMA_IMPORT: configManager.generatedGraphQLJSONPath,
|
|
2021
2039
|
STATIC_MEDIA_IMPORT: staticMediaPath,
|
|
2022
|
-
crypto:
|
|
2023
|
-
fs:
|
|
2024
|
-
os:
|
|
2025
|
-
path:
|
|
2040
|
+
crypto: path6.join(configManager.spaRootPath, "src", "dummy-client.ts"),
|
|
2041
|
+
fs: path6.join(configManager.spaRootPath, "src", "dummy-client.ts"),
|
|
2042
|
+
os: path6.join(configManager.spaRootPath, "src", "dummy-client.ts"),
|
|
2043
|
+
path: path6.join(configManager.spaRootPath, "src", "dummy-client.ts")
|
|
2026
2044
|
};
|
|
2027
2045
|
if (configManager.shouldSkipSDK()) {
|
|
2028
|
-
alias["CLIENT_IMPORT"] =
|
|
2046
|
+
alias["CLIENT_IMPORT"] = path6.join(
|
|
2029
2047
|
configManager.spaRootPath,
|
|
2030
2048
|
"src",
|
|
2031
2049
|
"dummy-client.ts"
|
|
@@ -2135,8 +2153,8 @@ var createConfig = async ({
|
|
|
2135
2153
|
};
|
|
2136
2154
|
|
|
2137
2155
|
// src/next/vite/plugins.ts
|
|
2138
|
-
import
|
|
2139
|
-
import
|
|
2156
|
+
import fs7 from "fs";
|
|
2157
|
+
import path8 from "path";
|
|
2140
2158
|
import { createFilter } from "@rollup/pluginutils";
|
|
2141
2159
|
import { resolve as gqlResolve } from "@tinacms/graphql";
|
|
2142
2160
|
import bodyParser from "body-parser";
|
|
@@ -2145,11 +2163,11 @@ import { transform as esbuildTransform } from "esbuild";
|
|
|
2145
2163
|
import { transformWithEsbuild } from "vite";
|
|
2146
2164
|
|
|
2147
2165
|
// src/next/commands/dev-command/server/media.ts
|
|
2148
|
-
import
|
|
2166
|
+
import path7, { join } from "path";
|
|
2149
2167
|
import busboy from "busboy";
|
|
2150
|
-
import
|
|
2168
|
+
import fs6 from "fs-extra";
|
|
2151
2169
|
var createMediaRouter = (config2) => {
|
|
2152
|
-
const mediaFolder =
|
|
2170
|
+
const mediaFolder = path7.join(
|
|
2153
2171
|
config2.rootPath,
|
|
2154
2172
|
config2.publicFolder,
|
|
2155
2173
|
config2.mediaRoot
|
|
@@ -2213,8 +2231,8 @@ var createMediaRouter = (config2) => {
|
|
|
2213
2231
|
);
|
|
2214
2232
|
return;
|
|
2215
2233
|
}
|
|
2216
|
-
await
|
|
2217
|
-
file.pipe(
|
|
2234
|
+
await fs6.ensureDir(path7.dirname(saveTo));
|
|
2235
|
+
file.pipe(fs6.createWriteStream(saveTo));
|
|
2218
2236
|
});
|
|
2219
2237
|
bb.on("error", (error) => {
|
|
2220
2238
|
responded = true;
|
|
@@ -2244,18 +2262,18 @@ var parseMediaFolder = (str) => {
|
|
|
2244
2262
|
var ENCODED_TRAVERSAL_RE = /%2e%2e|%2f|%5c/i;
|
|
2245
2263
|
function resolveRealPath(candidate) {
|
|
2246
2264
|
try {
|
|
2247
|
-
return
|
|
2265
|
+
return fs6.realpathSync(candidate);
|
|
2248
2266
|
} catch {
|
|
2249
|
-
const parent =
|
|
2267
|
+
const parent = path7.dirname(candidate);
|
|
2250
2268
|
if (parent === candidate) return candidate;
|
|
2251
|
-
return
|
|
2269
|
+
return path7.join(resolveRealPath(parent), path7.basename(candidate));
|
|
2252
2270
|
}
|
|
2253
2271
|
}
|
|
2254
2272
|
function assertSymlinkWithinBase(resolved, resolvedBase, userPath) {
|
|
2255
2273
|
try {
|
|
2256
|
-
const realBase =
|
|
2274
|
+
const realBase = fs6.realpathSync(resolvedBase);
|
|
2257
2275
|
const realResolved = resolveRealPath(resolved);
|
|
2258
|
-
if (realResolved !== realBase && !realResolved.startsWith(realBase +
|
|
2276
|
+
if (realResolved !== realBase && !realResolved.startsWith(realBase + path7.sep)) {
|
|
2259
2277
|
throw new PathTraversalError(userPath);
|
|
2260
2278
|
}
|
|
2261
2279
|
} catch (err) {
|
|
@@ -2266,13 +2284,13 @@ function resolveWithinBase(userPath, baseDir) {
|
|
|
2266
2284
|
if (ENCODED_TRAVERSAL_RE.test(userPath)) {
|
|
2267
2285
|
throw new PathTraversalError(userPath);
|
|
2268
2286
|
}
|
|
2269
|
-
const resolvedBase =
|
|
2270
|
-
const resolved =
|
|
2287
|
+
const resolvedBase = path7.resolve(baseDir);
|
|
2288
|
+
const resolved = path7.resolve(path7.join(baseDir, userPath));
|
|
2271
2289
|
if (resolved === resolvedBase) {
|
|
2272
2290
|
assertSymlinkWithinBase(resolved, resolvedBase, userPath);
|
|
2273
2291
|
return resolvedBase;
|
|
2274
2292
|
}
|
|
2275
|
-
if (resolved.startsWith(resolvedBase +
|
|
2293
|
+
if (resolved.startsWith(resolvedBase + path7.sep)) {
|
|
2276
2294
|
assertSymlinkWithinBase(resolved, resolvedBase, userPath);
|
|
2277
2295
|
return resolved;
|
|
2278
2296
|
}
|
|
@@ -2282,12 +2300,12 @@ function resolveStrictlyWithinBase(userPath, baseDir) {
|
|
|
2282
2300
|
if (ENCODED_TRAVERSAL_RE.test(userPath)) {
|
|
2283
2301
|
throw new PathTraversalError(userPath);
|
|
2284
2302
|
}
|
|
2285
|
-
const resolvedBase =
|
|
2286
|
-
const resolved =
|
|
2303
|
+
const resolvedBase = path7.resolve(baseDir) + path7.sep;
|
|
2304
|
+
const resolved = path7.resolve(path7.join(baseDir, userPath));
|
|
2287
2305
|
if (!resolved.startsWith(resolvedBase)) {
|
|
2288
2306
|
throw new PathTraversalError(userPath);
|
|
2289
2307
|
}
|
|
2290
|
-
assertSymlinkWithinBase(resolved,
|
|
2308
|
+
assertSymlinkWithinBase(resolved, path7.resolve(baseDir), userPath);
|
|
2291
2309
|
return resolved;
|
|
2292
2310
|
}
|
|
2293
2311
|
var MediaModel = class {
|
|
@@ -2304,16 +2322,16 @@ var MediaModel = class {
|
|
|
2304
2322
|
const mediaBase = join(this.rootPath, this.publicFolder, this.mediaRoot);
|
|
2305
2323
|
const validatedPath = resolveWithinBase(args.searchPath, mediaBase);
|
|
2306
2324
|
const searchPath = parseMediaFolder(args.searchPath);
|
|
2307
|
-
if (!await
|
|
2325
|
+
if (!await fs6.pathExists(validatedPath)) {
|
|
2308
2326
|
return {
|
|
2309
2327
|
files: [],
|
|
2310
2328
|
directories: []
|
|
2311
2329
|
};
|
|
2312
2330
|
}
|
|
2313
|
-
const filesStr = await
|
|
2331
|
+
const filesStr = await fs6.readdir(validatedPath);
|
|
2314
2332
|
const filesProm = filesStr.map(async (file) => {
|
|
2315
2333
|
const filePath = join(validatedPath, file);
|
|
2316
|
-
const stat = await
|
|
2334
|
+
const stat = await fs6.stat(filePath);
|
|
2317
2335
|
let src = `/${file}`;
|
|
2318
2336
|
const isFile = stat.isFile();
|
|
2319
2337
|
if (!isFile) {
|
|
@@ -2372,8 +2390,8 @@ var MediaModel = class {
|
|
|
2372
2390
|
try {
|
|
2373
2391
|
const mediaBase = join(this.rootPath, this.publicFolder, this.mediaRoot);
|
|
2374
2392
|
const file = resolveStrictlyWithinBase(args.searchPath, mediaBase);
|
|
2375
|
-
await
|
|
2376
|
-
await
|
|
2393
|
+
await fs6.stat(file);
|
|
2394
|
+
await fs6.remove(file);
|
|
2377
2395
|
return { ok: true };
|
|
2378
2396
|
} catch (error) {
|
|
2379
2397
|
if (error instanceof PathTraversalError) throw error;
|
|
@@ -2481,7 +2499,7 @@ var transformTsxPlugin = ({
|
|
|
2481
2499
|
const plug = {
|
|
2482
2500
|
name: "transform-tsx",
|
|
2483
2501
|
async transform(code, id) {
|
|
2484
|
-
const extName =
|
|
2502
|
+
const extName = path8.extname(id);
|
|
2485
2503
|
if (extName.startsWith(".tsx") || extName.startsWith(".ts")) {
|
|
2486
2504
|
const result = await esbuildTransform(code, { loader: "tsx" });
|
|
2487
2505
|
return {
|
|
@@ -2592,7 +2610,7 @@ function viteTransformExtension({
|
|
|
2592
2610
|
async transform(code, id) {
|
|
2593
2611
|
if (filter(id)) {
|
|
2594
2612
|
const { transform: transform2 } = await import("@svgr/core");
|
|
2595
|
-
const svgCode = await
|
|
2613
|
+
const svgCode = await fs7.promises.readFile(
|
|
2596
2614
|
id.replace(/\?.*$/, ""),
|
|
2597
2615
|
"utf8"
|
|
2598
2616
|
);
|
|
@@ -2733,13 +2751,13 @@ var DevCommand = class extends BaseCommand {
|
|
|
2733
2751
|
});
|
|
2734
2752
|
const apiURL2 = await codegen2.execute();
|
|
2735
2753
|
if (!configManager.isUsingLegacyFolder) {
|
|
2736
|
-
const schemaObject = await
|
|
2754
|
+
const schemaObject = await fs8.readJSON(
|
|
2737
2755
|
configManager.generatedSchemaJSONPath
|
|
2738
2756
|
);
|
|
2739
|
-
const lookupObject = await
|
|
2757
|
+
const lookupObject = await fs8.readJSON(
|
|
2740
2758
|
configManager.generatedLookupJSONPath
|
|
2741
2759
|
);
|
|
2742
|
-
const graphqlSchemaObject = await
|
|
2760
|
+
const graphqlSchemaObject = await fs8.readJSON(
|
|
2743
2761
|
configManager.generatedGraphQLJSONPath
|
|
2744
2762
|
);
|
|
2745
2763
|
const tinaLockFilename = "tina-lock.json";
|
|
@@ -2748,8 +2766,8 @@ var DevCommand = class extends BaseCommand {
|
|
|
2748
2766
|
lookup: lookupObject,
|
|
2749
2767
|
graphql: graphqlSchemaObject
|
|
2750
2768
|
});
|
|
2751
|
-
|
|
2752
|
-
|
|
2769
|
+
fs8.writeFileSync(
|
|
2770
|
+
path9.join(configManager.tinaFolderPath, tinaLockFilename),
|
|
2753
2771
|
tinaLockContent
|
|
2754
2772
|
);
|
|
2755
2773
|
if (configManager.hasSeparateContentRoot()) {
|
|
@@ -2757,9 +2775,9 @@ var DevCommand = class extends BaseCommand {
|
|
|
2757
2775
|
configManager.contentRootPath,
|
|
2758
2776
|
{ isContentRoot: true }
|
|
2759
2777
|
);
|
|
2760
|
-
const filePath =
|
|
2761
|
-
await
|
|
2762
|
-
await
|
|
2778
|
+
const filePath = path9.join(rootPath, tinaLockFilename);
|
|
2779
|
+
await fs8.ensureFile(filePath);
|
|
2780
|
+
await fs8.outputFile(filePath, tinaLockContent);
|
|
2763
2781
|
}
|
|
2764
2782
|
}
|
|
2765
2783
|
await this.indexContentWithSpinner({
|
|
@@ -2802,8 +2820,8 @@ ${dangerText(e.message)}
|
|
|
2802
2820
|
const { apiURL, graphQLSchema, tinaSchema } = await setup({
|
|
2803
2821
|
firstTime: true
|
|
2804
2822
|
});
|
|
2805
|
-
await
|
|
2806
|
-
await
|
|
2823
|
+
await fs8.outputFile(configManager.outputHTMLFilePath, devHTML(this.port));
|
|
2824
|
+
await fs8.outputFile(
|
|
2807
2825
|
configManager.outputGitignorePath,
|
|
2808
2826
|
"index.html\nassets/"
|
|
2809
2827
|
);
|
|
@@ -2948,7 +2966,7 @@ ${dangerText(e.message)}
|
|
|
2948
2966
|
watchContentFiles(configManager, database, databaseLock, searchIndexer) {
|
|
2949
2967
|
const collectionContentFiles = [];
|
|
2950
2968
|
configManager.config.schema.collections.forEach((collection) => {
|
|
2951
|
-
const collectionGlob = `${
|
|
2969
|
+
const collectionGlob = `${path9.join(
|
|
2952
2970
|
configManager.contentRootPath,
|
|
2953
2971
|
collection.path
|
|
2954
2972
|
)}/**/*.${collection.format || "md"}`;
|
|
@@ -2998,7 +3016,7 @@ ${dangerText(e.message)}
|
|
|
2998
3016
|
|
|
2999
3017
|
// src/next/commands/build-command/index.ts
|
|
3000
3018
|
import crypto from "crypto";
|
|
3001
|
-
import
|
|
3019
|
+
import path10 from "path";
|
|
3002
3020
|
import { diff } from "@graphql-inspector/core";
|
|
3003
3021
|
import { FilesystemBridge as FilesystemBridge3, buildSchema as buildSchema2 } from "@tinacms/graphql";
|
|
3004
3022
|
import { parseURL as parseURL2 } from "@tinacms/schema-tools";
|
|
@@ -3007,7 +3025,7 @@ import {
|
|
|
3007
3025
|
TinaCMSSearchIndexClient
|
|
3008
3026
|
} from "@tinacms/search";
|
|
3009
3027
|
import { Command as Command3, Option as Option3 } from "clipanion";
|
|
3010
|
-
import
|
|
3028
|
+
import fs9 from "fs-extra";
|
|
3011
3029
|
import {
|
|
3012
3030
|
buildASTSchema as buildASTSchema2,
|
|
3013
3031
|
buildClientSchema,
|
|
@@ -3366,7 +3384,7 @@ ${dangerText(e.message)}
|
|
|
3366
3384
|
}
|
|
3367
3385
|
}
|
|
3368
3386
|
await buildProductionSpa(configManager, database, codegen2.productionUrl);
|
|
3369
|
-
await
|
|
3387
|
+
await fs9.outputFile(
|
|
3370
3388
|
configManager.outputGitignorePath,
|
|
3371
3389
|
"index.html\nassets/"
|
|
3372
3390
|
);
|
|
@@ -3744,7 +3762,7 @@ Additional info: Branch: ${config2.branch}, Client ID: ${config2.clientId} `;
|
|
|
3744
3762
|
}
|
|
3745
3763
|
const localTinaSchema = JSON.parse(
|
|
3746
3764
|
await database.bridge.get(
|
|
3747
|
-
|
|
3765
|
+
path10.join(database.tinaDirectory, "__generated__", "_schema.json")
|
|
3748
3766
|
)
|
|
3749
3767
|
);
|
|
3750
3768
|
localTinaSchema.version = void 0;
|
|
@@ -3866,7 +3884,7 @@ import { buildSchema as buildSchema3 } from "@tinacms/graphql";
|
|
|
3866
3884
|
import prompts from "prompts";
|
|
3867
3885
|
import { Telemetry } from "@tinacms/metrics";
|
|
3868
3886
|
import { resolve } from "@tinacms/graphql";
|
|
3869
|
-
import
|
|
3887
|
+
import chalk6 from "chalk";
|
|
3870
3888
|
var audit = async ({
|
|
3871
3889
|
database,
|
|
3872
3890
|
clean,
|
|
@@ -3884,7 +3902,7 @@ var audit = async ({
|
|
|
3884
3902
|
});
|
|
3885
3903
|
if (clean) {
|
|
3886
3904
|
logger.info(
|
|
3887
|
-
`You are using the \`--clean\` option. This will modify your content as if a user is submitting a form. Before running this you should have a ${
|
|
3905
|
+
`You are using the \`--clean\` option. This will modify your content as if a user is submitting a form. Before running this you should have a ${chalk6.bold(
|
|
3888
3906
|
"clean git tree"
|
|
3889
3907
|
)} so unwanted changes can be undone.
|
|
3890
3908
|
|
|
@@ -3896,13 +3914,13 @@ var audit = async ({
|
|
|
3896
3914
|
message: `Do you want to continue?`
|
|
3897
3915
|
});
|
|
3898
3916
|
if (!res.useClean) {
|
|
3899
|
-
logger.warn(
|
|
3917
|
+
logger.warn(chalk6.yellowBright("\u26A0\uFE0F Audit not complete"));
|
|
3900
3918
|
process.exit(0);
|
|
3901
3919
|
}
|
|
3902
3920
|
}
|
|
3903
3921
|
if (useDefaultValues && !clean) {
|
|
3904
3922
|
logger.warn(
|
|
3905
|
-
|
|
3923
|
+
chalk6.yellowBright(
|
|
3906
3924
|
"WARNING: using the `--useDefaultValues` without the `--clean` flag has no effect. Please re-run audit and add the `--clean` flag"
|
|
3907
3925
|
)
|
|
3908
3926
|
);
|
|
@@ -3930,10 +3948,10 @@ var audit = async ({
|
|
|
3930
3948
|
}
|
|
3931
3949
|
if (error) {
|
|
3932
3950
|
logger.error(
|
|
3933
|
-
|
|
3951
|
+
chalk6.redBright(`\u203C\uFE0F Audit ${chalk6.bold("failed")} with errors`)
|
|
3934
3952
|
);
|
|
3935
3953
|
} else {
|
|
3936
|
-
logger.info(
|
|
3954
|
+
logger.info(chalk6.greenBright("\u2705 Audit passed"));
|
|
3937
3955
|
}
|
|
3938
3956
|
};
|
|
3939
3957
|
var auditDocuments = async (args) => {
|
|
@@ -3961,11 +3979,11 @@ var auditDocuments = async (args) => {
|
|
|
3961
3979
|
if (docResult.errors) {
|
|
3962
3980
|
error = true;
|
|
3963
3981
|
docResult.errors.forEach((err) => {
|
|
3964
|
-
logger.error(
|
|
3982
|
+
logger.error(chalk6.red(err.message));
|
|
3965
3983
|
if (err.originalError.originalError) {
|
|
3966
3984
|
logger.error(
|
|
3967
3985
|
// @ts-ignore FIXME: this doesn't seem right
|
|
3968
|
-
|
|
3986
|
+
chalk6.red(` ${err.originalError.originalError.message}`)
|
|
3969
3987
|
);
|
|
3970
3988
|
}
|
|
3971
3989
|
});
|
|
@@ -4007,7 +4025,7 @@ var auditDocuments = async (args) => {
|
|
|
4007
4025
|
if (mutationRes.errors) {
|
|
4008
4026
|
mutationRes.errors.forEach((err) => {
|
|
4009
4027
|
error = true;
|
|
4010
|
-
logger.error(
|
|
4028
|
+
logger.error(chalk6.red(err.message));
|
|
4011
4029
|
});
|
|
4012
4030
|
}
|
|
4013
4031
|
}
|
|
@@ -4107,26 +4125,26 @@ var AuditCommand = class extends Command4 {
|
|
|
4107
4125
|
import { Command as Command6, Option as Option6 } from "clipanion";
|
|
4108
4126
|
|
|
4109
4127
|
// src/cmds/init/detectEnvironment.ts
|
|
4110
|
-
import
|
|
4111
|
-
import
|
|
4128
|
+
import fs10 from "fs-extra";
|
|
4129
|
+
import path11 from "path";
|
|
4112
4130
|
var checkGitignoreForItem = async ({
|
|
4113
4131
|
baseDir,
|
|
4114
4132
|
line
|
|
4115
4133
|
}) => {
|
|
4116
|
-
const gitignoreContent =
|
|
4134
|
+
const gitignoreContent = fs10.readFileSync(path11.join(baseDir, ".gitignore")).toString();
|
|
4117
4135
|
return gitignoreContent.split("\n").some((item) => item === line);
|
|
4118
4136
|
};
|
|
4119
4137
|
var makeGeneratedFile = async (name2, generatedFileType, parentPath, opts) => {
|
|
4120
4138
|
const result = {
|
|
4121
|
-
fullPathTS:
|
|
4139
|
+
fullPathTS: path11.join(
|
|
4122
4140
|
parentPath,
|
|
4123
4141
|
`${name2}.${opts?.typescriptSuffix || opts?.extensionOverride || "ts"}`
|
|
4124
4142
|
),
|
|
4125
|
-
fullPathJS:
|
|
4143
|
+
fullPathJS: path11.join(
|
|
4126
4144
|
parentPath,
|
|
4127
4145
|
`${name2}.${opts?.extensionOverride || "js"}`
|
|
4128
4146
|
),
|
|
4129
|
-
fullPathOverride: opts?.extensionOverride ?
|
|
4147
|
+
fullPathOverride: opts?.extensionOverride ? path11.join(parentPath, `${name2}.${opts?.extensionOverride}`) : "",
|
|
4130
4148
|
generatedFileType,
|
|
4131
4149
|
name: name2,
|
|
4132
4150
|
parentPath,
|
|
@@ -4144,8 +4162,8 @@ var makeGeneratedFile = async (name2, generatedFileType, parentPath, opts) => {
|
|
|
4144
4162
|
};
|
|
4145
4163
|
}
|
|
4146
4164
|
};
|
|
4147
|
-
result.typescriptExists = await
|
|
4148
|
-
result.javascriptExists = await
|
|
4165
|
+
result.typescriptExists = await fs10.pathExists(result.fullPathTS);
|
|
4166
|
+
result.javascriptExists = await fs10.pathExists(result.fullPathJS);
|
|
4149
4167
|
return result;
|
|
4150
4168
|
};
|
|
4151
4169
|
var detectEnvironment = async ({
|
|
@@ -4154,21 +4172,21 @@ var detectEnvironment = async ({
|
|
|
4154
4172
|
rootPath,
|
|
4155
4173
|
debug = false
|
|
4156
4174
|
}) => {
|
|
4157
|
-
const hasForestryConfig = await
|
|
4158
|
-
|
|
4175
|
+
const hasForestryConfig = await fs10.pathExists(
|
|
4176
|
+
path11.join(pathToForestryConfig, ".forestry", "settings.yml")
|
|
4159
4177
|
);
|
|
4160
|
-
const sampleContentPath =
|
|
4178
|
+
const sampleContentPath = path11.join(
|
|
4161
4179
|
baseDir,
|
|
4162
4180
|
"content",
|
|
4163
4181
|
"posts",
|
|
4164
4182
|
"hello-world.md"
|
|
4165
4183
|
);
|
|
4166
|
-
const usingSrc =
|
|
4167
|
-
const tinaFolder =
|
|
4184
|
+
const usingSrc = fs10.pathExistsSync(path11.join(baseDir, "src")) && (fs10.pathExistsSync(path11.join(baseDir, "src", "app")) || fs10.pathExistsSync(path11.join(baseDir, "src", "pages")));
|
|
4185
|
+
const tinaFolder = path11.join(baseDir, "tina");
|
|
4168
4186
|
const tinaConfigExists = Boolean(
|
|
4169
4187
|
// Does the tina folder exist?
|
|
4170
|
-
await
|
|
4171
|
-
(await
|
|
4188
|
+
await fs10.pathExists(tinaFolder) && // Does the tina folder contain a config file?
|
|
4189
|
+
(await fs10.readdir(tinaFolder)).find((x) => x.includes("config"))
|
|
4172
4190
|
);
|
|
4173
4191
|
const pagesDir = [baseDir, usingSrc ? "src" : false, "pages"].filter(
|
|
4174
4192
|
Boolean
|
|
@@ -4180,12 +4198,12 @@ var detectEnvironment = async ({
|
|
|
4180
4198
|
"next-api-handler": await makeGeneratedFile(
|
|
4181
4199
|
"[...routes]",
|
|
4182
4200
|
"next-api-handler",
|
|
4183
|
-
|
|
4201
|
+
path11.join(...pagesDir, "api", "tina")
|
|
4184
4202
|
),
|
|
4185
4203
|
"reactive-example": await makeGeneratedFile(
|
|
4186
4204
|
"[filename]",
|
|
4187
4205
|
"reactive-example",
|
|
4188
|
-
|
|
4206
|
+
path11.join(...pagesDir, "demo", "blog"),
|
|
4189
4207
|
{
|
|
4190
4208
|
typescriptSuffix: "tsx"
|
|
4191
4209
|
}
|
|
@@ -4193,22 +4211,22 @@ var detectEnvironment = async ({
|
|
|
4193
4211
|
"users-json": await makeGeneratedFile(
|
|
4194
4212
|
"index",
|
|
4195
4213
|
"users-json",
|
|
4196
|
-
|
|
4214
|
+
path11.join(baseDir, "content", "users"),
|
|
4197
4215
|
{ extensionOverride: "json" }
|
|
4198
4216
|
),
|
|
4199
4217
|
"sample-content": await makeGeneratedFile(
|
|
4200
4218
|
"hello-world",
|
|
4201
4219
|
"sample-content",
|
|
4202
|
-
|
|
4220
|
+
path11.join(baseDir, "content", "posts"),
|
|
4203
4221
|
{ extensionOverride: "md" }
|
|
4204
4222
|
)
|
|
4205
4223
|
};
|
|
4206
|
-
const hasSampleContent = await
|
|
4207
|
-
const hasPackageJSON = await
|
|
4224
|
+
const hasSampleContent = await fs10.pathExists(sampleContentPath);
|
|
4225
|
+
const hasPackageJSON = await fs10.pathExists("package.json");
|
|
4208
4226
|
let hasTinaDeps = false;
|
|
4209
4227
|
if (hasPackageJSON) {
|
|
4210
4228
|
try {
|
|
4211
|
-
const packageJSON = await
|
|
4229
|
+
const packageJSON = await fs10.readJSON("package.json");
|
|
4212
4230
|
const deps = [];
|
|
4213
4231
|
if (packageJSON?.dependencies) {
|
|
4214
4232
|
deps.push(...Object.keys(packageJSON.dependencies));
|
|
@@ -4225,15 +4243,15 @@ var detectEnvironment = async ({
|
|
|
4225
4243
|
);
|
|
4226
4244
|
}
|
|
4227
4245
|
}
|
|
4228
|
-
const hasGitIgnore = await
|
|
4246
|
+
const hasGitIgnore = await fs10.pathExists(path11.join(".gitignore"));
|
|
4229
4247
|
const hasGitIgnoreNodeModules = hasGitIgnore && await checkGitignoreForItem({ baseDir, line: "node_modules" });
|
|
4230
4248
|
const hasEnvTina = hasGitIgnore && await checkGitignoreForItem({ baseDir, line: ".env.tina" });
|
|
4231
4249
|
const hasGitIgnoreEnv = hasGitIgnore && await checkGitignoreForItem({ baseDir, line: ".env" });
|
|
4232
4250
|
let frontMatterFormat;
|
|
4233
4251
|
if (hasForestryConfig) {
|
|
4234
|
-
const hugoConfigPath =
|
|
4235
|
-
if (await
|
|
4236
|
-
const hugoConfig = await
|
|
4252
|
+
const hugoConfigPath = path11.join(rootPath, "config.toml");
|
|
4253
|
+
if (await fs10.pathExists(hugoConfigPath)) {
|
|
4254
|
+
const hugoConfig = await fs10.readFile(hugoConfigPath, "utf8");
|
|
4237
4255
|
const metaDataFormat = hugoConfig.toString().match(/metaDataFormat = "(.*)"/)?.[1];
|
|
4238
4256
|
if (metaDataFormat && (metaDataFormat === "yaml" || metaDataFormat === "toml" || metaDataFormat === "json")) {
|
|
4239
4257
|
frontMatterFormat = metaDataFormat;
|
|
@@ -4846,21 +4864,21 @@ var CLICommand = class {
|
|
|
4846
4864
|
};
|
|
4847
4865
|
|
|
4848
4866
|
// src/cmds/init/apply.ts
|
|
4849
|
-
import
|
|
4867
|
+
import path15 from "path";
|
|
4850
4868
|
|
|
4851
4869
|
// src/cmds/forestry-migrate/index.ts
|
|
4852
|
-
import
|
|
4853
|
-
import
|
|
4870
|
+
import fs12 from "fs-extra";
|
|
4871
|
+
import path13 from "path";
|
|
4854
4872
|
import yaml2 from "js-yaml";
|
|
4855
4873
|
import pkg from "minimatch";
|
|
4856
4874
|
import { parseFile, stringifyFile } from "@tinacms/graphql";
|
|
4857
4875
|
import { CONTENT_FORMATS } from "@tinacms/schema-tools";
|
|
4858
4876
|
|
|
4859
4877
|
// src/cmds/forestry-migrate/util/index.ts
|
|
4860
|
-
import
|
|
4861
|
-
import
|
|
4878
|
+
import fs11 from "fs-extra";
|
|
4879
|
+
import path12 from "path";
|
|
4862
4880
|
import yaml from "js-yaml";
|
|
4863
|
-
import
|
|
4881
|
+
import z2 from "zod";
|
|
4864
4882
|
|
|
4865
4883
|
// src/cmds/forestry-migrate/util/errorSingleton.ts
|
|
4866
4884
|
var ErrorSingleton = class _ErrorSingleton {
|
|
@@ -4987,82 +5005,82 @@ var stringifyTemplateName = (name2, template) => {
|
|
|
4987
5005
|
return newName;
|
|
4988
5006
|
}
|
|
4989
5007
|
};
|
|
4990
|
-
var forestryConfigSchema =
|
|
4991
|
-
sections:
|
|
4992
|
-
|
|
4993
|
-
type:
|
|
4994
|
-
|
|
4995
|
-
|
|
4996
|
-
|
|
4997
|
-
|
|
4998
|
-
|
|
5008
|
+
var forestryConfigSchema = z2.object({
|
|
5009
|
+
sections: z2.array(
|
|
5010
|
+
z2.object({
|
|
5011
|
+
type: z2.union([
|
|
5012
|
+
z2.literal("directory"),
|
|
5013
|
+
z2.literal("document"),
|
|
5014
|
+
z2.literal("heading"),
|
|
5015
|
+
z2.literal("jekyll-pages"),
|
|
5016
|
+
z2.literal("jekyll-posts")
|
|
4999
5017
|
]),
|
|
5000
|
-
label:
|
|
5001
|
-
path:
|
|
5002
|
-
match:
|
|
5003
|
-
exclude:
|
|
5004
|
-
create:
|
|
5005
|
-
templates:
|
|
5006
|
-
new_doc_ext:
|
|
5007
|
-
read_only:
|
|
5018
|
+
label: z2.string(),
|
|
5019
|
+
path: z2.string().optional().nullable(),
|
|
5020
|
+
match: z2.string().optional().nullable(),
|
|
5021
|
+
exclude: z2.string().optional().nullable(),
|
|
5022
|
+
create: z2.union([z2.literal("all"), z2.literal("documents"), z2.literal("none")]).optional(),
|
|
5023
|
+
templates: z2.array(z2.string()).optional().nullable(),
|
|
5024
|
+
new_doc_ext: z2.string().optional().nullable(),
|
|
5025
|
+
read_only: z2.boolean().optional().nullable()
|
|
5008
5026
|
})
|
|
5009
5027
|
)
|
|
5010
5028
|
});
|
|
5011
|
-
var forestryFieldWithoutField =
|
|
5029
|
+
var forestryFieldWithoutField = z2.object({
|
|
5012
5030
|
// TODO: maybe better type this?
|
|
5013
|
-
type:
|
|
5014
|
-
|
|
5015
|
-
|
|
5016
|
-
|
|
5017
|
-
|
|
5018
|
-
|
|
5019
|
-
|
|
5020
|
-
|
|
5021
|
-
|
|
5022
|
-
|
|
5023
|
-
|
|
5024
|
-
|
|
5025
|
-
|
|
5026
|
-
|
|
5027
|
-
|
|
5028
|
-
|
|
5031
|
+
type: z2.union([
|
|
5032
|
+
z2.literal("text"),
|
|
5033
|
+
z2.literal("datetime"),
|
|
5034
|
+
z2.literal("list"),
|
|
5035
|
+
z2.literal("file"),
|
|
5036
|
+
z2.literal("image_gallery"),
|
|
5037
|
+
z2.literal("textarea"),
|
|
5038
|
+
z2.literal("tag_list"),
|
|
5039
|
+
z2.literal("number"),
|
|
5040
|
+
z2.literal("boolean"),
|
|
5041
|
+
z2.literal("field_group"),
|
|
5042
|
+
z2.literal("field_group_list"),
|
|
5043
|
+
z2.literal("select"),
|
|
5044
|
+
z2.literal("include"),
|
|
5045
|
+
z2.literal("blocks"),
|
|
5046
|
+
z2.literal("color")
|
|
5029
5047
|
]),
|
|
5030
|
-
template_types:
|
|
5031
|
-
name:
|
|
5032
|
-
label:
|
|
5033
|
-
default:
|
|
5034
|
-
template:
|
|
5035
|
-
config:
|
|
5048
|
+
template_types: z2.array(z2.string()).optional().nullable(),
|
|
5049
|
+
name: z2.string(),
|
|
5050
|
+
label: z2.string(),
|
|
5051
|
+
default: z2.any().optional(),
|
|
5052
|
+
template: z2.string().optional(),
|
|
5053
|
+
config: z2.object({
|
|
5036
5054
|
// min and max are used for lists
|
|
5037
|
-
min:
|
|
5038
|
-
max:
|
|
5039
|
-
required:
|
|
5040
|
-
use_select:
|
|
5041
|
-
date_format:
|
|
5042
|
-
time_format:
|
|
5043
|
-
options:
|
|
5044
|
-
source:
|
|
5045
|
-
type:
|
|
5046
|
-
|
|
5047
|
-
|
|
5048
|
-
|
|
5049
|
-
|
|
5055
|
+
min: z2.number().optional().nullable(),
|
|
5056
|
+
max: z2.number().optional().nullable(),
|
|
5057
|
+
required: z2.boolean().optional().nullable(),
|
|
5058
|
+
use_select: z2.boolean().optional().nullable(),
|
|
5059
|
+
date_format: z2.string().optional().nullable(),
|
|
5060
|
+
time_format: z2.string().optional().nullable(),
|
|
5061
|
+
options: z2.array(z2.string()).optional().nullable(),
|
|
5062
|
+
source: z2.object({
|
|
5063
|
+
type: z2.union([
|
|
5064
|
+
z2.literal("custom"),
|
|
5065
|
+
z2.literal("pages"),
|
|
5066
|
+
z2.literal("documents"),
|
|
5067
|
+
z2.literal("simple"),
|
|
5050
5068
|
// TODO: I want to ignore this key if its invalid
|
|
5051
|
-
|
|
5069
|
+
z2.string()
|
|
5052
5070
|
]).optional().nullable(),
|
|
5053
|
-
section:
|
|
5071
|
+
section: z2.string().optional().nullable()
|
|
5054
5072
|
}).optional()
|
|
5055
5073
|
}).optional()
|
|
5056
5074
|
});
|
|
5057
|
-
var forestryField =
|
|
5075
|
+
var forestryField = z2.lazy(
|
|
5058
5076
|
() => forestryFieldWithoutField.extend({
|
|
5059
|
-
fields:
|
|
5077
|
+
fields: z2.array(forestryField).optional()
|
|
5060
5078
|
})
|
|
5061
5079
|
);
|
|
5062
|
-
var FrontmatterTemplateSchema =
|
|
5063
|
-
label:
|
|
5064
|
-
hide_body:
|
|
5065
|
-
fields:
|
|
5080
|
+
var FrontmatterTemplateSchema = z2.object({
|
|
5081
|
+
label: z2.string(),
|
|
5082
|
+
hide_body: z2.boolean().optional(),
|
|
5083
|
+
fields: z2.array(forestryField).optional()
|
|
5066
5084
|
});
|
|
5067
5085
|
var transformForestryFieldsToTinaFields = ({
|
|
5068
5086
|
fields,
|
|
@@ -5285,7 +5303,7 @@ var transformForestryFieldsToTinaFields = ({
|
|
|
5285
5303
|
return tinaFields;
|
|
5286
5304
|
};
|
|
5287
5305
|
var getFieldsFromTemplates = ({ tem, pathToForestryConfig, skipBlocks = false }) => {
|
|
5288
|
-
const templatePath =
|
|
5306
|
+
const templatePath = path12.join(
|
|
5289
5307
|
pathToForestryConfig,
|
|
5290
5308
|
".forestry",
|
|
5291
5309
|
"front_matter",
|
|
@@ -5294,7 +5312,7 @@ var getFieldsFromTemplates = ({ tem, pathToForestryConfig, skipBlocks = false })
|
|
|
5294
5312
|
);
|
|
5295
5313
|
let templateString = "";
|
|
5296
5314
|
try {
|
|
5297
|
-
templateString =
|
|
5315
|
+
templateString = fs11.readFileSync(templatePath).toString();
|
|
5298
5316
|
} catch {
|
|
5299
5317
|
throw new Error(
|
|
5300
5318
|
`Could not find template ${tem} at ${templatePath}
|
|
@@ -5360,9 +5378,9 @@ function checkExt(ext) {
|
|
|
5360
5378
|
var generateAllTemplates = async ({
|
|
5361
5379
|
pathToForestryConfig
|
|
5362
5380
|
}) => {
|
|
5363
|
-
const allTemplates = (await
|
|
5364
|
-
|
|
5365
|
-
)).map((tem) =>
|
|
5381
|
+
const allTemplates = (await fs12.readdir(
|
|
5382
|
+
path13.join(pathToForestryConfig, ".forestry", "front_matter", "templates")
|
|
5383
|
+
)).map((tem) => path13.basename(tem, ".yml"));
|
|
5366
5384
|
const templateMap = /* @__PURE__ */ new Map();
|
|
5367
5385
|
const proms = allTemplates.map(async (tem) => {
|
|
5368
5386
|
try {
|
|
@@ -5507,9 +5525,9 @@ var generateCollectionFromForestrySection = (args) => {
|
|
|
5507
5525
|
return c;
|
|
5508
5526
|
} else if (section.type === "document") {
|
|
5509
5527
|
const filePath = section.path;
|
|
5510
|
-
const extname =
|
|
5511
|
-
const fileName =
|
|
5512
|
-
const dir =
|
|
5528
|
+
const extname = path13.extname(filePath);
|
|
5529
|
+
const fileName = path13.basename(filePath, extname);
|
|
5530
|
+
const dir = path13.dirname(filePath);
|
|
5513
5531
|
const ext = checkExt(extname);
|
|
5514
5532
|
if (ext) {
|
|
5515
5533
|
const fields = [];
|
|
@@ -5571,8 +5589,8 @@ var generateCollections = async ({
|
|
|
5571
5589
|
templateMap,
|
|
5572
5590
|
usingTypescript
|
|
5573
5591
|
});
|
|
5574
|
-
const forestryConfig = await
|
|
5575
|
-
|
|
5592
|
+
const forestryConfig = await fs12.readFile(
|
|
5593
|
+
path13.join(pathToForestryConfig, ".forestry", "settings.yml")
|
|
5576
5594
|
);
|
|
5577
5595
|
rewriteTemplateKeysInDocs({
|
|
5578
5596
|
templateMap,
|
|
@@ -5602,12 +5620,12 @@ var rewriteTemplateKeysInDocs = (args) => {
|
|
|
5602
5620
|
const { templateObj } = templateMap.get(templateKey);
|
|
5603
5621
|
templateObj?.pages?.forEach((page) => {
|
|
5604
5622
|
try {
|
|
5605
|
-
const filePath =
|
|
5606
|
-
if (
|
|
5623
|
+
const filePath = path13.join(page);
|
|
5624
|
+
if (fs12.lstatSync(filePath).isDirectory()) {
|
|
5607
5625
|
return;
|
|
5608
5626
|
}
|
|
5609
|
-
const extname =
|
|
5610
|
-
const fileContent =
|
|
5627
|
+
const extname = path13.extname(filePath);
|
|
5628
|
+
const fileContent = fs12.readFileSync(filePath).toString();
|
|
5611
5629
|
const content = parseFile(
|
|
5612
5630
|
fileContent,
|
|
5613
5631
|
extname,
|
|
@@ -5618,7 +5636,7 @@ var rewriteTemplateKeysInDocs = (args) => {
|
|
|
5618
5636
|
_template: stringifyLabel(templateKey),
|
|
5619
5637
|
...content
|
|
5620
5638
|
};
|
|
5621
|
-
|
|
5639
|
+
fs12.writeFileSync(
|
|
5622
5640
|
filePath,
|
|
5623
5641
|
stringifyFile(newContent, extname, true, markdownParseConfig)
|
|
5624
5642
|
);
|
|
@@ -5633,12 +5651,12 @@ var rewriteTemplateKeysInDocs = (args) => {
|
|
|
5633
5651
|
|
|
5634
5652
|
// src/cmds/init/apply.ts
|
|
5635
5653
|
import { Telemetry as Telemetry2 } from "@tinacms/metrics";
|
|
5636
|
-
import
|
|
5654
|
+
import fs15 from "fs-extra";
|
|
5637
5655
|
|
|
5638
5656
|
// src/next/commands/codemod-command/index.ts
|
|
5639
5657
|
import { Command as Command5, Option as Option5 } from "clipanion";
|
|
5640
|
-
import
|
|
5641
|
-
import
|
|
5658
|
+
import fs13 from "fs-extra";
|
|
5659
|
+
import path14 from "path";
|
|
5642
5660
|
var CodemodCommand = class extends Command5 {
|
|
5643
5661
|
static paths = [["codemod"], ["codemod", "move-tina-folder"]];
|
|
5644
5662
|
rootPath = Option5.String("--rootPath", {
|
|
@@ -5679,13 +5697,13 @@ var moveTinaFolder = async (rootPath = process.cwd()) => {
|
|
|
5679
5697
|
logger.error(e.message);
|
|
5680
5698
|
process.exit(1);
|
|
5681
5699
|
}
|
|
5682
|
-
const tinaDestination =
|
|
5683
|
-
if (await
|
|
5700
|
+
const tinaDestination = path14.join(configManager.rootPath, "tina");
|
|
5701
|
+
if (await fs13.existsSync(tinaDestination)) {
|
|
5684
5702
|
logger.info(
|
|
5685
5703
|
`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.`
|
|
5686
5704
|
);
|
|
5687
5705
|
} else {
|
|
5688
|
-
await
|
|
5706
|
+
await fs13.moveSync(configManager.tinaFolderPath, tinaDestination);
|
|
5689
5707
|
await writeGitignore(configManager.rootPath);
|
|
5690
5708
|
logger.info(
|
|
5691
5709
|
"Move to 'tina' folder complete. Be sure to update any imports of the autogenerated client!"
|
|
@@ -5693,8 +5711,8 @@ var moveTinaFolder = async (rootPath = process.cwd()) => {
|
|
|
5693
5711
|
}
|
|
5694
5712
|
};
|
|
5695
5713
|
var writeGitignore = async (rootPath) => {
|
|
5696
|
-
await
|
|
5697
|
-
|
|
5714
|
+
await fs13.outputFileSync(
|
|
5715
|
+
path14.join(rootPath, "tina", ".gitignore"),
|
|
5698
5716
|
"__generated__"
|
|
5699
5717
|
);
|
|
5700
5718
|
};
|
|
@@ -6132,7 +6150,7 @@ function extendNextScripts(scripts, opts) {
|
|
|
6132
6150
|
|
|
6133
6151
|
// src/cmds/init/codegen/index.ts
|
|
6134
6152
|
import ts2 from "typescript";
|
|
6135
|
-
import
|
|
6153
|
+
import fs14 from "fs-extra";
|
|
6136
6154
|
|
|
6137
6155
|
// src/cmds/init/codegen/util.ts
|
|
6138
6156
|
import ts from "typescript";
|
|
@@ -6369,7 +6387,7 @@ var addSelfHostedTinaAuthToConfig = async (config2, configFile) => {
|
|
|
6369
6387
|
const pathToConfig = configFile.resolve(config2.typescript).path;
|
|
6370
6388
|
const sourceFile = ts2.createSourceFile(
|
|
6371
6389
|
pathToConfig,
|
|
6372
|
-
|
|
6390
|
+
fs14.readFileSync(pathToConfig, "utf8"),
|
|
6373
6391
|
config2.typescript ? ts2.ScriptTarget.Latest : ts2.ScriptTarget.ESNext
|
|
6374
6392
|
);
|
|
6375
6393
|
const { configImports, configAuthProviderClass, extraTinaCollections } = config2.authProvider;
|
|
@@ -6419,7 +6437,7 @@ var addSelfHostedTinaAuthToConfig = async (config2, configFile) => {
|
|
|
6419
6437
|
)
|
|
6420
6438
|
].map((visitor) => makeTransformer(visitor))
|
|
6421
6439
|
);
|
|
6422
|
-
return
|
|
6440
|
+
return fs14.writeFile(
|
|
6423
6441
|
pathToConfig,
|
|
6424
6442
|
ts2.createPrinter({ omitTrailingSemicolon: true }).printFile(transformedSourceFileResult.transformed[0])
|
|
6425
6443
|
);
|
|
@@ -6537,8 +6555,8 @@ async function apply({
|
|
|
6537
6555
|
await addConfigFile({
|
|
6538
6556
|
configArgs: {
|
|
6539
6557
|
config: config2,
|
|
6540
|
-
publicFolder:
|
|
6541
|
-
|
|
6558
|
+
publicFolder: path15.join(
|
|
6559
|
+
path15.relative(process.cwd(), pathToForestryConfig),
|
|
6542
6560
|
config2.publicFolder
|
|
6543
6561
|
),
|
|
6544
6562
|
collections,
|
|
@@ -6611,18 +6629,18 @@ var createPackageJSON = async () => {
|
|
|
6611
6629
|
};
|
|
6612
6630
|
var createGitignore = async ({ baseDir }) => {
|
|
6613
6631
|
logger.info(logText("No .gitignore found, creating one"));
|
|
6614
|
-
|
|
6632
|
+
fs15.outputFileSync(path15.join(baseDir, ".gitignore"), "node_modules");
|
|
6615
6633
|
};
|
|
6616
6634
|
var updateGitIgnore = async ({
|
|
6617
6635
|
baseDir,
|
|
6618
6636
|
items
|
|
6619
6637
|
}) => {
|
|
6620
6638
|
logger.info(logText(`Adding ${items.join(",")} to .gitignore`));
|
|
6621
|
-
const gitignoreContent =
|
|
6639
|
+
const gitignoreContent = fs15.readFileSync(path15.join(baseDir, ".gitignore")).toString();
|
|
6622
6640
|
const newGitignoreContent = [...gitignoreContent.split("\n"), ...items].join(
|
|
6623
6641
|
"\n"
|
|
6624
6642
|
);
|
|
6625
|
-
await
|
|
6643
|
+
await fs15.writeFile(path15.join(baseDir, ".gitignore"), newGitignoreContent);
|
|
6626
6644
|
};
|
|
6627
6645
|
var addDependencies = async (config2, env, params) => {
|
|
6628
6646
|
const { packageManager } = config2;
|
|
@@ -6693,22 +6711,22 @@ var writeGeneratedFile = async ({
|
|
|
6693
6711
|
content,
|
|
6694
6712
|
typescript
|
|
6695
6713
|
}) => {
|
|
6696
|
-
const { exists, path:
|
|
6714
|
+
const { exists, path: path16, parentPath } = generatedFile.resolve(typescript);
|
|
6697
6715
|
if (exists) {
|
|
6698
6716
|
if (overwrite) {
|
|
6699
|
-
logger.info(`Overwriting file at ${
|
|
6700
|
-
|
|
6717
|
+
logger.info(`Overwriting file at ${path16}... \u2705`);
|
|
6718
|
+
fs15.outputFileSync(path16, content);
|
|
6701
6719
|
} else {
|
|
6702
|
-
logger.info(`Not overwriting file at ${
|
|
6720
|
+
logger.info(`Not overwriting file at ${path16}.`);
|
|
6703
6721
|
logger.info(
|
|
6704
|
-
logText(`Please add the following to ${
|
|
6722
|
+
logText(`Please add the following to ${path16}:
|
|
6705
6723
|
${indentText(content)}}`)
|
|
6706
6724
|
);
|
|
6707
6725
|
}
|
|
6708
6726
|
} else {
|
|
6709
|
-
logger.info(`Adding file at ${
|
|
6710
|
-
await
|
|
6711
|
-
|
|
6727
|
+
logger.info(`Adding file at ${path16}... \u2705`);
|
|
6728
|
+
await fs15.ensureDir(parentPath);
|
|
6729
|
+
fs15.outputFileSync(path16, content);
|
|
6712
6730
|
}
|
|
6713
6731
|
};
|
|
6714
6732
|
var addConfigFile = async ({
|
|
@@ -6786,7 +6804,7 @@ var addContentFile = async ({
|
|
|
6786
6804
|
return () => ({
|
|
6787
6805
|
exists: env.sampleContentExists,
|
|
6788
6806
|
path: env.sampleContentPath,
|
|
6789
|
-
parentPath:
|
|
6807
|
+
parentPath: path15.dirname(env.sampleContentPath)
|
|
6790
6808
|
});
|
|
6791
6809
|
}
|
|
6792
6810
|
},
|
|
@@ -6809,10 +6827,10 @@ ${titleText(" TinaCMS ")} backend initialized!`));
|
|
|
6809
6827
|
return `${x.key}=${x.value || "***"}`;
|
|
6810
6828
|
}).join("\n") + `
|
|
6811
6829
|
TINA_PUBLIC_IS_LOCAL=true`;
|
|
6812
|
-
const envFile =
|
|
6813
|
-
if (!
|
|
6830
|
+
const envFile = path15.join(process.cwd(), ".env");
|
|
6831
|
+
if (!fs15.existsSync(envFile)) {
|
|
6814
6832
|
logger.info(`Adding .env file to your project... \u2705`);
|
|
6815
|
-
|
|
6833
|
+
fs15.writeFileSync(envFile, envFileText);
|
|
6816
6834
|
} else {
|
|
6817
6835
|
logger.info(
|
|
6818
6836
|
"Please add the following environment variables to your .env file"
|
|
@@ -6881,7 +6899,7 @@ var addReactiveFile = {
|
|
|
6881
6899
|
baseDir,
|
|
6882
6900
|
dataLayer
|
|
6883
6901
|
}) => {
|
|
6884
|
-
const packageJsonPath =
|
|
6902
|
+
const packageJsonPath = path15.join(baseDir, "package.json");
|
|
6885
6903
|
await writeGeneratedFile({
|
|
6886
6904
|
generatedFile,
|
|
6887
6905
|
typescript: config2.typescript,
|
|
@@ -6894,7 +6912,7 @@ var addReactiveFile = {
|
|
|
6894
6912
|
})
|
|
6895
6913
|
});
|
|
6896
6914
|
logger.info("Adding a nextjs example... \u2705");
|
|
6897
|
-
const packageJson = JSON.parse(
|
|
6915
|
+
const packageJson = JSON.parse(fs15.readFileSync(packageJsonPath).toString());
|
|
6898
6916
|
const scripts = packageJson.scripts || {};
|
|
6899
6917
|
const updatedPackageJson = JSON.stringify(
|
|
6900
6918
|
{
|
|
@@ -6907,7 +6925,7 @@ var addReactiveFile = {
|
|
|
6907
6925
|
null,
|
|
6908
6926
|
2
|
|
6909
6927
|
);
|
|
6910
|
-
|
|
6928
|
+
fs15.writeFileSync(packageJsonPath, updatedPackageJson);
|
|
6911
6929
|
}
|
|
6912
6930
|
};
|
|
6913
6931
|
function execShellCommand(cmd) {
|