@tinacms/cli 0.0.0-d28d795-20250427004334 → 0.0.0-d4c653b-20251027224657
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -5
- package/dist/cmds/forestry-migrate/index.d.ts +2 -2
- package/dist/cmds/init/index.d.ts +2 -2
- package/dist/cmds/init/prompts/index.d.ts +3 -2
- package/dist/cmds/init/prompts/types.d.ts +3 -2
- package/dist/index.d.ts +4 -1
- package/dist/index.js +447 -412
- package/dist/next/commands/build-command/index.d.ts +3 -0
- package/dist/utils/path.d.ts +3 -0
- package/dist/utils/sleep.d.ts +1 -0
- package/package.json +13 -8
package/dist/index.js
CHANGED
|
@@ -35,10 +35,10 @@ module.exports = __toCommonJS(index_exports);
|
|
|
35
35
|
var import_clipanion8 = require("clipanion");
|
|
36
36
|
|
|
37
37
|
// package.json
|
|
38
|
-
var version = "1.
|
|
38
|
+
var version = "1.11.0";
|
|
39
39
|
|
|
40
40
|
// src/next/commands/dev-command/index.ts
|
|
41
|
-
var
|
|
41
|
+
var import_path7 = __toESM(require("path"));
|
|
42
42
|
var import_graphql10 = require("@tinacms/graphql");
|
|
43
43
|
var import_search = require("@tinacms/search");
|
|
44
44
|
var import_async_lock = __toESM(require("async-lock"));
|
|
@@ -587,13 +587,12 @@ var Codegen = class {
|
|
|
587
587
|
return apiURL;
|
|
588
588
|
}
|
|
589
589
|
_createApiUrl() {
|
|
590
|
-
|
|
591
|
-
const
|
|
592
|
-
const
|
|
593
|
-
const token = (_c = this.configManager.config) == null ? void 0 : _c.token;
|
|
590
|
+
const branch = this.configManager.config?.branch;
|
|
591
|
+
const clientId = this.configManager.config?.clientId;
|
|
592
|
+
const token = this.configManager.config?.token;
|
|
594
593
|
const fullVersion = this.configManager.getTinaGraphQLVersion();
|
|
595
594
|
const version2 = `${fullVersion.major}.${fullVersion.minor}`;
|
|
596
|
-
const baseUrl =
|
|
595
|
+
const baseUrl = this.configManager.config.tinaioConfig?.contentApiUrlOverride || `https://${TINA_HOST}`;
|
|
597
596
|
if ((!branch || !clientId || !token) && !this.port && !this.configManager.config.contentApiUrlOverride) {
|
|
598
597
|
const missing = [];
|
|
599
598
|
if (!branch) missing.push("branch");
|
|
@@ -602,7 +601,7 @@ var Codegen = class {
|
|
|
602
601
|
throw new Error(
|
|
603
602
|
`Client not configured properly. Missing ${missing.join(
|
|
604
603
|
", "
|
|
605
|
-
)}. Please visit https://tina.io/docs/
|
|
604
|
+
)}. Please visit https://tina.io/docs/r/what-is-tinacloud for more information`
|
|
606
605
|
);
|
|
607
606
|
}
|
|
608
607
|
let localUrl = `http://localhost:${this.port}/graphql`;
|
|
@@ -621,7 +620,6 @@ var Codegen = class {
|
|
|
621
620
|
return this.apiURL;
|
|
622
621
|
}
|
|
623
622
|
async genDatabaseClient() {
|
|
624
|
-
var _a, _b;
|
|
625
623
|
const authCollection = this.tinaSchema.getCollections().find((c) => c.isAuthCollection);
|
|
626
624
|
let authFields = [];
|
|
627
625
|
if (authCollection) {
|
|
@@ -632,7 +630,7 @@ var Codegen = class {
|
|
|
632
630
|
if (usersFields.length > 1) {
|
|
633
631
|
throw new Error("Only one user field is allowed");
|
|
634
632
|
}
|
|
635
|
-
authFields =
|
|
633
|
+
authFields = usersFields[0]?.collectable?.fields.map((f) => {
|
|
636
634
|
if (f.type !== "password" && f.type !== "object") {
|
|
637
635
|
if (f.uid) {
|
|
638
636
|
return `id:${f.name}`;
|
|
@@ -710,9 +708,8 @@ export default databaseClient;
|
|
|
710
708
|
`;
|
|
711
709
|
}
|
|
712
710
|
async genClient() {
|
|
713
|
-
|
|
714
|
-
const
|
|
715
|
-
const errorPolicy = (_c = (_b = this.configManager.config) == null ? void 0 : _b.client) == null ? void 0 : _c.errorPolicy;
|
|
711
|
+
const token = this.configManager.config?.token;
|
|
712
|
+
const errorPolicy = this.configManager.config?.client?.errorPolicy;
|
|
716
713
|
const apiURL = this.getApiURL();
|
|
717
714
|
const clientString = `import { createClient } from "tinacms/dist/client";
|
|
718
715
|
import { queries } from "./types";
|
|
@@ -778,12 +775,25 @@ var unlinkIfExists = async (filepath) => {
|
|
|
778
775
|
|
|
779
776
|
// src/next/config-manager.ts
|
|
780
777
|
var import_fs_extra2 = __toESM(require("fs-extra"));
|
|
781
|
-
var
|
|
778
|
+
var import_path3 = __toESM(require("path"));
|
|
782
779
|
var import_os = __toESM(require("os"));
|
|
783
780
|
var esbuild = __toESM(require("esbuild"));
|
|
784
781
|
var dotenv = __toESM(require("dotenv"));
|
|
785
782
|
var import_normalize_path2 = __toESM(require("normalize-path"));
|
|
786
783
|
var import_chalk3 = __toESM(require("chalk"));
|
|
784
|
+
|
|
785
|
+
// src/utils/path.ts
|
|
786
|
+
var import_path2 = __toESM(require("path"));
|
|
787
|
+
function stripNativeTrailingSlash(p) {
|
|
788
|
+
const { root } = import_path2.default.parse(p);
|
|
789
|
+
let str = p;
|
|
790
|
+
while (str.length > root.length && str.endsWith(import_path2.default.sep)) {
|
|
791
|
+
str = str.slice(0, -1);
|
|
792
|
+
}
|
|
793
|
+
return str;
|
|
794
|
+
}
|
|
795
|
+
|
|
796
|
+
// src/next/config-manager.ts
|
|
787
797
|
var TINA_FOLDER = "tina";
|
|
788
798
|
var LEGACY_TINA_FOLDER = ".tina";
|
|
789
799
|
var GENERATED_FOLDER = "__generated__";
|
|
@@ -802,7 +812,7 @@ var ConfigManager = class {
|
|
|
802
812
|
this.legacyNoSDK = legacyNoSDK;
|
|
803
813
|
}
|
|
804
814
|
isUsingTs() {
|
|
805
|
-
return [".ts", ".tsx"].includes(
|
|
815
|
+
return [".ts", ".tsx"].includes(import_path3.default.extname(this.tinaConfigFilePath));
|
|
806
816
|
}
|
|
807
817
|
hasSelfHostedConfig() {
|
|
808
818
|
return !!this.selfHostedDatabaseFilePath;
|
|
@@ -811,20 +821,19 @@ var ConfigManager = class {
|
|
|
811
821
|
return this.rootPath !== this.contentRootPath;
|
|
812
822
|
}
|
|
813
823
|
shouldSkipSDK() {
|
|
814
|
-
var _a;
|
|
815
824
|
if (this.legacyNoSDK) {
|
|
816
825
|
return this.legacyNoSDK;
|
|
817
826
|
}
|
|
818
|
-
return
|
|
827
|
+
return this.config.client?.skip || false;
|
|
819
828
|
}
|
|
820
829
|
async processConfig() {
|
|
821
830
|
this.tinaFolderPath = await this.getTinaFolderPath(this.rootPath);
|
|
822
|
-
this.envFilePath =
|
|
823
|
-
|
|
831
|
+
this.envFilePath = import_path3.default.resolve(
|
|
832
|
+
import_path3.default.join(this.tinaFolderPath, "..", ".env")
|
|
824
833
|
);
|
|
825
834
|
dotenv.config({ path: this.envFilePath });
|
|
826
835
|
this.tinaConfigFilePath = await this.getPathWithExtension(
|
|
827
|
-
|
|
836
|
+
import_path3.default.join(this.tinaFolderPath, "config")
|
|
828
837
|
);
|
|
829
838
|
if (!this.tinaConfigFilePath) {
|
|
830
839
|
throw new Error(
|
|
@@ -832,79 +841,79 @@ var ConfigManager = class {
|
|
|
832
841
|
);
|
|
833
842
|
}
|
|
834
843
|
this.selfHostedDatabaseFilePath = await this.getPathWithExtension(
|
|
835
|
-
|
|
844
|
+
import_path3.default.join(this.tinaFolderPath, "database")
|
|
836
845
|
);
|
|
837
|
-
this.generatedFolderPath =
|
|
838
|
-
this.generatedCachePath =
|
|
846
|
+
this.generatedFolderPath = import_path3.default.join(this.tinaFolderPath, GENERATED_FOLDER);
|
|
847
|
+
this.generatedCachePath = import_path3.default.join(
|
|
839
848
|
this.generatedFolderPath,
|
|
840
849
|
".cache",
|
|
841
850
|
String((/* @__PURE__ */ new Date()).getTime())
|
|
842
851
|
);
|
|
843
|
-
this.generatedGraphQLGQLPath =
|
|
852
|
+
this.generatedGraphQLGQLPath = import_path3.default.join(
|
|
844
853
|
this.generatedFolderPath,
|
|
845
854
|
GRAPHQL_GQL_FILE
|
|
846
855
|
);
|
|
847
|
-
this.generatedGraphQLJSONPath =
|
|
856
|
+
this.generatedGraphQLJSONPath = import_path3.default.join(
|
|
848
857
|
this.generatedFolderPath,
|
|
849
858
|
GRAPHQL_JSON_FILE
|
|
850
859
|
);
|
|
851
|
-
this.generatedSchemaJSONPath =
|
|
860
|
+
this.generatedSchemaJSONPath = import_path3.default.join(
|
|
852
861
|
this.generatedFolderPath,
|
|
853
862
|
SCHEMA_JSON_FILE
|
|
854
863
|
);
|
|
855
|
-
this.generatedLookupJSONPath =
|
|
864
|
+
this.generatedLookupJSONPath = import_path3.default.join(
|
|
856
865
|
this.generatedFolderPath,
|
|
857
866
|
LOOKUP_JSON_FILE
|
|
858
867
|
);
|
|
859
|
-
this.generatedQueriesFilePath =
|
|
868
|
+
this.generatedQueriesFilePath = import_path3.default.join(
|
|
860
869
|
this.generatedFolderPath,
|
|
861
870
|
"queries.gql"
|
|
862
871
|
);
|
|
863
|
-
this.generatedFragmentsFilePath =
|
|
872
|
+
this.generatedFragmentsFilePath = import_path3.default.join(
|
|
864
873
|
this.generatedFolderPath,
|
|
865
874
|
"frags.gql"
|
|
866
875
|
);
|
|
867
|
-
this.generatedTypesTSFilePath =
|
|
876
|
+
this.generatedTypesTSFilePath = import_path3.default.join(
|
|
868
877
|
this.generatedFolderPath,
|
|
869
878
|
"types.ts"
|
|
870
879
|
);
|
|
871
|
-
this.generatedTypesJSFilePath =
|
|
880
|
+
this.generatedTypesJSFilePath = import_path3.default.join(
|
|
872
881
|
this.generatedFolderPath,
|
|
873
882
|
"types.js"
|
|
874
883
|
);
|
|
875
|
-
this.generatedTypesDFilePath =
|
|
884
|
+
this.generatedTypesDFilePath = import_path3.default.join(
|
|
876
885
|
this.generatedFolderPath,
|
|
877
886
|
"types.d.ts"
|
|
878
887
|
);
|
|
879
|
-
this.userQueriesAndFragmentsGlob =
|
|
888
|
+
this.userQueriesAndFragmentsGlob = import_path3.default.join(
|
|
880
889
|
this.tinaFolderPath,
|
|
881
890
|
"queries/**/*.{graphql,gql}"
|
|
882
891
|
);
|
|
883
|
-
this.generatedQueriesAndFragmentsGlob =
|
|
892
|
+
this.generatedQueriesAndFragmentsGlob = import_path3.default.join(
|
|
884
893
|
this.generatedFolderPath,
|
|
885
894
|
"*.{graphql,gql}"
|
|
886
895
|
);
|
|
887
|
-
this.generatedClientTSFilePath =
|
|
896
|
+
this.generatedClientTSFilePath = import_path3.default.join(
|
|
888
897
|
this.generatedFolderPath,
|
|
889
898
|
"client.ts"
|
|
890
899
|
);
|
|
891
|
-
this.generatedClientJSFilePath =
|
|
900
|
+
this.generatedClientJSFilePath = import_path3.default.join(
|
|
892
901
|
this.generatedFolderPath,
|
|
893
902
|
"client.js"
|
|
894
903
|
);
|
|
895
|
-
this.generatedClientDFilePath =
|
|
904
|
+
this.generatedClientDFilePath = import_path3.default.join(
|
|
896
905
|
this.generatedFolderPath,
|
|
897
906
|
"client.d.ts"
|
|
898
907
|
);
|
|
899
|
-
this.generatedDatabaseClientDFilePath =
|
|
908
|
+
this.generatedDatabaseClientDFilePath = import_path3.default.join(
|
|
900
909
|
this.generatedFolderPath,
|
|
901
910
|
"databaseClient.d.ts"
|
|
902
911
|
);
|
|
903
|
-
this.generatedDatabaseClientTSFilePath =
|
|
912
|
+
this.generatedDatabaseClientTSFilePath = import_path3.default.join(
|
|
904
913
|
this.generatedFolderPath,
|
|
905
914
|
"databaseClient.ts"
|
|
906
915
|
);
|
|
907
|
-
this.generatedDatabaseClientJSFilePath =
|
|
916
|
+
this.generatedDatabaseClientJSFilePath = import_path3.default.join(
|
|
908
917
|
this.generatedFolderPath,
|
|
909
918
|
"databaseClient.js"
|
|
910
919
|
);
|
|
@@ -924,19 +933,18 @@ var ConfigManager = class {
|
|
|
924
933
|
this.watchList = watchList;
|
|
925
934
|
this.config = config2;
|
|
926
935
|
this.prebuildFilePath = prebuildPath;
|
|
927
|
-
this.publicFolderPath =
|
|
936
|
+
this.publicFolderPath = import_path3.default.join(
|
|
928
937
|
this.rootPath,
|
|
929
938
|
this.config.build.publicFolder
|
|
930
939
|
);
|
|
931
|
-
this.outputFolderPath =
|
|
940
|
+
this.outputFolderPath = import_path3.default.join(
|
|
932
941
|
this.publicFolderPath,
|
|
933
942
|
this.config.build.outputFolder
|
|
934
943
|
);
|
|
935
|
-
this.outputHTMLFilePath =
|
|
936
|
-
this.outputGitignorePath =
|
|
937
|
-
const fullLocalContentPath =
|
|
938
|
-
this.tinaFolderPath,
|
|
939
|
-
this.config.localContentPath || ""
|
|
944
|
+
this.outputHTMLFilePath = import_path3.default.join(this.outputFolderPath, "index.html");
|
|
945
|
+
this.outputGitignorePath = import_path3.default.join(this.outputFolderPath, ".gitignore");
|
|
946
|
+
const fullLocalContentPath = stripNativeTrailingSlash(
|
|
947
|
+
import_path3.default.join(this.tinaFolderPath, this.config.localContentPath || "")
|
|
940
948
|
);
|
|
941
949
|
if (this.config.localContentPath) {
|
|
942
950
|
const localContentPathExists = await import_fs_extra2.default.pathExists(fullLocalContentPath);
|
|
@@ -956,21 +964,21 @@ var ConfigManager = class {
|
|
|
956
964
|
if (!this.contentRootPath) {
|
|
957
965
|
this.contentRootPath = this.rootPath;
|
|
958
966
|
}
|
|
959
|
-
this.generatedFolderPathContentRepo =
|
|
967
|
+
this.generatedFolderPathContentRepo = import_path3.default.join(
|
|
960
968
|
await this.getTinaFolderPath(this.contentRootPath),
|
|
961
969
|
GENERATED_FOLDER
|
|
962
970
|
);
|
|
963
971
|
this.spaMainPath = require.resolve("@tinacms/app");
|
|
964
|
-
this.spaRootPath =
|
|
972
|
+
this.spaRootPath = import_path3.default.join(this.spaMainPath, "..", "..");
|
|
965
973
|
}
|
|
966
974
|
async getTinaFolderPath(rootPath) {
|
|
967
|
-
const tinaFolderPath =
|
|
975
|
+
const tinaFolderPath = import_path3.default.join(rootPath, TINA_FOLDER);
|
|
968
976
|
const tinaFolderExists = await import_fs_extra2.default.pathExists(tinaFolderPath);
|
|
969
977
|
if (tinaFolderExists) {
|
|
970
978
|
this.isUsingLegacyFolder = false;
|
|
971
979
|
return tinaFolderPath;
|
|
972
980
|
}
|
|
973
|
-
const legacyFolderPath =
|
|
981
|
+
const legacyFolderPath = import_path3.default.join(rootPath, LEGACY_TINA_FOLDER);
|
|
974
982
|
const legacyFolderExists = await import_fs_extra2.default.pathExists(legacyFolderPath);
|
|
975
983
|
if (legacyFolderExists) {
|
|
976
984
|
this.isUsingLegacyFolder = true;
|
|
@@ -991,7 +999,7 @@ var ConfigManager = class {
|
|
|
991
999
|
};
|
|
992
1000
|
}
|
|
993
1001
|
const generatedSchema = import_fs_extra2.default.readJSONSync(this.generatedSchemaJSONPath);
|
|
994
|
-
if (!generatedSchema || !(typeof
|
|
1002
|
+
if (!generatedSchema || !(typeof generatedSchema?.version !== "undefined")) {
|
|
995
1003
|
throw new Error(
|
|
996
1004
|
`Can not find Tina GraphQL version in ${this.generatedSchemaJSONPath}`
|
|
997
1005
|
);
|
|
@@ -1046,8 +1054,8 @@ var ConfigManager = class {
|
|
|
1046
1054
|
return result;
|
|
1047
1055
|
}
|
|
1048
1056
|
async loadDatabaseFile() {
|
|
1049
|
-
const tmpdir =
|
|
1050
|
-
const outfile =
|
|
1057
|
+
const tmpdir = import_path3.default.join(import_os.default.tmpdir(), Date.now().toString());
|
|
1058
|
+
const outfile = import_path3.default.join(tmpdir, "database.build.js");
|
|
1051
1059
|
await esbuild.build({
|
|
1052
1060
|
entryPoints: [this.selfHostedDatabaseFilePath],
|
|
1053
1061
|
bundle: true,
|
|
@@ -1060,14 +1068,14 @@ var ConfigManager = class {
|
|
|
1060
1068
|
return result.default;
|
|
1061
1069
|
}
|
|
1062
1070
|
async loadConfigFile(generatedFolderPath, configFilePath) {
|
|
1063
|
-
const tmpdir =
|
|
1064
|
-
const preBuildConfigPath =
|
|
1071
|
+
const tmpdir = import_path3.default.join(import_os.default.tmpdir(), Date.now().toString());
|
|
1072
|
+
const preBuildConfigPath = import_path3.default.join(
|
|
1065
1073
|
this.generatedFolderPath,
|
|
1066
1074
|
"config.prebuild.jsx"
|
|
1067
1075
|
);
|
|
1068
|
-
const outfile =
|
|
1069
|
-
const outfile2 =
|
|
1070
|
-
const tempTSConfigFile =
|
|
1076
|
+
const outfile = import_path3.default.join(tmpdir, "config.build.jsx");
|
|
1077
|
+
const outfile2 = import_path3.default.join(tmpdir, "config.build.js");
|
|
1078
|
+
const tempTSConfigFile = import_path3.default.join(tmpdir, "tsconfig.json");
|
|
1071
1079
|
import_fs_extra2.default.outputFileSync(tempTSConfigFile, "{}");
|
|
1072
1080
|
const result2 = await esbuild.build({
|
|
1073
1081
|
entryPoints: [configFilePath],
|
|
@@ -1168,7 +1176,7 @@ var createDBServer = (port) => {
|
|
|
1168
1176
|
});
|
|
1169
1177
|
});
|
|
1170
1178
|
dbServer.once("error", (err) => {
|
|
1171
|
-
if (
|
|
1179
|
+
if (err?.code === "EADDRINUSE") {
|
|
1172
1180
|
throw new Error(
|
|
1173
1181
|
`Tina Dev server is already in use. Datalayer server is busy on port ${port}`
|
|
1174
1182
|
);
|
|
@@ -1319,7 +1327,6 @@ var BaseCommand = class extends import_clipanion.Command {
|
|
|
1319
1327
|
const warnings = [];
|
|
1320
1328
|
await spin({
|
|
1321
1329
|
waitFor: async () => {
|
|
1322
|
-
var _a, _b;
|
|
1323
1330
|
const rootPath = configManager.rootPath;
|
|
1324
1331
|
let sha;
|
|
1325
1332
|
try {
|
|
@@ -1344,7 +1351,7 @@ var BaseCommand = class extends import_clipanion.Command {
|
|
|
1344
1351
|
}
|
|
1345
1352
|
for (const collection of tinaSchema.getCollections()) {
|
|
1346
1353
|
pathFilter[collection.path] = {
|
|
1347
|
-
matches:
|
|
1354
|
+
matches: collection.match?.exclude || collection.match?.include ? tinaSchema.getMatches({ collection }) : void 0
|
|
1348
1355
|
};
|
|
1349
1356
|
}
|
|
1350
1357
|
const { added, modified, deleted } = await (0, import_graphql8.getChangedFiles)({
|
|
@@ -1355,7 +1362,7 @@ var BaseCommand = class extends import_clipanion.Command {
|
|
|
1355
1362
|
pathFilter
|
|
1356
1363
|
});
|
|
1357
1364
|
const tinaPathUpdates = modified.filter(
|
|
1358
|
-
(
|
|
1365
|
+
(path15) => path15.startsWith(".tina/__generated__/_schema.json") || path15.startsWith("tina/tina-lock.json")
|
|
1359
1366
|
);
|
|
1360
1367
|
if (tinaPathUpdates.length > 0) {
|
|
1361
1368
|
res = await database.indexContent({
|
|
@@ -1379,7 +1386,7 @@ var BaseCommand = class extends import_clipanion.Command {
|
|
|
1379
1386
|
if (sha) {
|
|
1380
1387
|
await database.setMetadata("lastSha", sha);
|
|
1381
1388
|
}
|
|
1382
|
-
if (res
|
|
1389
|
+
if (res?.warnings) {
|
|
1383
1390
|
warnings.push(...res.warnings);
|
|
1384
1391
|
}
|
|
1385
1392
|
},
|
|
@@ -1433,7 +1440,7 @@ var errorHTML = `<style type="text/css">
|
|
|
1433
1440
|
the assets for this page.
|
|
1434
1441
|
</p>
|
|
1435
1442
|
<p>
|
|
1436
|
-
Please visit <a href="https://tina.io/docs/
|
|
1443
|
+
Please visit <a href="https://tina.io/docs/r/FAQ/#13-how-do-i-resolve-failed-loading-tinacms-assets-error">this doc</a> for help.
|
|
1437
1444
|
</p>
|
|
1438
1445
|
</div>
|
|
1439
1446
|
</div>`.trim().replace(/[\r\n\s]+/g, " ");
|
|
@@ -1474,14 +1481,14 @@ var devHTML = (port) => `<!DOCTYPE html>
|
|
|
1474
1481
|
var import_vite3 = require("vite");
|
|
1475
1482
|
|
|
1476
1483
|
// src/next/vite/index.ts
|
|
1477
|
-
var import_node_path2 = __toESM(require("path"));
|
|
1484
|
+
var import_node_path2 = __toESM(require("node:path"));
|
|
1478
1485
|
var import_plugin_react = __toESM(require("@vitejs/plugin-react"));
|
|
1479
1486
|
var import_fs_extra4 = __toESM(require("fs-extra"));
|
|
1480
1487
|
var import_normalize_path3 = __toESM(require("normalize-path"));
|
|
1481
1488
|
var import_vite = require("vite");
|
|
1482
1489
|
|
|
1483
1490
|
// src/next/vite/tailwind.ts
|
|
1484
|
-
var import_node_path = __toESM(require("path"));
|
|
1491
|
+
var import_node_path = __toESM(require("node:path"));
|
|
1485
1492
|
var import_aspect_ratio = __toESM(require("@tailwindcss/aspect-ratio"));
|
|
1486
1493
|
var import_container_queries = __toESM(require("@tailwindcss/container-queries"));
|
|
1487
1494
|
var import_typography = __toESM(require("@tailwindcss/typography"));
|
|
@@ -1686,6 +1693,7 @@ var tinaTailwind = (spaPath, prebuildFilePath) => {
|
|
|
1686
1693
|
500: "#EC4815",
|
|
1687
1694
|
600: "#DC4419"
|
|
1688
1695
|
},
|
|
1696
|
+
"tina-orange": "#EC4815",
|
|
1689
1697
|
background: "#FFFFFF",
|
|
1690
1698
|
foreground: "#0A0A0A",
|
|
1691
1699
|
muted: "#F5F5F5",
|
|
@@ -1807,7 +1815,6 @@ var createConfig = async ({
|
|
|
1807
1815
|
noWatch,
|
|
1808
1816
|
rollupOptions
|
|
1809
1817
|
}) => {
|
|
1810
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
1811
1818
|
const publicEnv = {};
|
|
1812
1819
|
Object.keys(process.env).forEach((key) => {
|
|
1813
1820
|
if (key.startsWith("TINA_PUBLIC_") || key.startsWith("NEXT_PUBLIC_") || key === "NODE_ENV" || key === "HEAD") {
|
|
@@ -1829,9 +1836,9 @@ var createConfig = async ({
|
|
|
1829
1836
|
configManager.generatedFolderPath,
|
|
1830
1837
|
"static-media.json"
|
|
1831
1838
|
);
|
|
1832
|
-
if (
|
|
1839
|
+
if (configManager.config.media?.tina?.static) {
|
|
1833
1840
|
const staticMedia = await listFilesRecursively({
|
|
1834
|
-
directoryPath:
|
|
1841
|
+
directoryPath: configManager.config.media.tina?.mediaRoot || "",
|
|
1835
1842
|
config: configManager.config.media.tina,
|
|
1836
1843
|
roothPath: configManager.rootPath
|
|
1837
1844
|
});
|
|
@@ -1892,7 +1899,7 @@ var createConfig = async ({
|
|
|
1892
1899
|
// Used by picomatch https://github.com/micromatch/picomatch/blob/master/lib/utils.js#L4
|
|
1893
1900
|
"process.platform": `"${process.platform}"`,
|
|
1894
1901
|
__API_URL__: `"${apiURL}"`,
|
|
1895
|
-
__BASE_PATH__: `"${
|
|
1902
|
+
__BASE_PATH__: `"${configManager.config?.build?.basePath || ""}"`,
|
|
1896
1903
|
__TINA_GRAPHQL_VERSION__: version2
|
|
1897
1904
|
},
|
|
1898
1905
|
logLevel: "error",
|
|
@@ -1904,7 +1911,7 @@ var createConfig = async ({
|
|
|
1904
1911
|
include: ["react/jsx-runtime", "react/jsx-dev-runtime"]
|
|
1905
1912
|
},
|
|
1906
1913
|
server: {
|
|
1907
|
-
host:
|
|
1914
|
+
host: configManager.config?.build?.host ?? false,
|
|
1908
1915
|
watch: noWatch ? {
|
|
1909
1916
|
ignored: ["**/*"]
|
|
1910
1917
|
} : {
|
|
@@ -1932,7 +1939,8 @@ var createConfig = async ({
|
|
|
1932
1939
|
babel: {
|
|
1933
1940
|
// Supresses the warning [NOTE] babel The code generator has deoptimised the styling of
|
|
1934
1941
|
compact: true
|
|
1935
|
-
}
|
|
1942
|
+
},
|
|
1943
|
+
fastRefresh: false
|
|
1936
1944
|
}),
|
|
1937
1945
|
(0, import_vite.splitVendorChunkPlugin)(),
|
|
1938
1946
|
tinaTailwind(configManager.spaRootPath, configManager.prebuildFilePath),
|
|
@@ -1947,17 +1955,17 @@ var import_pluginutils = require("@rollup/pluginutils");
|
|
|
1947
1955
|
var import_fs = __toESM(require("fs"));
|
|
1948
1956
|
var import_vite2 = require("vite");
|
|
1949
1957
|
var import_esbuild2 = require("esbuild");
|
|
1950
|
-
var
|
|
1958
|
+
var import_path6 = __toESM(require("path"));
|
|
1951
1959
|
var import_body_parser = __toESM(require("body-parser"));
|
|
1952
1960
|
var import_cors = __toESM(require("cors"));
|
|
1953
1961
|
var import_graphql9 = require("@tinacms/graphql");
|
|
1954
1962
|
|
|
1955
1963
|
// src/next/commands/dev-command/server/media.ts
|
|
1956
1964
|
var import_fs_extra5 = __toESM(require("fs-extra"));
|
|
1957
|
-
var
|
|
1965
|
+
var import_path5 = __toESM(require("path"));
|
|
1958
1966
|
var import_busboy = __toESM(require("busboy"));
|
|
1959
1967
|
var createMediaRouter = (config2) => {
|
|
1960
|
-
const mediaFolder =
|
|
1968
|
+
const mediaFolder = import_path5.default.join(
|
|
1961
1969
|
config2.rootPath,
|
|
1962
1970
|
config2.publicFolder,
|
|
1963
1971
|
config2.mediaRoot
|
|
@@ -1983,10 +1991,9 @@ var createMediaRouter = (config2) => {
|
|
|
1983
1991
|
const handlePost = async function(req, res) {
|
|
1984
1992
|
const bb = (0, import_busboy.default)({ headers: req.headers });
|
|
1985
1993
|
bb.on("file", async (_name, file, _info) => {
|
|
1986
|
-
|
|
1987
|
-
const
|
|
1988
|
-
|
|
1989
|
-
await import_fs_extra5.default.ensureDir(import_path3.default.dirname(saveTo));
|
|
1994
|
+
const fullPath = decodeURI(req.url?.slice("/media/upload/".length));
|
|
1995
|
+
const saveTo = import_path5.default.join(mediaFolder, ...fullPath.split("/"));
|
|
1996
|
+
await import_fs_extra5.default.ensureDir(import_path5.default.dirname(saveTo));
|
|
1990
1997
|
file.pipe(import_fs_extra5.default.createWriteStream(saveTo));
|
|
1991
1998
|
});
|
|
1992
1999
|
bb.on("error", (error) => {
|
|
@@ -2020,7 +2027,7 @@ var MediaModel = class {
|
|
|
2020
2027
|
}
|
|
2021
2028
|
async listMedia(args) {
|
|
2022
2029
|
try {
|
|
2023
|
-
const folderPath = (0,
|
|
2030
|
+
const folderPath = (0, import_path5.join)(
|
|
2024
2031
|
this.rootPath,
|
|
2025
2032
|
this.publicFolder,
|
|
2026
2033
|
this.mediaRoot,
|
|
@@ -2035,7 +2042,7 @@ var MediaModel = class {
|
|
|
2035
2042
|
}
|
|
2036
2043
|
const filesStr = await import_fs_extra5.default.readdir(folderPath);
|
|
2037
2044
|
const filesProm = filesStr.map(async (file) => {
|
|
2038
|
-
const filePath = (0,
|
|
2045
|
+
const filePath = (0, import_path5.join)(folderPath, file);
|
|
2039
2046
|
const stat = await import_fs_extra5.default.stat(filePath);
|
|
2040
2047
|
let src = `/${file}`;
|
|
2041
2048
|
const isFile = stat.isFile();
|
|
@@ -2086,13 +2093,13 @@ var MediaModel = class {
|
|
|
2086
2093
|
return {
|
|
2087
2094
|
files: [],
|
|
2088
2095
|
directories: [],
|
|
2089
|
-
error: error
|
|
2096
|
+
error: error?.toString()
|
|
2090
2097
|
};
|
|
2091
2098
|
}
|
|
2092
2099
|
}
|
|
2093
2100
|
async deleteMedia(args) {
|
|
2094
2101
|
try {
|
|
2095
|
-
const file = (0,
|
|
2102
|
+
const file = (0, import_path5.join)(
|
|
2096
2103
|
this.rootPath,
|
|
2097
2104
|
this.publicFolder,
|
|
2098
2105
|
this.mediaRoot,
|
|
@@ -2103,7 +2110,7 @@ var MediaModel = class {
|
|
|
2103
2110
|
return { ok: true };
|
|
2104
2111
|
} catch (error) {
|
|
2105
2112
|
console.error(error);
|
|
2106
|
-
return { ok: false, message: error
|
|
2113
|
+
return { ok: false, message: error?.toString() };
|
|
2107
2114
|
}
|
|
2108
2115
|
}
|
|
2109
2116
|
};
|
|
@@ -2157,7 +2164,7 @@ var transformTsxPlugin = ({
|
|
|
2157
2164
|
const plug = {
|
|
2158
2165
|
name: "transform-tsx",
|
|
2159
2166
|
async transform(code, id) {
|
|
2160
|
-
const extName =
|
|
2167
|
+
const extName = import_path6.default.extname(id);
|
|
2161
2168
|
if (extName.startsWith(".tsx") || extName.startsWith(".ts")) {
|
|
2162
2169
|
const result = await (0, import_esbuild2.transform)(code, { loader: "tsx" });
|
|
2163
2170
|
return {
|
|
@@ -2181,13 +2188,12 @@ var devServerEndPointsPlugin = ({
|
|
|
2181
2188
|
server.middlewares.use((0, import_cors.default)());
|
|
2182
2189
|
server.middlewares.use(import_body_parser.default.json({ limit: "5mb" }));
|
|
2183
2190
|
server.middlewares.use(async (req, res, next) => {
|
|
2184
|
-
|
|
2185
|
-
const mediaPaths = (_a = configManager.config.media) == null ? void 0 : _a.tina;
|
|
2191
|
+
const mediaPaths = configManager.config.media?.tina;
|
|
2186
2192
|
const mediaRouter = createMediaRouter({
|
|
2187
2193
|
rootPath: configManager.rootPath,
|
|
2188
2194
|
apiURL,
|
|
2189
|
-
publicFolder: parseMediaFolder(
|
|
2190
|
-
mediaRoot: parseMediaFolder(
|
|
2195
|
+
publicFolder: parseMediaFolder(mediaPaths?.publicFolder || ""),
|
|
2196
|
+
mediaRoot: parseMediaFolder(mediaPaths?.mediaRoot || "")
|
|
2191
2197
|
});
|
|
2192
2198
|
const searchIndexRouter = createSearchIndexRouter({
|
|
2193
2199
|
config: { apiURL, searchPath: "searchIndex" },
|
|
@@ -2260,7 +2266,7 @@ function viteTransformExtension({
|
|
|
2260
2266
|
name: "vite-plugin-svgr",
|
|
2261
2267
|
async transform(code, id) {
|
|
2262
2268
|
if (filter(id)) {
|
|
2263
|
-
const { transform: transform2 } = await
|
|
2269
|
+
const { transform: transform2 } = await import("@svgr/core");
|
|
2264
2270
|
const svgCode = await import_fs.default.promises.readFile(
|
|
2265
2271
|
id.replace(/\?.*$/, ""),
|
|
2266
2272
|
"utf8"
|
|
@@ -2345,6 +2351,20 @@ var DevCommand = class extends BaseCommand {
|
|
|
2345
2351
|
});
|
|
2346
2352
|
this.indexingLock = new import_async_lock.default();
|
|
2347
2353
|
}
|
|
2354
|
+
static {
|
|
2355
|
+
this.paths = [["dev"], ["server:start"]];
|
|
2356
|
+
}
|
|
2357
|
+
static {
|
|
2358
|
+
// Prevent indexes and reads occurring at once
|
|
2359
|
+
this.usage = import_clipanion2.Command.Usage({
|
|
2360
|
+
category: `Commands`,
|
|
2361
|
+
description: `Builds Tina and starts the dev server`,
|
|
2362
|
+
examples: [
|
|
2363
|
+
[`A basic example`, `$0 dev`],
|
|
2364
|
+
[`A second example`, `$0 dev --rootPath`]
|
|
2365
|
+
]
|
|
2366
|
+
});
|
|
2367
|
+
}
|
|
2348
2368
|
async catch(error) {
|
|
2349
2369
|
logger.error("Error occured during tinacms dev");
|
|
2350
2370
|
console.error(error);
|
|
@@ -2359,7 +2379,6 @@ var DevCommand = class extends BaseCommand {
|
|
|
2359
2379
|
}
|
|
2360
2380
|
}
|
|
2361
2381
|
async execute() {
|
|
2362
|
-
var _a, _b, _c, _d, _e, _f;
|
|
2363
2382
|
const configManager = new ConfigManager({
|
|
2364
2383
|
rootPath: this.rootPath,
|
|
2365
2384
|
legacyNoSDK: this.noSDK
|
|
@@ -2409,14 +2428,14 @@ var DevCommand = class extends BaseCommand {
|
|
|
2409
2428
|
graphql: graphqlSchemaObject
|
|
2410
2429
|
});
|
|
2411
2430
|
import_fs_extra6.default.writeFileSync(
|
|
2412
|
-
|
|
2431
|
+
import_path7.default.join(configManager.tinaFolderPath, tinaLockFilename),
|
|
2413
2432
|
tinaLockContent
|
|
2414
2433
|
);
|
|
2415
2434
|
if (configManager.hasSeparateContentRoot()) {
|
|
2416
2435
|
const rootPath = await configManager.getTinaFolderPath(
|
|
2417
2436
|
configManager.contentRootPath
|
|
2418
2437
|
);
|
|
2419
|
-
const filePath =
|
|
2438
|
+
const filePath = import_path7.default.join(rootPath, tinaLockFilename);
|
|
2420
2439
|
await import_fs_extra6.default.ensureFile(filePath);
|
|
2421
2440
|
await import_fs_extra6.default.outputFile(filePath, tinaLockContent);
|
|
2422
2441
|
}
|
|
@@ -2467,19 +2486,19 @@ ${dangerText(e.message)}
|
|
|
2467
2486
|
"index.html\nassets/"
|
|
2468
2487
|
);
|
|
2469
2488
|
const searchIndexClient = new import_search.LocalSearchIndexClient({
|
|
2470
|
-
stopwordLanguages:
|
|
2471
|
-
tokenSplitRegex:
|
|
2489
|
+
stopwordLanguages: configManager.config.search?.tina?.stopwordLanguages,
|
|
2490
|
+
tokenSplitRegex: configManager.config.search?.tina?.tokenSplitRegex
|
|
2472
2491
|
});
|
|
2473
2492
|
await searchIndexClient.onStartIndexing();
|
|
2474
2493
|
const searchIndexer = new import_search.SearchIndexer({
|
|
2475
|
-
batchSize:
|
|
2494
|
+
batchSize: configManager.config.search?.indexBatchSize || 100,
|
|
2476
2495
|
bridge: new import_graphql10.FilesystemBridge(
|
|
2477
2496
|
configManager.rootPath,
|
|
2478
2497
|
configManager.contentRootPath
|
|
2479
2498
|
),
|
|
2480
2499
|
schema: tinaSchema,
|
|
2481
2500
|
client: searchIndexClient,
|
|
2482
|
-
textIndexLength:
|
|
2501
|
+
textIndexLength: configManager.config.search?.maxSearchIndexFieldLength || 100
|
|
2483
2502
|
});
|
|
2484
2503
|
if (configManager.config.search) {
|
|
2485
2504
|
await spin({
|
|
@@ -2576,11 +2595,11 @@ ${dangerText(e.message)}
|
|
|
2576
2595
|
// subItems: [
|
|
2577
2596
|
// {
|
|
2578
2597
|
// key: 'Custom queries',
|
|
2579
|
-
// value: 'https://tina.io/
|
|
2598
|
+
// value: 'https://tina.io/docs/r/content-api-overview',
|
|
2580
2599
|
// },
|
|
2581
2600
|
// {
|
|
2582
2601
|
// key: 'Visual editing',
|
|
2583
|
-
// value: 'https://tina.io/visual-editing',
|
|
2602
|
+
// value: 'https://tina.io/docs/r/visual-editing-setup',
|
|
2584
2603
|
// },
|
|
2585
2604
|
// ],
|
|
2586
2605
|
// },
|
|
@@ -2591,7 +2610,7 @@ ${dangerText(e.message)}
|
|
|
2591
2610
|
watchContentFiles(configManager, database, databaseLock, searchIndexer) {
|
|
2592
2611
|
const collectionContentFiles = [];
|
|
2593
2612
|
configManager.config.schema.collections.forEach((collection) => {
|
|
2594
|
-
const collectionGlob = `${
|
|
2613
|
+
const collectionGlob = `${import_path7.default.join(
|
|
2595
2614
|
configManager.contentRootPath,
|
|
2596
2615
|
collection.path
|
|
2597
2616
|
)}/**/*.${collection.format || "md"}`;
|
|
@@ -2638,20 +2657,10 @@ ${dangerText(e.message)}
|
|
|
2638
2657
|
import_chokidar.default.watch(configManager.userQueriesAndFragmentsGlob).on("add", executeCallback).on("change", executeCallback).on("unlink", executeCallback);
|
|
2639
2658
|
}
|
|
2640
2659
|
};
|
|
2641
|
-
DevCommand.paths = [["dev"], ["server:start"]];
|
|
2642
|
-
// Prevent indexes and reads occurring at once
|
|
2643
|
-
DevCommand.usage = import_clipanion2.Command.Usage({
|
|
2644
|
-
category: `Commands`,
|
|
2645
|
-
description: `Builds Tina and starts the dev server`,
|
|
2646
|
-
examples: [
|
|
2647
|
-
[`A basic example`, `$0 dev`],
|
|
2648
|
-
[`A second example`, `$0 dev --rootPath`]
|
|
2649
|
-
]
|
|
2650
|
-
});
|
|
2651
2660
|
|
|
2652
2661
|
// src/next/commands/build-command/index.ts
|
|
2653
2662
|
var import_crypto = __toESM(require("crypto"));
|
|
2654
|
-
var
|
|
2663
|
+
var import_path8 = __toESM(require("path"));
|
|
2655
2664
|
var import_core3 = require("@graphql-inspector/core");
|
|
2656
2665
|
var import_graphql11 = require("@tinacms/graphql");
|
|
2657
2666
|
var import_schema_tools2 = require("@tinacms/schema-tools");
|
|
@@ -2666,7 +2675,7 @@ var import_core2 = require("@graphql-inspector/core");
|
|
|
2666
2675
|
var getFaqLink = (type) => {
|
|
2667
2676
|
switch (type) {
|
|
2668
2677
|
case import_core2.ChangeType.FieldRemoved: {
|
|
2669
|
-
return "https://tina.io/docs/
|
|
2678
|
+
return "https://tina.io/docs/r/FAQ/#2-how-do-i-resolve-the-local-graphql-schema-doesnt-match-the-remote-graphql-schema-error";
|
|
2670
2679
|
}
|
|
2671
2680
|
default:
|
|
2672
2681
|
return null;
|
|
@@ -2845,12 +2854,20 @@ var BuildCommand = class extends BaseCommand {
|
|
|
2845
2854
|
description: "Disables the client build cache"
|
|
2846
2855
|
});
|
|
2847
2856
|
}
|
|
2857
|
+
static {
|
|
2858
|
+
this.paths = [["build"]];
|
|
2859
|
+
}
|
|
2860
|
+
static {
|
|
2861
|
+
this.usage = import_clipanion3.Command.Usage({
|
|
2862
|
+
category: `Commands`,
|
|
2863
|
+
description: `Build the CMS and autogenerated modules for usage with TinaCloud`
|
|
2864
|
+
});
|
|
2865
|
+
}
|
|
2848
2866
|
async catch(error) {
|
|
2849
2867
|
console.error(error);
|
|
2850
2868
|
process.exit(1);
|
|
2851
2869
|
}
|
|
2852
2870
|
async execute() {
|
|
2853
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s;
|
|
2854
2871
|
logger.info("Starting Tina build");
|
|
2855
2872
|
this.logDeprecationWarnings();
|
|
2856
2873
|
const configManager = new ConfigManager({
|
|
@@ -2939,45 +2956,63 @@ ${dangerText(e.message)}
|
|
|
2939
2956
|
}
|
|
2940
2957
|
const skipCloudChecks = this.skipCloudChecks || configManager.hasSelfHostedConfig();
|
|
2941
2958
|
if (!skipCloudChecks) {
|
|
2942
|
-
|
|
2943
|
-
|
|
2944
|
-
|
|
2945
|
-
|
|
2946
|
-
|
|
2947
|
-
if (!hasUpstream && this.upstreamBranch) {
|
|
2948
|
-
logger.warn(
|
|
2949
|
-
`${dangerText(
|
|
2950
|
-
`WARN: Upstream branch '${this.upstreamBranch}' specified but no upstream project was found.`
|
|
2951
|
-
)}`
|
|
2959
|
+
try {
|
|
2960
|
+
const clientInfo = await this.checkClientInfo(
|
|
2961
|
+
configManager,
|
|
2962
|
+
codegen2.productionUrl,
|
|
2963
|
+
this.previewBaseBranch
|
|
2952
2964
|
);
|
|
2965
|
+
if (clientInfo.detectedBotBranch) {
|
|
2966
|
+
logger.warn(
|
|
2967
|
+
`${warnText(
|
|
2968
|
+
`WARN: Detected bot branch. Using schema/content from default branch '${clientInfo.defaultBranch}' instead of '${configManager.config.branch}'.`
|
|
2969
|
+
)}`
|
|
2970
|
+
);
|
|
2971
|
+
}
|
|
2972
|
+
if (!clientInfo.hasUpstream && this.upstreamBranch) {
|
|
2973
|
+
logger.warn(
|
|
2974
|
+
`${dangerText(
|
|
2975
|
+
`WARN: Upstream branch '${this.upstreamBranch}' specified but no upstream project was found.`
|
|
2976
|
+
)}`
|
|
2977
|
+
);
|
|
2978
|
+
}
|
|
2979
|
+
if (clientInfo.hasUpstream || this.previewBaseBranch && this.previewName) {
|
|
2980
|
+
await this.syncProject(configManager, codegen2.productionUrl, {
|
|
2981
|
+
upstreamBranch: this.upstreamBranch,
|
|
2982
|
+
previewBaseBranch: this.previewBaseBranch,
|
|
2983
|
+
previewName: this.previewName
|
|
2984
|
+
});
|
|
2985
|
+
}
|
|
2986
|
+
await waitForDB(
|
|
2987
|
+
configManager.config,
|
|
2988
|
+
codegen2.productionUrl,
|
|
2989
|
+
this.previewName,
|
|
2990
|
+
false
|
|
2991
|
+
);
|
|
2992
|
+
await this.checkGraphqlSchema(
|
|
2993
|
+
configManager,
|
|
2994
|
+
database,
|
|
2995
|
+
codegen2.productionUrl,
|
|
2996
|
+
clientInfo.timestamp
|
|
2997
|
+
);
|
|
2998
|
+
await this.checkTinaSchema(
|
|
2999
|
+
configManager,
|
|
3000
|
+
database,
|
|
3001
|
+
codegen2.productionUrl,
|
|
3002
|
+
this.previewName,
|
|
3003
|
+
this.verbose,
|
|
3004
|
+
clientInfo.timestamp
|
|
3005
|
+
);
|
|
3006
|
+
} catch (e) {
|
|
3007
|
+
logger.error(`
|
|
3008
|
+
|
|
3009
|
+
${dangerText(e.message)}
|
|
3010
|
+
`);
|
|
3011
|
+
if (this.verbose) {
|
|
3012
|
+
console.error(e);
|
|
3013
|
+
}
|
|
3014
|
+
process.exit(1);
|
|
2953
3015
|
}
|
|
2954
|
-
if (hasUpstream || this.previewBaseBranch && this.previewName) {
|
|
2955
|
-
await this.syncProject(configManager, codegen2.productionUrl, {
|
|
2956
|
-
upstreamBranch: this.upstreamBranch,
|
|
2957
|
-
previewBaseBranch: this.previewBaseBranch,
|
|
2958
|
-
previewName: this.previewName
|
|
2959
|
-
});
|
|
2960
|
-
}
|
|
2961
|
-
await waitForDB(
|
|
2962
|
-
configManager.config,
|
|
2963
|
-
codegen2.productionUrl,
|
|
2964
|
-
this.previewName,
|
|
2965
|
-
false
|
|
2966
|
-
);
|
|
2967
|
-
await this.checkGraphqlSchema(
|
|
2968
|
-
configManager,
|
|
2969
|
-
database,
|
|
2970
|
-
codegen2.productionUrl,
|
|
2971
|
-
timestamp
|
|
2972
|
-
);
|
|
2973
|
-
await this.checkTinaSchema(
|
|
2974
|
-
configManager,
|
|
2975
|
-
database,
|
|
2976
|
-
codegen2.productionUrl,
|
|
2977
|
-
this.previewName,
|
|
2978
|
-
this.verbose,
|
|
2979
|
-
timestamp
|
|
2980
|
-
);
|
|
2981
3016
|
}
|
|
2982
3017
|
await buildProductionSpa(configManager, database, codegen2.productionUrl);
|
|
2983
3018
|
await import_fs_extra7.default.outputFile(
|
|
@@ -2986,9 +3021,9 @@ ${dangerText(e.message)}
|
|
|
2986
3021
|
);
|
|
2987
3022
|
if (configManager.config.search && !this.skipSearchIndex && !this.localOption) {
|
|
2988
3023
|
let client;
|
|
2989
|
-
const hasTinaSearch = Boolean(
|
|
3024
|
+
const hasTinaSearch = Boolean(configManager.config?.search?.tina);
|
|
2990
3025
|
if (hasTinaSearch) {
|
|
2991
|
-
if (!
|
|
3026
|
+
if (!configManager.config?.branch) {
|
|
2992
3027
|
logger.error(
|
|
2993
3028
|
`${dangerText(
|
|
2994
3029
|
`ERROR: Branch not configured in tina search configuration.`
|
|
@@ -2998,11 +3033,11 @@ ${dangerText(e.message)}
|
|
|
2998
3033
|
"Branch not configured in tina search configuration."
|
|
2999
3034
|
);
|
|
3000
3035
|
}
|
|
3001
|
-
if (!
|
|
3036
|
+
if (!configManager.config?.clientId) {
|
|
3002
3037
|
logger.error(`${dangerText(`ERROR: clientId not configured.`)}`);
|
|
3003
3038
|
throw new Error("clientId not configured.");
|
|
3004
3039
|
}
|
|
3005
|
-
if (!
|
|
3040
|
+
if (!configManager.config?.search?.tina?.indexerToken) {
|
|
3006
3041
|
logger.error(
|
|
3007
3042
|
`${dangerText(
|
|
3008
3043
|
`ERROR: indexerToken not configured in tina search configuration.`
|
|
@@ -3013,16 +3048,16 @@ ${dangerText(e.message)}
|
|
|
3013
3048
|
);
|
|
3014
3049
|
}
|
|
3015
3050
|
client = new import_search2.TinaCMSSearchIndexClient({
|
|
3016
|
-
apiUrl: `${
|
|
3017
|
-
branch:
|
|
3018
|
-
indexerToken:
|
|
3019
|
-
stopwordLanguages:
|
|
3051
|
+
apiUrl: `${configManager.config.tinaioConfig?.contentApiUrlOverride || "https://content.tinajs.io"}/searchIndex/${configManager.config?.clientId}`,
|
|
3052
|
+
branch: configManager.config?.branch,
|
|
3053
|
+
indexerToken: configManager.config?.search?.tina?.indexerToken,
|
|
3054
|
+
stopwordLanguages: configManager.config?.search?.tina?.stopwordLanguages
|
|
3020
3055
|
});
|
|
3021
3056
|
} else {
|
|
3022
|
-
client =
|
|
3057
|
+
client = configManager.config?.search?.searchClient;
|
|
3023
3058
|
}
|
|
3024
3059
|
const searchIndexer = new import_search2.SearchIndexer({
|
|
3025
|
-
batchSize:
|
|
3060
|
+
batchSize: configManager.config.search?.indexBatchSize || 100,
|
|
3026
3061
|
bridge: new import_graphql11.FilesystemBridge(
|
|
3027
3062
|
configManager.rootPath,
|
|
3028
3063
|
configManager.contentRootPath
|
|
@@ -3090,86 +3125,88 @@ ${dangerText(e.message)}
|
|
|
3090
3125
|
}
|
|
3091
3126
|
}
|
|
3092
3127
|
async checkClientInfo(configManager, apiURL, previewBaseBranch) {
|
|
3128
|
+
const MAX_RETRIES = 5;
|
|
3093
3129
|
const { config: config2 } = configManager;
|
|
3094
3130
|
const token = config2.token;
|
|
3095
3131
|
const { clientId, branch, host } = (0, import_schema_tools2.parseURL)(apiURL);
|
|
3096
|
-
const url = `https://${host}/db/${clientId}/status/${previewBaseBranch || branch}`;
|
|
3097
3132
|
const bar2 = new import_progress2.default("Checking clientId and token. :prog", 1);
|
|
3098
|
-
|
|
3099
|
-
|
|
3100
|
-
|
|
3101
|
-
|
|
3102
|
-
|
|
3103
|
-
|
|
3104
|
-
|
|
3105
|
-
|
|
3106
|
-
|
|
3107
|
-
|
|
3108
|
-
|
|
3109
|
-
|
|
3110
|
-
|
|
3111
|
-
|
|
3112
|
-
|
|
3113
|
-
|
|
3114
|
-
|
|
3133
|
+
const getBranchInfo = async () => {
|
|
3134
|
+
const url = `https://${host}/db/${clientId}/status/${previewBaseBranch || branch}`;
|
|
3135
|
+
const branchInfo2 = {
|
|
3136
|
+
status: "unknown",
|
|
3137
|
+
branchKnown: false,
|
|
3138
|
+
hasUpstream: false,
|
|
3139
|
+
timestamp: 0,
|
|
3140
|
+
detectedBotBranch: false,
|
|
3141
|
+
defaultBranch: void 0
|
|
3142
|
+
};
|
|
3143
|
+
try {
|
|
3144
|
+
const res = await request({
|
|
3145
|
+
token,
|
|
3146
|
+
url
|
|
3147
|
+
});
|
|
3148
|
+
branchInfo2.status = res.status;
|
|
3149
|
+
branchInfo2.branchKnown = res.status !== "unknown";
|
|
3150
|
+
branchInfo2.timestamp = res.timestamp || 0;
|
|
3151
|
+
branchInfo2.hasUpstream = res.hasUpstream;
|
|
3152
|
+
branchInfo2.detectedBotBranch = res.json.detectedBotBranch;
|
|
3153
|
+
branchInfo2.defaultBranch = res.json.defaultBranch;
|
|
3154
|
+
} catch (e) {
|
|
3155
|
+
summary({
|
|
3156
|
+
heading: "Error when checking client information",
|
|
3157
|
+
items: [
|
|
3158
|
+
{
|
|
3159
|
+
emoji: "\u274C",
|
|
3160
|
+
heading: "You provided",
|
|
3161
|
+
subItems: [
|
|
3162
|
+
{
|
|
3163
|
+
key: "clientId",
|
|
3164
|
+
value: config2.clientId
|
|
3165
|
+
},
|
|
3166
|
+
{
|
|
3167
|
+
key: "branch",
|
|
3168
|
+
value: config2.branch
|
|
3169
|
+
},
|
|
3170
|
+
{
|
|
3171
|
+
key: "token",
|
|
3172
|
+
value: config2.token
|
|
3173
|
+
}
|
|
3174
|
+
]
|
|
3175
|
+
}
|
|
3176
|
+
]
|
|
3177
|
+
});
|
|
3178
|
+
throw e;
|
|
3115
3179
|
}
|
|
3116
|
-
|
|
3117
|
-
|
|
3118
|
-
|
|
3119
|
-
|
|
3120
|
-
|
|
3121
|
-
|
|
3122
|
-
|
|
3123
|
-
|
|
3124
|
-
|
|
3125
|
-
|
|
3126
|
-
|
|
3127
|
-
},
|
|
3128
|
-
{
|
|
3129
|
-
key: "branch",
|
|
3130
|
-
value: config2.branch
|
|
3131
|
-
},
|
|
3132
|
-
{
|
|
3133
|
-
key: "token",
|
|
3134
|
-
value: config2.token
|
|
3135
|
-
}
|
|
3136
|
-
]
|
|
3137
|
-
}
|
|
3138
|
-
]
|
|
3139
|
-
});
|
|
3140
|
-
throw e;
|
|
3141
|
-
}
|
|
3142
|
-
const branchBar = new import_progress2.default("Checking branch is on TinaCloud. :prog", 1);
|
|
3143
|
-
if (branchKnown) {
|
|
3180
|
+
return branchInfo2;
|
|
3181
|
+
};
|
|
3182
|
+
const branchInfo = await getBranchInfo();
|
|
3183
|
+
bar2.tick({
|
|
3184
|
+
prog: "\u2705"
|
|
3185
|
+
});
|
|
3186
|
+
const branchBar = new import_progress2.default(
|
|
3187
|
+
`Checking branch '${config2.branch}' is on TinaCloud. :prog`,
|
|
3188
|
+
1
|
|
3189
|
+
);
|
|
3190
|
+
if (branchInfo.branchKnown) {
|
|
3144
3191
|
branchBar.tick({
|
|
3145
3192
|
prog: "\u2705"
|
|
3146
3193
|
});
|
|
3147
|
-
return
|
|
3148
|
-
hasUpstream,
|
|
3149
|
-
timestamp
|
|
3150
|
-
};
|
|
3194
|
+
return branchInfo;
|
|
3151
3195
|
}
|
|
3152
|
-
for (let i =
|
|
3153
|
-
await
|
|
3154
|
-
|
|
3155
|
-
|
|
3156
|
-
|
|
3157
|
-
|
|
3158
|
-
|
|
3159
|
-
|
|
3160
|
-
|
|
3161
|
-
|
|
3162
|
-
|
|
3163
|
-
|
|
3164
|
-
|
|
3165
|
-
|
|
3166
|
-
prog: "\u2705"
|
|
3167
|
-
});
|
|
3168
|
-
return;
|
|
3169
|
-
}
|
|
3170
|
-
},
|
|
3171
|
-
ms: 5e3
|
|
3172
|
-
});
|
|
3196
|
+
for (let i = 1; i <= MAX_RETRIES; i++) {
|
|
3197
|
+
await timeout(5e3);
|
|
3198
|
+
const branchInfo2 = await getBranchInfo();
|
|
3199
|
+
if (this.verbose) {
|
|
3200
|
+
logger.info(
|
|
3201
|
+
`Branch status: ${branchInfo2.status}. Attempt: ${i}. Trying again in 5 seconds.`
|
|
3202
|
+
);
|
|
3203
|
+
}
|
|
3204
|
+
if (branchInfo2.branchKnown) {
|
|
3205
|
+
branchBar.tick({
|
|
3206
|
+
prog: "\u2705"
|
|
3207
|
+
});
|
|
3208
|
+
return branchInfo2;
|
|
3209
|
+
}
|
|
3173
3210
|
}
|
|
3174
3211
|
branchBar.tick({
|
|
3175
3212
|
prog: "\u274C"
|
|
@@ -3177,7 +3214,7 @@ ${dangerText(e.message)}
|
|
|
3177
3214
|
logger.error(
|
|
3178
3215
|
`${dangerText(
|
|
3179
3216
|
`ERROR: Branch '${branch}' is not on TinaCloud.`
|
|
3180
|
-
)} Please make sure that branch '${branch}' exists in your repository and that you have pushed your all changes to the remote. View all
|
|
3217
|
+
)} Please make sure that branch '${branch}' exists in your repository and that you have pushed your all changes to the remote. View all branches and their current status here: ${linkText(
|
|
3181
3218
|
`https://app.tina.io/projects/${clientId}/configuration`
|
|
3182
3219
|
)}`
|
|
3183
3220
|
);
|
|
@@ -3252,7 +3289,7 @@ ${dangerText(e.message)}
|
|
|
3252
3289
|
prog: "\u274C"
|
|
3253
3290
|
});
|
|
3254
3291
|
let errorMessage = `The remote GraphQL schema does not exist. Check indexing for this branch.`;
|
|
3255
|
-
if (config2
|
|
3292
|
+
if (config2?.branch) {
|
|
3256
3293
|
errorMessage += `
|
|
3257
3294
|
|
|
3258
3295
|
Additional info: Branch: ${config2.branch}, Client ID: ${config2.clientId} `;
|
|
@@ -3284,7 +3321,7 @@ Check out '${faqLink}' for possible solutions.`}`;
|
|
|
3284
3321
|
Additional info:
|
|
3285
3322
|
|
|
3286
3323
|
`;
|
|
3287
|
-
if (config2
|
|
3324
|
+
if (config2?.branch) {
|
|
3288
3325
|
errorMessage += ` Branch: ${config2.branch}, Client ID: ${config2.clientId}
|
|
3289
3326
|
`;
|
|
3290
3327
|
}
|
|
@@ -3333,7 +3370,7 @@ Additional info:
|
|
|
3333
3370
|
prog: "\u274C"
|
|
3334
3371
|
});
|
|
3335
3372
|
let errorMessage = `The remote Tina schema does not exist. Check indexing for this branch.`;
|
|
3336
|
-
if (config2
|
|
3373
|
+
if (config2?.branch) {
|
|
3337
3374
|
errorMessage += `
|
|
3338
3375
|
|
|
3339
3376
|
Additional info: Branch: ${config2.branch}, Client ID: ${config2.clientId} `;
|
|
@@ -3345,7 +3382,7 @@ Additional info: Branch: ${config2.branch}, Client ID: ${config2.clientId} `;
|
|
|
3345
3382
|
}
|
|
3346
3383
|
const localTinaSchema = JSON.parse(
|
|
3347
3384
|
await database.bridge.get(
|
|
3348
|
-
|
|
3385
|
+
import_path8.default.join(database.tinaDirectory, "__generated__", "_schema.json")
|
|
3349
3386
|
)
|
|
3350
3387
|
);
|
|
3351
3388
|
localTinaSchema.version = void 0;
|
|
@@ -3364,7 +3401,7 @@ Additional info: Branch: ${config2.branch}, Client ID: ${config2.clientId} `;
|
|
|
3364
3401
|
Additional info:
|
|
3365
3402
|
|
|
3366
3403
|
`;
|
|
3367
|
-
if (config2
|
|
3404
|
+
if (config2?.branch) {
|
|
3368
3405
|
errorMessage += ` Branch: ${config2.branch}, Client ID: ${config2.clientId}
|
|
3369
3406
|
`;
|
|
3370
3407
|
}
|
|
@@ -3376,18 +3413,13 @@ Additional info:
|
|
|
3376
3413
|
}
|
|
3377
3414
|
}
|
|
3378
3415
|
};
|
|
3379
|
-
BuildCommand.paths = [["build"]];
|
|
3380
|
-
BuildCommand.usage = import_clipanion3.Command.Usage({
|
|
3381
|
-
category: `Commands`,
|
|
3382
|
-
description: `Build the CMS and autogenerated modules for usage with TinaCloud`
|
|
3383
|
-
});
|
|
3384
3416
|
async function request(args) {
|
|
3385
3417
|
const headers = new Headers();
|
|
3386
3418
|
if (args.token) {
|
|
3387
3419
|
headers.append("X-API-KEY", args.token);
|
|
3388
3420
|
}
|
|
3389
3421
|
headers.append("Content-Type", "application/json");
|
|
3390
|
-
const url = args
|
|
3422
|
+
const url = args?.url;
|
|
3391
3423
|
const res = await fetch(url, {
|
|
3392
3424
|
method: args.method || "GET",
|
|
3393
3425
|
headers,
|
|
@@ -3405,21 +3437,22 @@ async function request(args) {
|
|
|
3405
3437
|
Message from server: ${json.message}`;
|
|
3406
3438
|
}
|
|
3407
3439
|
throw new Error(
|
|
3408
|
-
`Server responded with status code ${res.status}, ${res.statusText}. ${additionalInfo ? additionalInfo : ""} Please see our FAQ for more information: https://tina.io/docs/
|
|
3440
|
+
`Server responded with status code ${res.status}, ${res.statusText}. ${additionalInfo ? additionalInfo : ""} Please see our FAQ for more information: https://tina.io/docs/r/FAQ/`
|
|
3409
3441
|
);
|
|
3410
3442
|
}
|
|
3411
3443
|
if (json.errors) {
|
|
3412
3444
|
throw new Error(
|
|
3413
|
-
`Unable to fetch, please see our FAQ for more information: https://tina.io/docs/
|
|
3445
|
+
`Unable to fetch, please see our FAQ for more information: https://tina.io/docs/r/FAQ/
|
|
3414
3446
|
|
|
3415
3447
|
Errors:
|
|
3416
3448
|
${json.errors.map((error) => error.message).join("\n")}`
|
|
3417
3449
|
);
|
|
3418
3450
|
}
|
|
3419
3451
|
return {
|
|
3420
|
-
status: json
|
|
3421
|
-
timestamp: json
|
|
3422
|
-
hasUpstream:
|
|
3452
|
+
status: json?.status,
|
|
3453
|
+
timestamp: json?.timestamp,
|
|
3454
|
+
hasUpstream: json?.hasUpstream || false,
|
|
3455
|
+
json
|
|
3423
3456
|
};
|
|
3424
3457
|
}
|
|
3425
3458
|
var fetchRemoteGraphqlSchema = async ({
|
|
@@ -3442,7 +3475,7 @@ var fetchRemoteGraphqlSchema = async ({
|
|
|
3442
3475
|
});
|
|
3443
3476
|
const data = await res.json();
|
|
3444
3477
|
return {
|
|
3445
|
-
remoteSchema: data
|
|
3478
|
+
remoteSchema: data?.data,
|
|
3446
3479
|
remoteRuntimeVersion: res.headers.get("tinacms-grapqhl-version"),
|
|
3447
3480
|
remoteProjectVersion: res.headers.get("tinacms-graphql-project-version")
|
|
3448
3481
|
};
|
|
@@ -3652,6 +3685,15 @@ var AuditCommand = class extends import_clipanion4.Command {
|
|
|
3652
3685
|
description: "Specify a port to run the datalayer server on. (default 9000)"
|
|
3653
3686
|
});
|
|
3654
3687
|
}
|
|
3688
|
+
static {
|
|
3689
|
+
this.paths = [["audit"]];
|
|
3690
|
+
}
|
|
3691
|
+
static {
|
|
3692
|
+
this.usage = import_clipanion4.Command.Usage({
|
|
3693
|
+
category: `Commands`,
|
|
3694
|
+
description: `Audit config and content files`
|
|
3695
|
+
});
|
|
3696
|
+
}
|
|
3655
3697
|
async catch(error) {
|
|
3656
3698
|
logger.error("Error occured during tinacms audit");
|
|
3657
3699
|
if (this.verbose) {
|
|
@@ -3705,36 +3747,31 @@ var AuditCommand = class extends import_clipanion4.Command {
|
|
|
3705
3747
|
process.exit();
|
|
3706
3748
|
}
|
|
3707
3749
|
};
|
|
3708
|
-
AuditCommand.paths = [["audit"]];
|
|
3709
|
-
AuditCommand.usage = import_clipanion4.Command.Usage({
|
|
3710
|
-
category: `Commands`,
|
|
3711
|
-
description: `Audit config and content files`
|
|
3712
|
-
});
|
|
3713
3750
|
|
|
3714
3751
|
// src/next/commands/init-command/index.ts
|
|
3715
3752
|
var import_clipanion6 = require("clipanion");
|
|
3716
3753
|
|
|
3717
3754
|
// src/cmds/init/detectEnvironment.ts
|
|
3718
3755
|
var import_fs_extra8 = __toESM(require("fs-extra"));
|
|
3719
|
-
var
|
|
3756
|
+
var import_path9 = __toESM(require("path"));
|
|
3720
3757
|
var checkGitignoreForItem = async ({
|
|
3721
3758
|
baseDir,
|
|
3722
3759
|
line
|
|
3723
3760
|
}) => {
|
|
3724
|
-
const gitignoreContent = import_fs_extra8.default.readFileSync(
|
|
3761
|
+
const gitignoreContent = import_fs_extra8.default.readFileSync(import_path9.default.join(baseDir, ".gitignore")).toString();
|
|
3725
3762
|
return gitignoreContent.split("\n").some((item) => item === line);
|
|
3726
3763
|
};
|
|
3727
3764
|
var makeGeneratedFile = async (name2, generatedFileType, parentPath, opts) => {
|
|
3728
3765
|
const result = {
|
|
3729
|
-
fullPathTS:
|
|
3766
|
+
fullPathTS: import_path9.default.join(
|
|
3730
3767
|
parentPath,
|
|
3731
|
-
`${name2}.${
|
|
3768
|
+
`${name2}.${opts?.typescriptSuffix || opts?.extensionOverride || "ts"}`
|
|
3732
3769
|
),
|
|
3733
|
-
fullPathJS:
|
|
3770
|
+
fullPathJS: import_path9.default.join(
|
|
3734
3771
|
parentPath,
|
|
3735
|
-
`${name2}.${
|
|
3772
|
+
`${name2}.${opts?.extensionOverride || "js"}`
|
|
3736
3773
|
),
|
|
3737
|
-
fullPathOverride:
|
|
3774
|
+
fullPathOverride: opts?.extensionOverride ? import_path9.default.join(parentPath, `${name2}.${opts?.extensionOverride}`) : "",
|
|
3738
3775
|
generatedFileType,
|
|
3739
3776
|
name: name2,
|
|
3740
3777
|
parentPath,
|
|
@@ -3762,18 +3799,17 @@ var detectEnvironment = async ({
|
|
|
3762
3799
|
rootPath,
|
|
3763
3800
|
debug = false
|
|
3764
3801
|
}) => {
|
|
3765
|
-
var _a;
|
|
3766
3802
|
const hasForestryConfig = await import_fs_extra8.default.pathExists(
|
|
3767
|
-
|
|
3803
|
+
import_path9.default.join(pathToForestryConfig, ".forestry", "settings.yml")
|
|
3768
3804
|
);
|
|
3769
|
-
const sampleContentPath =
|
|
3805
|
+
const sampleContentPath = import_path9.default.join(
|
|
3770
3806
|
baseDir,
|
|
3771
3807
|
"content",
|
|
3772
3808
|
"posts",
|
|
3773
3809
|
"hello-world.md"
|
|
3774
3810
|
);
|
|
3775
|
-
const usingSrc = import_fs_extra8.default.pathExistsSync(
|
|
3776
|
-
const tinaFolder =
|
|
3811
|
+
const usingSrc = import_fs_extra8.default.pathExistsSync(import_path9.default.join(baseDir, "src")) && (import_fs_extra8.default.pathExistsSync(import_path9.default.join(baseDir, "src", "app")) || import_fs_extra8.default.pathExistsSync(import_path9.default.join(baseDir, "src", "pages")));
|
|
3812
|
+
const tinaFolder = import_path9.default.join(baseDir, "tina");
|
|
3777
3813
|
const tinaConfigExists = Boolean(
|
|
3778
3814
|
// Does the tina folder exist?
|
|
3779
3815
|
await import_fs_extra8.default.pathExists(tinaFolder) && // Does the tina folder contain a config file?
|
|
@@ -3789,12 +3825,12 @@ var detectEnvironment = async ({
|
|
|
3789
3825
|
"next-api-handler": await makeGeneratedFile(
|
|
3790
3826
|
"[...routes]",
|
|
3791
3827
|
"next-api-handler",
|
|
3792
|
-
|
|
3828
|
+
import_path9.default.join(...pagesDir, "api", "tina")
|
|
3793
3829
|
),
|
|
3794
3830
|
"reactive-example": await makeGeneratedFile(
|
|
3795
3831
|
"[filename]",
|
|
3796
3832
|
"reactive-example",
|
|
3797
|
-
|
|
3833
|
+
import_path9.default.join(...pagesDir, "demo", "blog"),
|
|
3798
3834
|
{
|
|
3799
3835
|
typescriptSuffix: "tsx"
|
|
3800
3836
|
}
|
|
@@ -3802,13 +3838,13 @@ var detectEnvironment = async ({
|
|
|
3802
3838
|
"users-json": await makeGeneratedFile(
|
|
3803
3839
|
"index",
|
|
3804
3840
|
"users-json",
|
|
3805
|
-
|
|
3841
|
+
import_path9.default.join(baseDir, "content", "users"),
|
|
3806
3842
|
{ extensionOverride: "json" }
|
|
3807
3843
|
),
|
|
3808
3844
|
"sample-content": await makeGeneratedFile(
|
|
3809
3845
|
"hello-world",
|
|
3810
3846
|
"sample-content",
|
|
3811
|
-
|
|
3847
|
+
import_path9.default.join(baseDir, "content", "posts"),
|
|
3812
3848
|
{ extensionOverride: "md" }
|
|
3813
3849
|
)
|
|
3814
3850
|
};
|
|
@@ -3819,10 +3855,10 @@ var detectEnvironment = async ({
|
|
|
3819
3855
|
try {
|
|
3820
3856
|
const packageJSON = await import_fs_extra8.default.readJSON("package.json");
|
|
3821
3857
|
const deps = [];
|
|
3822
|
-
if (packageJSON
|
|
3858
|
+
if (packageJSON?.dependencies) {
|
|
3823
3859
|
deps.push(...Object.keys(packageJSON.dependencies));
|
|
3824
3860
|
}
|
|
3825
|
-
if (packageJSON
|
|
3861
|
+
if (packageJSON?.devDependencies) {
|
|
3826
3862
|
deps.push(...Object.keys(packageJSON.devDependencies));
|
|
3827
3863
|
}
|
|
3828
3864
|
if (deps.includes("@tinacms/cli") && deps.includes("tinacms")) {
|
|
@@ -3834,16 +3870,16 @@ var detectEnvironment = async ({
|
|
|
3834
3870
|
);
|
|
3835
3871
|
}
|
|
3836
3872
|
}
|
|
3837
|
-
const hasGitIgnore = await import_fs_extra8.default.pathExists(
|
|
3873
|
+
const hasGitIgnore = await import_fs_extra8.default.pathExists(import_path9.default.join(".gitignore"));
|
|
3838
3874
|
const hasGitIgnoreNodeModules = hasGitIgnore && await checkGitignoreForItem({ baseDir, line: "node_modules" });
|
|
3839
3875
|
const hasEnvTina = hasGitIgnore && await checkGitignoreForItem({ baseDir, line: ".env.tina" });
|
|
3840
3876
|
const hasGitIgnoreEnv = hasGitIgnore && await checkGitignoreForItem({ baseDir, line: ".env" });
|
|
3841
3877
|
let frontMatterFormat;
|
|
3842
3878
|
if (hasForestryConfig) {
|
|
3843
|
-
const hugoConfigPath =
|
|
3879
|
+
const hugoConfigPath = import_path9.default.join(rootPath, "config.toml");
|
|
3844
3880
|
if (await import_fs_extra8.default.pathExists(hugoConfigPath)) {
|
|
3845
3881
|
const hugoConfig = await import_fs_extra8.default.readFile(hugoConfigPath, "utf8");
|
|
3846
|
-
const metaDataFormat =
|
|
3882
|
+
const metaDataFormat = hugoConfig.toString().match(/metaDataFormat = "(.*)"/)?.[1];
|
|
3847
3883
|
if (metaDataFormat && (metaDataFormat === "yaml" || metaDataFormat === "toml" || metaDataFormat === "json")) {
|
|
3848
3884
|
frontMatterFormat = metaDataFormat;
|
|
3849
3885
|
}
|
|
@@ -3942,7 +3978,7 @@ var chooseGitProvider = async ({ config: config2 }) => {
|
|
|
3942
3978
|
${logText(
|
|
3943
3979
|
"Learn more here: "
|
|
3944
3980
|
)}${linkText(
|
|
3945
|
-
"https://tina.io/docs/self-
|
|
3981
|
+
"https://tina.io/docs/r/self-hosting-nextjs/#github-personal-access-token"
|
|
3946
3982
|
)}`,
|
|
3947
3983
|
initial: process.env.GITHUB_PERSONAL_ACCESS_TOKEN
|
|
3948
3984
|
},
|
|
@@ -4203,7 +4239,8 @@ var askCommonSetUp = async () => {
|
|
|
4203
4239
|
choices: [
|
|
4204
4240
|
{ title: "PNPM", value: "pnpm" },
|
|
4205
4241
|
{ title: "Yarn", value: "yarn" },
|
|
4206
|
-
{ title: "NPM", value: "npm" }
|
|
4242
|
+
{ title: "NPM", value: "npm" },
|
|
4243
|
+
{ title: "Bun", value: "bun" }
|
|
4207
4244
|
]
|
|
4208
4245
|
}
|
|
4209
4246
|
]);
|
|
@@ -4264,7 +4301,7 @@ var askTinaSetupPrompts = async (params) => {
|
|
|
4264
4301
|
message: `Where are public assets stored? (default: "public")
|
|
4265
4302
|
` + logText(
|
|
4266
4303
|
`Not sure what value to use? Refer to our "Frameworks" doc: ${linkText(
|
|
4267
|
-
"https://tina.io/docs/
|
|
4304
|
+
"https://tina.io/docs/r/framework-guides-overview"
|
|
4268
4305
|
)}`
|
|
4269
4306
|
)
|
|
4270
4307
|
});
|
|
@@ -4454,18 +4491,19 @@ var CLICommand = class {
|
|
|
4454
4491
|
};
|
|
4455
4492
|
|
|
4456
4493
|
// src/cmds/init/apply.ts
|
|
4457
|
-
var
|
|
4494
|
+
var import_path13 = __toESM(require("path"));
|
|
4458
4495
|
|
|
4459
4496
|
// src/cmds/forestry-migrate/index.ts
|
|
4460
4497
|
var import_fs_extra10 = __toESM(require("fs-extra"));
|
|
4461
|
-
var
|
|
4498
|
+
var import_path11 = __toESM(require("path"));
|
|
4462
4499
|
var import_js_yaml2 = __toESM(require("js-yaml"));
|
|
4463
4500
|
var import_minimatch = __toESM(require("minimatch"));
|
|
4464
4501
|
var import_graphql16 = require("@tinacms/graphql");
|
|
4502
|
+
var import_schema_tools3 = require("@tinacms/schema-tools");
|
|
4465
4503
|
|
|
4466
4504
|
// src/cmds/forestry-migrate/util/index.ts
|
|
4467
4505
|
var import_fs_extra9 = __toESM(require("fs-extra"));
|
|
4468
|
-
var
|
|
4506
|
+
var import_path10 = __toESM(require("path"));
|
|
4469
4507
|
var import_js_yaml = __toESM(require("js-yaml"));
|
|
4470
4508
|
var import_zod = __toESM(require("zod"));
|
|
4471
4509
|
|
|
@@ -4494,8 +4532,7 @@ var ErrorSingleton = class _ErrorSingleton {
|
|
|
4494
4532
|
this.collectionNameErrors.push(error);
|
|
4495
4533
|
}
|
|
4496
4534
|
printCollectionNameErrors() {
|
|
4497
|
-
|
|
4498
|
-
if ((_a = this.collectionNameErrors) == null ? void 0 : _a.length) {
|
|
4535
|
+
if (this.collectionNameErrors?.length) {
|
|
4499
4536
|
logger.error(
|
|
4500
4537
|
dangerText("ERROR: TinaCMS only supports alphanumeric template names")
|
|
4501
4538
|
);
|
|
@@ -4677,8 +4714,7 @@ var transformForestryFieldsToTinaFields = ({
|
|
|
4677
4714
|
skipBlocks = false
|
|
4678
4715
|
}) => {
|
|
4679
4716
|
const tinaFields = [];
|
|
4680
|
-
fields
|
|
4681
|
-
var _a, _b, _c, _d;
|
|
4717
|
+
fields?.forEach((forestryField2) => {
|
|
4682
4718
|
if (forestryField2.name === "menu") {
|
|
4683
4719
|
logger.info(
|
|
4684
4720
|
warnText(
|
|
@@ -4754,12 +4790,12 @@ var transformForestryFieldsToTinaFields = ({
|
|
|
4754
4790
|
};
|
|
4755
4791
|
break;
|
|
4756
4792
|
case "select":
|
|
4757
|
-
if (
|
|
4793
|
+
if (forestryField2.config?.options) {
|
|
4758
4794
|
field = {
|
|
4759
4795
|
type: "string",
|
|
4760
4796
|
...getTinaFieldsFromName(forestryField2.name),
|
|
4761
4797
|
label: forestryField2.label,
|
|
4762
|
-
options:
|
|
4798
|
+
options: forestryField2.config?.options || []
|
|
4763
4799
|
};
|
|
4764
4800
|
} else {
|
|
4765
4801
|
logger.info(
|
|
@@ -4777,7 +4813,7 @@ var transformForestryFieldsToTinaFields = ({
|
|
|
4777
4813
|
label: forestryField2.label,
|
|
4778
4814
|
list: true
|
|
4779
4815
|
};
|
|
4780
|
-
if (
|
|
4816
|
+
if (forestryField2.config?.options) {
|
|
4781
4817
|
field.options = forestryField2.config.options;
|
|
4782
4818
|
}
|
|
4783
4819
|
break;
|
|
@@ -4825,7 +4861,7 @@ var transformForestryFieldsToTinaFields = ({
|
|
|
4825
4861
|
break;
|
|
4826
4862
|
}
|
|
4827
4863
|
const templates2 = [];
|
|
4828
|
-
forestryField2
|
|
4864
|
+
forestryField2?.template_types.forEach((tem) => {
|
|
4829
4865
|
const { template: template2 } = getFieldsFromTemplates({
|
|
4830
4866
|
tem,
|
|
4831
4867
|
skipBlocks: true,
|
|
@@ -4883,7 +4919,7 @@ var transformForestryFieldsToTinaFields = ({
|
|
|
4883
4919
|
);
|
|
4884
4920
|
}
|
|
4885
4921
|
if (field) {
|
|
4886
|
-
if (
|
|
4922
|
+
if (forestryField2.config?.required) {
|
|
4887
4923
|
field = { ...field, required: true };
|
|
4888
4924
|
}
|
|
4889
4925
|
tinaFields.push(field);
|
|
@@ -4892,7 +4928,7 @@ var transformForestryFieldsToTinaFields = ({
|
|
|
4892
4928
|
return tinaFields;
|
|
4893
4929
|
};
|
|
4894
4930
|
var getFieldsFromTemplates = ({ tem, pathToForestryConfig, skipBlocks = false }) => {
|
|
4895
|
-
const templatePath =
|
|
4931
|
+
const templatePath = import_path10.default.join(
|
|
4896
4932
|
pathToForestryConfig,
|
|
4897
4933
|
".forestry",
|
|
4898
4934
|
"front_matter",
|
|
@@ -4945,8 +4981,7 @@ var stringifyLabelWithField = (label) => {
|
|
|
4945
4981
|
return `${labelString}Fields`;
|
|
4946
4982
|
};
|
|
4947
4983
|
var transformForestryMatchToTinaMatch = (match) => {
|
|
4948
|
-
|
|
4949
|
-
const newMatch = (_b = (_a = match.replace(" ", "").replace(/\.?(mdx|md|json|yaml|yml|toml)/g, "")) == null ? void 0 : _a.replace(/\..*$/g, "")) == null ? void 0 : _b.replace("{}", "");
|
|
4984
|
+
const newMatch = match.replace(" ", "").replace(/\.?(mdx|md|json|yaml|yml|toml)/g, "")?.replace(/\..*$/g, "")?.replace("{}", "");
|
|
4950
4985
|
if (match !== newMatch) {
|
|
4951
4986
|
logger.info(
|
|
4952
4987
|
`Info: Match ${match} was transformed to ${newMatch}. See ${linkText(
|
|
@@ -4958,7 +4993,7 @@ var transformForestryMatchToTinaMatch = (match) => {
|
|
|
4958
4993
|
};
|
|
4959
4994
|
function checkExt(ext) {
|
|
4960
4995
|
const extReal = ext.replace(".", "");
|
|
4961
|
-
if (
|
|
4996
|
+
if (import_schema_tools3.CONTENT_FORMATS.includes(extReal)) {
|
|
4962
4997
|
return extReal;
|
|
4963
4998
|
} else {
|
|
4964
4999
|
return false;
|
|
@@ -4968,8 +5003,8 @@ var generateAllTemplates = async ({
|
|
|
4968
5003
|
pathToForestryConfig
|
|
4969
5004
|
}) => {
|
|
4970
5005
|
const allTemplates = (await import_fs_extra10.default.readdir(
|
|
4971
|
-
|
|
4972
|
-
)).map((tem) =>
|
|
5006
|
+
import_path11.default.join(pathToForestryConfig, ".forestry", "front_matter", "templates")
|
|
5007
|
+
)).map((tem) => import_path11.default.basename(tem, ".yml"));
|
|
4973
5008
|
const templateMap = /* @__PURE__ */ new Map();
|
|
4974
5009
|
const proms = allTemplates.map(async (tem) => {
|
|
4975
5010
|
try {
|
|
@@ -5011,18 +5046,18 @@ var generateCollectionFromForestrySection = (args) => {
|
|
|
5011
5046
|
}
|
|
5012
5047
|
if (section.match) {
|
|
5013
5048
|
baseCollection.match = {
|
|
5014
|
-
...
|
|
5049
|
+
...baseCollection?.match || {},
|
|
5015
5050
|
include: transformForestryMatchToTinaMatch(section.match)
|
|
5016
5051
|
};
|
|
5017
5052
|
}
|
|
5018
5053
|
if (section.exclude) {
|
|
5019
5054
|
baseCollection.match = {
|
|
5020
|
-
...
|
|
5055
|
+
...baseCollection?.match || {},
|
|
5021
5056
|
exclude: transformForestryMatchToTinaMatch(section.exclude)
|
|
5022
5057
|
};
|
|
5023
5058
|
}
|
|
5024
5059
|
if (section.type === "directory") {
|
|
5025
|
-
if (!
|
|
5060
|
+
if (!section?.path || section.path === "/" || section.path === "./" || section.path === ".") {
|
|
5026
5061
|
logger.log(
|
|
5027
5062
|
warnText(
|
|
5028
5063
|
`Warning: Section ${section.label} is using a Root Path. Currently, Tina Does not support Root paths see ${linkText(
|
|
@@ -5032,11 +5067,11 @@ var generateCollectionFromForestrySection = (args) => {
|
|
|
5032
5067
|
);
|
|
5033
5068
|
return;
|
|
5034
5069
|
}
|
|
5035
|
-
const forestryTemplates =
|
|
5070
|
+
const forestryTemplates = section?.templates || [];
|
|
5036
5071
|
if (forestryTemplates.length === 0 && section.create === "all") {
|
|
5037
5072
|
for (const templateKey of templateMap.keys()) {
|
|
5038
5073
|
const { templateObj } = templateMap.get(templateKey);
|
|
5039
|
-
const pages = templateObj
|
|
5074
|
+
const pages = templateObj?.pages;
|
|
5040
5075
|
if (pages) {
|
|
5041
5076
|
let glob = section.match;
|
|
5042
5077
|
const skipPath = section.path === "" || section.path === "/" || !section.path;
|
|
@@ -5053,7 +5088,7 @@ var generateCollectionFromForestrySection = (args) => {
|
|
|
5053
5088
|
}
|
|
5054
5089
|
const hasBody = ["md", "mdx", "markdown"].includes(format3);
|
|
5055
5090
|
let c;
|
|
5056
|
-
if ((
|
|
5091
|
+
if ((forestryTemplates?.length || 0) > 1) {
|
|
5057
5092
|
c = {
|
|
5058
5093
|
...baseCollection,
|
|
5059
5094
|
// @ts-expect-error
|
|
@@ -5075,7 +5110,7 @@ var generateCollectionFromForestrySection = (args) => {
|
|
|
5075
5110
|
})
|
|
5076
5111
|
};
|
|
5077
5112
|
}
|
|
5078
|
-
if (
|
|
5113
|
+
if (forestryTemplates?.length === 1) {
|
|
5079
5114
|
const tem = forestryTemplates[0];
|
|
5080
5115
|
const template = templateMap.get(tem);
|
|
5081
5116
|
const fieldsString = stringifyLabelWithField(template.templateObj.label);
|
|
@@ -5090,7 +5125,7 @@ var generateCollectionFromForestrySection = (args) => {
|
|
|
5090
5125
|
})
|
|
5091
5126
|
};
|
|
5092
5127
|
}
|
|
5093
|
-
if (
|
|
5128
|
+
if (forestryTemplates?.length === 0) {
|
|
5094
5129
|
logger.warn(
|
|
5095
5130
|
warnText(
|
|
5096
5131
|
`No templates found for section ${section.label}. Please see ${linkText(
|
|
@@ -5103,7 +5138,7 @@ var generateCollectionFromForestrySection = (args) => {
|
|
|
5103
5138
|
fields: [BODY_FIELD]
|
|
5104
5139
|
};
|
|
5105
5140
|
}
|
|
5106
|
-
if (
|
|
5141
|
+
if (section?.create === "none") {
|
|
5107
5142
|
c.ui = {
|
|
5108
5143
|
...c.ui,
|
|
5109
5144
|
allowedActions: {
|
|
@@ -5114,9 +5149,9 @@ var generateCollectionFromForestrySection = (args) => {
|
|
|
5114
5149
|
return c;
|
|
5115
5150
|
} else if (section.type === "document") {
|
|
5116
5151
|
const filePath = section.path;
|
|
5117
|
-
const extname =
|
|
5118
|
-
const fileName =
|
|
5119
|
-
const dir =
|
|
5152
|
+
const extname = import_path11.default.extname(filePath);
|
|
5153
|
+
const fileName = import_path11.default.basename(filePath, extname);
|
|
5154
|
+
const dir = import_path11.default.dirname(filePath);
|
|
5120
5155
|
const ext = checkExt(extname);
|
|
5121
5156
|
if (ext) {
|
|
5122
5157
|
const fields = [];
|
|
@@ -5125,7 +5160,7 @@ var generateCollectionFromForestrySection = (args) => {
|
|
|
5125
5160
|
}
|
|
5126
5161
|
for (const currentTemplateName of templateMap.keys()) {
|
|
5127
5162
|
const { templateObj, fields: additionalFields } = templateMap.get(currentTemplateName);
|
|
5128
|
-
const pages =
|
|
5163
|
+
const pages = templateObj?.pages || [];
|
|
5129
5164
|
if (pages.includes(section.path)) {
|
|
5130
5165
|
fields.push(...additionalFields);
|
|
5131
5166
|
break;
|
|
@@ -5136,7 +5171,7 @@ var generateCollectionFromForestrySection = (args) => {
|
|
|
5136
5171
|
name: "dummy",
|
|
5137
5172
|
label: "Dummy field",
|
|
5138
5173
|
type: "string",
|
|
5139
|
-
description: "This is a dummy field, please replace it with the fields you want to edit. See https://tina.io/docs/
|
|
5174
|
+
description: "This is a dummy field, please replace it with the fields you want to edit. See https://tina.io/docs/r/content-modelling-collections/ for more info"
|
|
5140
5175
|
});
|
|
5141
5176
|
logger.warn(
|
|
5142
5177
|
warnText(
|
|
@@ -5179,7 +5214,7 @@ var generateCollections = async ({
|
|
|
5179
5214
|
usingTypescript
|
|
5180
5215
|
});
|
|
5181
5216
|
const forestryConfig = await import_fs_extra10.default.readFile(
|
|
5182
|
-
|
|
5217
|
+
import_path11.default.join(pathToForestryConfig, ".forestry", "settings.yml")
|
|
5183
5218
|
);
|
|
5184
5219
|
rewriteTemplateKeysInDocs({
|
|
5185
5220
|
templateMap,
|
|
@@ -5204,17 +5239,16 @@ var generateCollections = async ({
|
|
|
5204
5239
|
};
|
|
5205
5240
|
};
|
|
5206
5241
|
var rewriteTemplateKeysInDocs = (args) => {
|
|
5207
|
-
var _a;
|
|
5208
5242
|
const { templateMap, markdownParseConfig } = args;
|
|
5209
5243
|
for (const templateKey of templateMap.keys()) {
|
|
5210
5244
|
const { templateObj } = templateMap.get(templateKey);
|
|
5211
|
-
|
|
5245
|
+
templateObj?.pages?.forEach((page) => {
|
|
5212
5246
|
try {
|
|
5213
|
-
const filePath =
|
|
5247
|
+
const filePath = import_path11.default.join(page);
|
|
5214
5248
|
if (import_fs_extra10.default.lstatSync(filePath).isDirectory()) {
|
|
5215
5249
|
return;
|
|
5216
5250
|
}
|
|
5217
|
-
const extname =
|
|
5251
|
+
const extname = import_path11.default.extname(filePath);
|
|
5218
5252
|
const fileContent = import_fs_extra10.default.readFileSync(filePath).toString();
|
|
5219
5253
|
const content = (0, import_graphql16.parseFile)(
|
|
5220
5254
|
fileContent,
|
|
@@ -5246,7 +5280,7 @@ var import_fs_extra13 = __toESM(require("fs-extra"));
|
|
|
5246
5280
|
// src/next/commands/codemod-command/index.ts
|
|
5247
5281
|
var import_clipanion5 = require("clipanion");
|
|
5248
5282
|
var import_fs_extra11 = __toESM(require("fs-extra"));
|
|
5249
|
-
var
|
|
5283
|
+
var import_path12 = __toESM(require("path"));
|
|
5250
5284
|
var CodemodCommand = class extends import_clipanion5.Command {
|
|
5251
5285
|
constructor() {
|
|
5252
5286
|
super(...arguments);
|
|
@@ -5257,6 +5291,15 @@ var CodemodCommand = class extends import_clipanion5.Command {
|
|
|
5257
5291
|
description: "increase verbosity of logged output"
|
|
5258
5292
|
});
|
|
5259
5293
|
}
|
|
5294
|
+
static {
|
|
5295
|
+
this.paths = [["codemod"], ["codemod", "move-tina-folder"]];
|
|
5296
|
+
}
|
|
5297
|
+
static {
|
|
5298
|
+
this.usage = import_clipanion5.Command.Usage({
|
|
5299
|
+
category: `Commands`,
|
|
5300
|
+
description: `Use codemods for various Tina tasks`
|
|
5301
|
+
});
|
|
5302
|
+
}
|
|
5260
5303
|
async catch(error) {
|
|
5261
5304
|
console.log(error);
|
|
5262
5305
|
}
|
|
@@ -5277,11 +5320,6 @@ var CodemodCommand = class extends import_clipanion5.Command {
|
|
|
5277
5320
|
await command2();
|
|
5278
5321
|
}
|
|
5279
5322
|
};
|
|
5280
|
-
CodemodCommand.paths = [["codemod"], ["codemod", "move-tina-folder"]];
|
|
5281
|
-
CodemodCommand.usage = import_clipanion5.Command.Usage({
|
|
5282
|
-
category: `Commands`,
|
|
5283
|
-
description: `Use codemods for various Tina tasks`
|
|
5284
|
-
});
|
|
5285
5323
|
var moveTinaFolder = async (rootPath = process.cwd()) => {
|
|
5286
5324
|
const configManager = new ConfigManager({ rootPath });
|
|
5287
5325
|
try {
|
|
@@ -5290,7 +5328,7 @@ var moveTinaFolder = async (rootPath = process.cwd()) => {
|
|
|
5290
5328
|
logger.error(e.message);
|
|
5291
5329
|
process.exit(1);
|
|
5292
5330
|
}
|
|
5293
|
-
const tinaDestination =
|
|
5331
|
+
const tinaDestination = import_path12.default.join(configManager.rootPath, "tina");
|
|
5294
5332
|
if (await import_fs_extra11.default.existsSync(tinaDestination)) {
|
|
5295
5333
|
logger.info(
|
|
5296
5334
|
`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.`
|
|
@@ -5305,7 +5343,7 @@ var moveTinaFolder = async (rootPath = process.cwd()) => {
|
|
|
5305
5343
|
};
|
|
5306
5344
|
var writeGitignore = async (rootPath) => {
|
|
5307
5345
|
await import_fs_extra11.default.outputFileSync(
|
|
5308
|
-
|
|
5346
|
+
import_path12.default.join(rootPath, "tina", ".gitignore"),
|
|
5309
5347
|
"__generated__"
|
|
5310
5348
|
);
|
|
5311
5349
|
};
|
|
@@ -5358,7 +5396,7 @@ const BlogPage = (props) => {
|
|
|
5358
5396
|
<div className='bg-green-100 text-center'>
|
|
5359
5397
|
Lost and looking for a place to start?
|
|
5360
5398
|
<a
|
|
5361
|
-
href='https://tina.io/
|
|
5399
|
+
href='https://tina.io/docs/r/beginner-series'
|
|
5362
5400
|
className='text-blue-500 underline'
|
|
5363
5401
|
>
|
|
5364
5402
|
{' '}
|
|
@@ -5561,11 +5599,10 @@ var baseFields = `[
|
|
|
5561
5599
|
},
|
|
5562
5600
|
]`;
|
|
5563
5601
|
var generateCollectionString = (args) => {
|
|
5564
|
-
var _a, _b, _c, _d;
|
|
5565
5602
|
if (args.collections) {
|
|
5566
5603
|
return args.collections;
|
|
5567
5604
|
}
|
|
5568
|
-
let extraTinaCollections =
|
|
5605
|
+
let extraTinaCollections = args.config.authProvider?.extraTinaCollections?.join(",\n");
|
|
5569
5606
|
if (extraTinaCollections) {
|
|
5570
5607
|
extraTinaCollections = extraTinaCollections + ",";
|
|
5571
5608
|
}
|
|
@@ -5591,18 +5628,17 @@ var generateCollectionString = (args) => {
|
|
|
5591
5628
|
},
|
|
5592
5629
|
},
|
|
5593
5630
|
]`;
|
|
5594
|
-
if (
|
|
5631
|
+
if (args.config?.framework?.name === "next") {
|
|
5595
5632
|
return nextExampleCollection;
|
|
5596
5633
|
}
|
|
5597
5634
|
return baseCollections;
|
|
5598
5635
|
};
|
|
5599
5636
|
var generateConfig = (args) => {
|
|
5600
|
-
|
|
5601
|
-
const isUsingTinaCloud = !args.selfHosted || ((_a = args.config.authProvider) == null ? void 0 : _a.name) === "tina-cloud";
|
|
5637
|
+
const isUsingTinaCloud = !args.selfHosted || args.config.authProvider?.name === "tina-cloud";
|
|
5602
5638
|
let extraImports = "";
|
|
5603
5639
|
if (args.selfHosted) {
|
|
5604
5640
|
if (args.config.authProvider) {
|
|
5605
|
-
extraImports = extraImports + makeImportString(
|
|
5641
|
+
extraImports = extraImports + makeImportString(args.config.authProvider?.configImports);
|
|
5606
5642
|
}
|
|
5607
5643
|
if (!isUsingTinaCloud) {
|
|
5608
5644
|
extraImports = extraImports + `
|
|
@@ -5625,7 +5661,7 @@ import { LocalAuthProvider } from "tinacms";`;
|
|
|
5625
5661
|
branch,
|
|
5626
5662
|
${args.selfHosted && !isUsingTinaCloud ? `authProvider: isLocal
|
|
5627
5663
|
? new LocalAuthProvider()
|
|
5628
|
-
:${
|
|
5664
|
+
:${args.config?.authProvider.configAuthProviderClass},` : ""}
|
|
5629
5665
|
${isUsingTinaCloud ? `// Get this from tina.io
|
|
5630
5666
|
clientId: process.env.NEXT_PUBLIC_TINA_CLIENT_ID,` : ""}
|
|
5631
5667
|
${isUsingTinaCloud ? `// Get this from tina.io
|
|
@@ -5642,7 +5678,7 @@ import { LocalAuthProvider } from "tinacms";`;
|
|
|
5642
5678
|
publicFolder: "${args.publicFolder}",
|
|
5643
5679
|
},
|
|
5644
5680
|
},
|
|
5645
|
-
// See docs on content modeling for more info on how to setup new content models: https://tina.io/docs/
|
|
5681
|
+
// See docs on content modeling for more info on how to setup new content models: https://tina.io/docs/r/content-modelling-collections/
|
|
5646
5682
|
schema: {
|
|
5647
5683
|
collections: ${generateCollectionString(args)},
|
|
5648
5684
|
},
|
|
@@ -5652,11 +5688,10 @@ import { LocalAuthProvider } from "tinacms";`;
|
|
|
5652
5688
|
|
|
5653
5689
|
// src/cmds/init/templates/database.ts
|
|
5654
5690
|
var databaseTemplate = ({ config: config2 }) => {
|
|
5655
|
-
var _a, _b, _c, _d;
|
|
5656
5691
|
return `
|
|
5657
5692
|
import { createDatabase, createLocalDatabase } from '@tinacms/datalayer'
|
|
5658
|
-
${makeImportString(
|
|
5659
|
-
${makeImportString(
|
|
5693
|
+
${makeImportString(config2.gitProvider?.imports)}
|
|
5694
|
+
${makeImportString(config2.databaseAdapter?.imports)}
|
|
5660
5695
|
|
|
5661
5696
|
const branch = (process.env.GITHUB_BRANCH ||
|
|
5662
5697
|
process.env.VERCEL_GIT_COMMIT_REF ||
|
|
@@ -5668,8 +5703,8 @@ const isLocal = process.env.${config2.isLocalEnvVarName} === 'true'
|
|
|
5668
5703
|
export default isLocal
|
|
5669
5704
|
? createLocalDatabase()
|
|
5670
5705
|
: createDatabase({
|
|
5671
|
-
gitProvider: ${
|
|
5672
|
-
databaseAdapter: ${
|
|
5706
|
+
gitProvider: ${config2.gitProvider?.gitProviderClassText},
|
|
5707
|
+
databaseAdapter: ${config2.databaseAdapter?.databaseAdapterClassText},
|
|
5673
5708
|
namespace: branch,
|
|
5674
5709
|
})
|
|
5675
5710
|
`;
|
|
@@ -5680,10 +5715,9 @@ var nextApiRouteTemplate = ({
|
|
|
5680
5715
|
config: config2,
|
|
5681
5716
|
env
|
|
5682
5717
|
}) => {
|
|
5683
|
-
var _a, _b;
|
|
5684
5718
|
const extraPath = env.usingSrc ? "../" : "";
|
|
5685
5719
|
return `import { TinaNodeBackend, LocalBackendAuthProvider } from '@tinacms/datalayer'
|
|
5686
|
-
${makeImportString(
|
|
5720
|
+
${makeImportString(config2.authProvider?.backendAuthProviderImports)}
|
|
5687
5721
|
|
|
5688
5722
|
|
|
5689
5723
|
|
|
@@ -5694,7 +5728,7 @@ var nextApiRouteTemplate = ({
|
|
|
5694
5728
|
const handler = TinaNodeBackend({
|
|
5695
5729
|
authProvider: isLocal
|
|
5696
5730
|
? LocalBackendAuthProvider()
|
|
5697
|
-
: ${
|
|
5731
|
+
: ${config2.authProvider?.backendAuthProvider || ""},
|
|
5698
5732
|
databaseClient,
|
|
5699
5733
|
})
|
|
5700
5734
|
|
|
@@ -5722,19 +5756,18 @@ var import_prettier2 = require("prettier");
|
|
|
5722
5756
|
// src/utils/script-helpers.ts
|
|
5723
5757
|
function generateGqlScript(scriptValue, opts) {
|
|
5724
5758
|
const cmd = `tinacms dev -c "${scriptValue}"`;
|
|
5725
|
-
if (opts
|
|
5759
|
+
if (opts?.isLocalEnvVarName) {
|
|
5726
5760
|
return `${opts.isLocalEnvVarName}=true ${cmd}`;
|
|
5727
5761
|
}
|
|
5728
5762
|
return cmd;
|
|
5729
5763
|
}
|
|
5730
5764
|
function extendNextScripts(scripts, opts) {
|
|
5731
|
-
var _a, _b;
|
|
5732
5765
|
const result = {
|
|
5733
5766
|
...scripts,
|
|
5734
|
-
dev: !
|
|
5735
|
-
build: !
|
|
5767
|
+
dev: !scripts?.dev || scripts?.dev?.indexOf("tinacms dev -c") === -1 ? generateGqlScript(scripts?.dev || "next dev", opts) : scripts?.dev,
|
|
5768
|
+
build: !scripts?.build || !scripts?.build?.startsWith("tinacms build &&") ? `tinacms build && ${scripts?.build || "next build"}` : scripts?.build
|
|
5736
5769
|
};
|
|
5737
|
-
if (
|
|
5770
|
+
if (opts?.addSetupUsers && !scripts["setup:users"]) {
|
|
5738
5771
|
result["setup:users"] = "tinacms-next-auth setup";
|
|
5739
5772
|
}
|
|
5740
5773
|
return result;
|
|
@@ -5816,7 +5849,6 @@ var makeVariableStatementVisitor = (sourceFile, variableStmtSourceFile, variable
|
|
|
5816
5849
|
}
|
|
5817
5850
|
};
|
|
5818
5851
|
var makeImportsVisitor = (sourceFile, importMap) => (ctx) => (node) => {
|
|
5819
|
-
var _a;
|
|
5820
5852
|
if (import_typescript3.default.isSourceFile(node)) {
|
|
5821
5853
|
const newStatements = [...node.statements];
|
|
5822
5854
|
let changed = false;
|
|
@@ -5825,7 +5857,7 @@ var makeImportsVisitor = (sourceFile, importMap) => (ctx) => (node) => {
|
|
|
5825
5857
|
for (const statement of newStatements) {
|
|
5826
5858
|
if (import_typescript3.default.isImportDeclaration(statement) && import_typescript3.default.isStringLiteral(statement.moduleSpecifier) && statement.moduleSpecifier.text === moduleName) {
|
|
5827
5859
|
foundImportStatement = true;
|
|
5828
|
-
const existingImports =
|
|
5860
|
+
const existingImports = statement.importClause?.namedBindings && import_typescript3.default.isNamedImports(statement.importClause.namedBindings) ? statement.importClause.namedBindings.elements.map(
|
|
5829
5861
|
(e) => e.name.text
|
|
5830
5862
|
) : [];
|
|
5831
5863
|
const newImports = [
|
|
@@ -6042,7 +6074,6 @@ async function apply({
|
|
|
6042
6074
|
params,
|
|
6043
6075
|
config: config2
|
|
6044
6076
|
}) {
|
|
6045
|
-
var _a;
|
|
6046
6077
|
if (config2.framework.name === "other" && config2.hosting === "self-host") {
|
|
6047
6078
|
logger.error(
|
|
6048
6079
|
logText(
|
|
@@ -6148,8 +6179,8 @@ async function apply({
|
|
|
6148
6179
|
await addConfigFile({
|
|
6149
6180
|
configArgs: {
|
|
6150
6181
|
config: config2,
|
|
6151
|
-
publicFolder:
|
|
6152
|
-
|
|
6182
|
+
publicFolder: import_path13.default.join(
|
|
6183
|
+
import_path13.default.relative(process.cwd(), pathToForestryConfig),
|
|
6153
6184
|
config2.publicFolder
|
|
6154
6185
|
),
|
|
6155
6186
|
collections,
|
|
@@ -6168,7 +6199,7 @@ async function apply({
|
|
|
6168
6199
|
env.tinaConfigExists && // Are we running tinacms init backend
|
|
6169
6200
|
params.isBackendInit && // Do the user choose the 'self-host' option
|
|
6170
6201
|
config2.hosting === "self-host" && // the user did not choose the 'tina-cloud' auth provider
|
|
6171
|
-
(
|
|
6202
|
+
(config2.authProvider?.name || "") !== "tina-cloud"
|
|
6172
6203
|
) {
|
|
6173
6204
|
await addSelfHostedTinaAuthToConfig(config2, env.generatedFiles["config"]);
|
|
6174
6205
|
}
|
|
@@ -6222,21 +6253,20 @@ var createPackageJSON = async () => {
|
|
|
6222
6253
|
};
|
|
6223
6254
|
var createGitignore = async ({ baseDir }) => {
|
|
6224
6255
|
logger.info(logText("No .gitignore found, creating one"));
|
|
6225
|
-
import_fs_extra13.default.outputFileSync(
|
|
6256
|
+
import_fs_extra13.default.outputFileSync(import_path13.default.join(baseDir, ".gitignore"), "node_modules");
|
|
6226
6257
|
};
|
|
6227
6258
|
var updateGitIgnore = async ({
|
|
6228
6259
|
baseDir,
|
|
6229
6260
|
items
|
|
6230
6261
|
}) => {
|
|
6231
6262
|
logger.info(logText(`Adding ${items.join(",")} to .gitignore`));
|
|
6232
|
-
const gitignoreContent = import_fs_extra13.default.readFileSync(
|
|
6263
|
+
const gitignoreContent = import_fs_extra13.default.readFileSync(import_path13.default.join(baseDir, ".gitignore")).toString();
|
|
6233
6264
|
const newGitignoreContent = [...gitignoreContent.split("\n"), ...items].join(
|
|
6234
6265
|
"\n"
|
|
6235
6266
|
);
|
|
6236
|
-
await import_fs_extra13.default.writeFile(
|
|
6267
|
+
await import_fs_extra13.default.writeFile(import_path13.default.join(baseDir, ".gitignore"), newGitignoreContent);
|
|
6237
6268
|
};
|
|
6238
6269
|
var addDependencies = async (config2, env, params) => {
|
|
6239
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
6240
6270
|
const { packageManager } = config2;
|
|
6241
6271
|
const tagVersion = params.tinaVersion ? `@${params.tinaVersion}` : "";
|
|
6242
6272
|
let deps = [];
|
|
@@ -6252,18 +6282,18 @@ var addDependencies = async (config2, env, params) => {
|
|
|
6252
6282
|
deps.push("@tinacms/datalayer");
|
|
6253
6283
|
}
|
|
6254
6284
|
deps.push(
|
|
6255
|
-
...
|
|
6285
|
+
...config2.databaseAdapter?.imports?.map((x) => x.packageName) || []
|
|
6256
6286
|
);
|
|
6257
|
-
deps.push(...
|
|
6287
|
+
deps.push(...config2.authProvider?.peerDependencies || []);
|
|
6258
6288
|
deps.push(
|
|
6259
|
-
...
|
|
6289
|
+
...config2.authProvider?.backendAuthProviderImports?.map(
|
|
6260
6290
|
(x) => x.packageName
|
|
6261
|
-
)
|
|
6291
|
+
) || []
|
|
6262
6292
|
);
|
|
6263
6293
|
deps.push(
|
|
6264
|
-
...
|
|
6294
|
+
...config2.authProvider?.configImports?.map((x) => x.packageName) || []
|
|
6265
6295
|
);
|
|
6266
|
-
deps.push(...
|
|
6296
|
+
deps.push(...config2.gitProvider?.imports?.map((x) => x.packageName) || []);
|
|
6267
6297
|
if (tagVersion) {
|
|
6268
6298
|
deps = deps.map(
|
|
6269
6299
|
(dep) => dep.indexOf("tina") >= 0 ? `${dep}${tagVersion}` : dep
|
|
@@ -6275,7 +6305,8 @@ var addDependencies = async (config2, env, params) => {
|
|
|
6275
6305
|
let packageManagers = {
|
|
6276
6306
|
pnpm: process.env.USE_WORKSPACE ? `pnpm add ${deps.join(" ")} --workspace` : `pnpm add ${deps.join(" ")}`,
|
|
6277
6307
|
npm: `npm install ${deps.join(" ")}`,
|
|
6278
|
-
yarn: `yarn add ${deps.join(" ")}
|
|
6308
|
+
yarn: `yarn add ${deps.join(" ")}`,
|
|
6309
|
+
bun: `bun add ${deps.join(" ")}`
|
|
6279
6310
|
};
|
|
6280
6311
|
if (packageManagers[packageManager] && deps.length > 0) {
|
|
6281
6312
|
logger.info(logText("Adding dependencies, this might take a moment..."));
|
|
@@ -6286,7 +6317,8 @@ var addDependencies = async (config2, env, params) => {
|
|
|
6286
6317
|
packageManagers = {
|
|
6287
6318
|
pnpm: process.env.USE_WORKSPACE ? `pnpm add -D ${devDeps.join(" ")} --workspace` : `pnpm add -D ${devDeps.join(" ")}`,
|
|
6288
6319
|
npm: `npm install -D ${devDeps.join(" ")}`,
|
|
6289
|
-
yarn: `yarn add -D ${devDeps.join(" ")}
|
|
6320
|
+
yarn: `yarn add -D ${devDeps.join(" ")}`,
|
|
6321
|
+
bun: `bun add -D ${devDeps.join(" ")}`
|
|
6290
6322
|
};
|
|
6291
6323
|
if (packageManagers[packageManager]) {
|
|
6292
6324
|
logger.info(
|
|
@@ -6303,22 +6335,22 @@ var writeGeneratedFile = async ({
|
|
|
6303
6335
|
content,
|
|
6304
6336
|
typescript
|
|
6305
6337
|
}) => {
|
|
6306
|
-
const { exists, path:
|
|
6338
|
+
const { exists, path: path15, parentPath } = generatedFile.resolve(typescript);
|
|
6307
6339
|
if (exists) {
|
|
6308
6340
|
if (overwrite) {
|
|
6309
|
-
logger.info(`Overwriting file at ${
|
|
6310
|
-
import_fs_extra13.default.outputFileSync(
|
|
6341
|
+
logger.info(`Overwriting file at ${path15}... \u2705`);
|
|
6342
|
+
import_fs_extra13.default.outputFileSync(path15, content);
|
|
6311
6343
|
} else {
|
|
6312
|
-
logger.info(`Not overwriting file at ${
|
|
6344
|
+
logger.info(`Not overwriting file at ${path15}.`);
|
|
6313
6345
|
logger.info(
|
|
6314
|
-
logText(`Please add the following to ${
|
|
6346
|
+
logText(`Please add the following to ${path15}:
|
|
6315
6347
|
${indentText(content)}}`)
|
|
6316
6348
|
);
|
|
6317
6349
|
}
|
|
6318
6350
|
} else {
|
|
6319
|
-
logger.info(`Adding file at ${
|
|
6351
|
+
logger.info(`Adding file at ${path15}... \u2705`);
|
|
6320
6352
|
await import_fs_extra13.default.ensureDir(parentPath);
|
|
6321
|
-
import_fs_extra13.default.outputFileSync(
|
|
6353
|
+
import_fs_extra13.default.outputFileSync(path15, content);
|
|
6322
6354
|
}
|
|
6323
6355
|
};
|
|
6324
6356
|
var addConfigFile = async ({
|
|
@@ -6327,12 +6359,11 @@ var addConfigFile = async ({
|
|
|
6327
6359
|
generatedFile,
|
|
6328
6360
|
config: config2
|
|
6329
6361
|
}) => {
|
|
6330
|
-
var _a;
|
|
6331
6362
|
const content = (0, import_prettier2.format)(generateConfig(configArgs), {
|
|
6332
6363
|
parser: "babel"
|
|
6333
6364
|
});
|
|
6334
6365
|
await writeGeneratedFile({
|
|
6335
|
-
overwrite:
|
|
6366
|
+
overwrite: config2.overwriteList?.includes("config"),
|
|
6336
6367
|
generatedFile,
|
|
6337
6368
|
content,
|
|
6338
6369
|
typescript: config2.typescript
|
|
@@ -6346,10 +6377,9 @@ var addDatabaseFile = async ({
|
|
|
6346
6377
|
config: config2,
|
|
6347
6378
|
generatedFile
|
|
6348
6379
|
}) => {
|
|
6349
|
-
var _a;
|
|
6350
6380
|
await writeGeneratedFile({
|
|
6351
6381
|
generatedFile,
|
|
6352
|
-
overwrite:
|
|
6382
|
+
overwrite: config2.overwriteList?.includes("database"),
|
|
6353
6383
|
content: databaseTemplate({ config: config2 }),
|
|
6354
6384
|
typescript: config2.typescript
|
|
6355
6385
|
});
|
|
@@ -6359,13 +6389,12 @@ var addNextApiRoute = async ({
|
|
|
6359
6389
|
generatedFile,
|
|
6360
6390
|
env
|
|
6361
6391
|
}) => {
|
|
6362
|
-
var _a;
|
|
6363
6392
|
const content = (0, import_prettier2.format)(nextApiRouteTemplate({ config: config2, env }), {
|
|
6364
6393
|
parser: "babel"
|
|
6365
6394
|
});
|
|
6366
6395
|
await writeGeneratedFile({
|
|
6367
6396
|
generatedFile,
|
|
6368
|
-
overwrite:
|
|
6397
|
+
overwrite: config2.overwriteList?.includes("next-api-handler"),
|
|
6369
6398
|
content,
|
|
6370
6399
|
typescript: config2.typescript
|
|
6371
6400
|
});
|
|
@@ -6375,10 +6404,9 @@ var addTemplateFile = async ({
|
|
|
6375
6404
|
generatedFile,
|
|
6376
6405
|
config: config2
|
|
6377
6406
|
}) => {
|
|
6378
|
-
var _a;
|
|
6379
6407
|
await writeGeneratedFile({
|
|
6380
6408
|
generatedFile,
|
|
6381
|
-
overwrite:
|
|
6409
|
+
overwrite: config2.overwriteList?.includes(generatedFile.generatedFileType),
|
|
6382
6410
|
content,
|
|
6383
6411
|
typescript: config2.typescript
|
|
6384
6412
|
});
|
|
@@ -6387,7 +6415,6 @@ var addContentFile = async ({
|
|
|
6387
6415
|
config: config2,
|
|
6388
6416
|
env
|
|
6389
6417
|
}) => {
|
|
6390
|
-
var _a;
|
|
6391
6418
|
await writeGeneratedFile({
|
|
6392
6419
|
generatedFile: {
|
|
6393
6420
|
javascriptExists: false,
|
|
@@ -6401,11 +6428,11 @@ var addContentFile = async ({
|
|
|
6401
6428
|
return () => ({
|
|
6402
6429
|
exists: env.sampleContentExists,
|
|
6403
6430
|
path: env.sampleContentPath,
|
|
6404
|
-
parentPath:
|
|
6431
|
+
parentPath: import_path13.default.dirname(env.sampleContentPath)
|
|
6405
6432
|
});
|
|
6406
6433
|
}
|
|
6407
6434
|
},
|
|
6408
|
-
overwrite:
|
|
6435
|
+
overwrite: config2.overwriteList?.includes("sample-content"),
|
|
6409
6436
|
content: helloWorldPost,
|
|
6410
6437
|
typescript: false
|
|
6411
6438
|
});
|
|
@@ -6424,7 +6451,7 @@ ${titleText(" TinaCMS ")} backend initialized!`));
|
|
|
6424
6451
|
return `${x.key}=${x.value || "***"}`;
|
|
6425
6452
|
}).join("\n") + `
|
|
6426
6453
|
TINA_PUBLIC_IS_LOCAL=true`;
|
|
6427
|
-
const envFile =
|
|
6454
|
+
const envFile = import_path13.default.join(process.cwd(), ".env");
|
|
6428
6455
|
if (!import_fs_extra13.default.existsSync(envFile)) {
|
|
6429
6456
|
logger.info(`Adding .env file to your project... \u2705`);
|
|
6430
6457
|
import_fs_extra13.default.writeFileSync(envFile, envFileText);
|
|
@@ -6470,7 +6497,8 @@ var other = ({ packageManager }) => {
|
|
|
6470
6497
|
pnpm: `pnpm`,
|
|
6471
6498
|
npm: `npx`,
|
|
6472
6499
|
// npx is the way to run executables that aren't in your "scripts"
|
|
6473
|
-
yarn: `yarn
|
|
6500
|
+
yarn: `yarn`,
|
|
6501
|
+
bun: `bun run`
|
|
6474
6502
|
};
|
|
6475
6503
|
return `${packageManagers[packageManager]} tinacms dev -c "<your dev command>"`;
|
|
6476
6504
|
};
|
|
@@ -6483,7 +6511,8 @@ var frameworkDevCmds = {
|
|
|
6483
6511
|
pnpm: `pnpm`,
|
|
6484
6512
|
npm: `npm run`,
|
|
6485
6513
|
// npx is the way to run executables that aren't in your "scripts"
|
|
6486
|
-
yarn: `yarn
|
|
6514
|
+
yarn: `yarn`,
|
|
6515
|
+
bun: `bun run`
|
|
6487
6516
|
};
|
|
6488
6517
|
return `${packageManagers[packageManager]} dev`;
|
|
6489
6518
|
}
|
|
@@ -6496,12 +6525,11 @@ var addReactiveFile = {
|
|
|
6496
6525
|
baseDir,
|
|
6497
6526
|
dataLayer
|
|
6498
6527
|
}) => {
|
|
6499
|
-
|
|
6500
|
-
const packageJsonPath = import_path11.default.join(baseDir, "package.json");
|
|
6528
|
+
const packageJsonPath = import_path13.default.join(baseDir, "package.json");
|
|
6501
6529
|
await writeGeneratedFile({
|
|
6502
6530
|
generatedFile,
|
|
6503
6531
|
typescript: config2.typescript,
|
|
6504
|
-
overwrite:
|
|
6532
|
+
overwrite: config2.overwriteList?.includes(
|
|
6505
6533
|
generatedFile.generatedFileType
|
|
6506
6534
|
),
|
|
6507
6535
|
content: templates["demo-post-page"]({
|
|
@@ -6517,7 +6545,7 @@ var addReactiveFile = {
|
|
|
6517
6545
|
...packageJson,
|
|
6518
6546
|
scripts: extendNextScripts(scripts, {
|
|
6519
6547
|
isLocalEnvVarName: config2.isLocalEnvVarName,
|
|
6520
|
-
addSetupUsers:
|
|
6548
|
+
addSetupUsers: config2.authProvider?.name === "next-auth"
|
|
6521
6549
|
})
|
|
6522
6550
|
},
|
|
6523
6551
|
null,
|
|
@@ -6592,6 +6620,15 @@ var InitCommand = class extends import_clipanion6.Command {
|
|
|
6592
6620
|
description: "Specify a version for tina dependencies"
|
|
6593
6621
|
});
|
|
6594
6622
|
}
|
|
6623
|
+
static {
|
|
6624
|
+
this.paths = [["init"], ["init", "backend"]];
|
|
6625
|
+
}
|
|
6626
|
+
static {
|
|
6627
|
+
this.usage = import_clipanion6.Command.Usage({
|
|
6628
|
+
category: `Commands`,
|
|
6629
|
+
description: `Add Tina to an existing project`
|
|
6630
|
+
});
|
|
6631
|
+
}
|
|
6595
6632
|
async catch(error) {
|
|
6596
6633
|
logger.error("Error occured during tinacms init");
|
|
6597
6634
|
console.error(error);
|
|
@@ -6611,11 +6648,6 @@ var InitCommand = class extends import_clipanion6.Command {
|
|
|
6611
6648
|
process.exit();
|
|
6612
6649
|
}
|
|
6613
6650
|
};
|
|
6614
|
-
InitCommand.paths = [["init"], ["init", "backend"]];
|
|
6615
|
-
InitCommand.usage = import_clipanion6.Command.Usage({
|
|
6616
|
-
category: `Commands`,
|
|
6617
|
-
description: `Add Tina to an existing project`
|
|
6618
|
-
});
|
|
6619
6651
|
|
|
6620
6652
|
// src/next/commands/searchindex-command/index.ts
|
|
6621
6653
|
var import_clipanion7 = require("clipanion");
|
|
@@ -6631,13 +6663,21 @@ var SearchIndexCommand = class extends import_clipanion7.Command {
|
|
|
6631
6663
|
description: "increase verbosity of logged output"
|
|
6632
6664
|
});
|
|
6633
6665
|
}
|
|
6666
|
+
static {
|
|
6667
|
+
this.paths = [["search-index"]];
|
|
6668
|
+
}
|
|
6669
|
+
static {
|
|
6670
|
+
this.usage = import_clipanion7.Command.Usage({
|
|
6671
|
+
category: `Commands`,
|
|
6672
|
+
description: `Index the site for search`
|
|
6673
|
+
});
|
|
6674
|
+
}
|
|
6634
6675
|
async catch(error) {
|
|
6635
6676
|
logger.error("Error occured during tinacms search-index");
|
|
6636
6677
|
console.error(error);
|
|
6637
6678
|
process.exit(1);
|
|
6638
6679
|
}
|
|
6639
6680
|
async execute() {
|
|
6640
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u;
|
|
6641
6681
|
const rootPath = this.rootPath || process.cwd();
|
|
6642
6682
|
const configManager = new ConfigManager({ rootPath });
|
|
6643
6683
|
try {
|
|
@@ -6648,7 +6688,7 @@ var SearchIndexCommand = class extends import_clipanion7.Command {
|
|
|
6648
6688
|
console.error(e);
|
|
6649
6689
|
}
|
|
6650
6690
|
}
|
|
6651
|
-
if (!
|
|
6691
|
+
if (!configManager.config?.search) {
|
|
6652
6692
|
logger.error("No search config found");
|
|
6653
6693
|
process.exit(1);
|
|
6654
6694
|
}
|
|
@@ -6657,9 +6697,9 @@ var SearchIndexCommand = class extends import_clipanion7.Command {
|
|
|
6657
6697
|
schema: { ...schema, config: configManager.config }
|
|
6658
6698
|
});
|
|
6659
6699
|
let client;
|
|
6660
|
-
const hasTinaSearch = Boolean(
|
|
6700
|
+
const hasTinaSearch = Boolean(configManager.config?.search?.tina);
|
|
6661
6701
|
if (hasTinaSearch) {
|
|
6662
|
-
if (!
|
|
6702
|
+
if (!configManager.config?.branch) {
|
|
6663
6703
|
logger.error(
|
|
6664
6704
|
`${dangerText(
|
|
6665
6705
|
`ERROR: Branch not configured in tina search configuration.`
|
|
@@ -6667,11 +6707,11 @@ var SearchIndexCommand = class extends import_clipanion7.Command {
|
|
|
6667
6707
|
);
|
|
6668
6708
|
throw new Error("Branch not configured in tina search configuration.");
|
|
6669
6709
|
}
|
|
6670
|
-
if (!
|
|
6710
|
+
if (!configManager.config?.clientId) {
|
|
6671
6711
|
logger.error(`${dangerText(`ERROR: clientId not configured.`)}`);
|
|
6672
6712
|
throw new Error("clientId not configured.");
|
|
6673
6713
|
}
|
|
6674
|
-
if (!
|
|
6714
|
+
if (!configManager.config?.search?.tina?.indexerToken) {
|
|
6675
6715
|
logger.error(
|
|
6676
6716
|
`${dangerText(
|
|
6677
6717
|
`ERROR: indexerToken not configured in tina search configuration.`
|
|
@@ -6682,22 +6722,22 @@ var SearchIndexCommand = class extends import_clipanion7.Command {
|
|
|
6682
6722
|
);
|
|
6683
6723
|
}
|
|
6684
6724
|
client = new import_search3.TinaCMSSearchIndexClient({
|
|
6685
|
-
apiUrl: `${
|
|
6686
|
-
branch:
|
|
6687
|
-
indexerToken:
|
|
6688
|
-
stopwordLanguages:
|
|
6725
|
+
apiUrl: `${configManager.config.tinaioConfig?.contentApiUrlOverride || "https://content.tinajs.io"}/searchIndex/${configManager.config?.clientId}`,
|
|
6726
|
+
branch: configManager.config?.branch,
|
|
6727
|
+
indexerToken: configManager.config?.search?.tina?.indexerToken,
|
|
6728
|
+
stopwordLanguages: configManager.config?.search?.tina?.stopwordLanguages
|
|
6689
6729
|
});
|
|
6690
6730
|
} else {
|
|
6691
|
-
client =
|
|
6731
|
+
client = configManager.config?.search?.searchClient;
|
|
6692
6732
|
}
|
|
6693
6733
|
const searchIndexer = new import_search3.SearchIndexer({
|
|
6694
|
-
batchSize:
|
|
6734
|
+
batchSize: configManager.config.search?.indexBatchSize || 100,
|
|
6695
6735
|
bridge: new import_graphql17.FilesystemBridge(
|
|
6696
6736
|
configManager.rootPath,
|
|
6697
6737
|
configManager.contentRootPath
|
|
6698
6738
|
),
|
|
6699
6739
|
schema: tinaSchema,
|
|
6700
|
-
textIndexLength:
|
|
6740
|
+
textIndexLength: configManager.config.search?.maxSearchIndexFieldLength || 100,
|
|
6701
6741
|
client
|
|
6702
6742
|
});
|
|
6703
6743
|
let err;
|
|
@@ -6718,11 +6758,6 @@ var SearchIndexCommand = class extends import_clipanion7.Command {
|
|
|
6718
6758
|
process.exit(0);
|
|
6719
6759
|
}
|
|
6720
6760
|
};
|
|
6721
|
-
SearchIndexCommand.paths = [["search-index"]];
|
|
6722
|
-
SearchIndexCommand.usage = import_clipanion7.Command.Usage({
|
|
6723
|
-
category: `Commands`,
|
|
6724
|
-
description: `Index the site for search`
|
|
6725
|
-
});
|
|
6726
6761
|
|
|
6727
6762
|
// src/index.ts
|
|
6728
6763
|
var cli = new import_clipanion8.Cli({
|