@tinacms/cli 1.0.4 → 1.0.6
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.
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
Copyright 2021 Forestry.io Holdings, Inc.
|
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
you may not use this file except in compliance with the License.
|
|
5
|
+
You may obtain a copy of the License at
|
|
6
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
Unless required by applicable law or agreed to in writing, software
|
|
8
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
9
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
10
|
+
See the License for the specific language governing permissions and
|
|
11
|
+
limitations under the License.
|
|
12
|
+
*/
|
|
13
|
+
import type { TinaCloudCollection } from '@tinacms/schema-tools';
|
|
14
|
+
export declare const generateCollections: ({ forestryPath, rootPath, }: {
|
|
15
|
+
forestryPath: string;
|
|
16
|
+
rootPath: string;
|
|
17
|
+
}) => Promise<TinaCloudCollection<false>[]>;
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
/**
|
|
2
|
+
Copyright 2021 Forestry.io Holdings, Inc.
|
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
you may not use this file except in compliance with the License.
|
|
5
|
+
You may obtain a copy of the License at
|
|
6
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
Unless required by applicable law or agreed to in writing, software
|
|
8
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
9
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
10
|
+
See the License for the specific language governing permissions and
|
|
11
|
+
limitations under the License.
|
|
12
|
+
*/
|
|
13
|
+
import z from 'zod';
|
|
14
|
+
import type { TinaFieldInner } from '@tinacms/schema-tools';
|
|
15
|
+
declare const forestryFieldWithoutField: z.ZodObject<{
|
|
16
|
+
type: z.ZodUnion<[z.ZodLiteral<"text">, z.ZodLiteral<"datetime">, z.ZodLiteral<"list">, z.ZodLiteral<"file">, z.ZodLiteral<"image_gallery">, z.ZodLiteral<"textarea">, z.ZodLiteral<"tag_list">, z.ZodLiteral<"number">, z.ZodLiteral<"boolean">, z.ZodLiteral<"field_group">, z.ZodLiteral<"field_group_list">, z.ZodLiteral<"select">, z.ZodLiteral<"include">, z.ZodLiteral<"blocks">, z.ZodLiteral<"color">]>;
|
|
17
|
+
name: z.ZodString;
|
|
18
|
+
label: z.ZodString;
|
|
19
|
+
default: z.ZodOptional<z.ZodAny>;
|
|
20
|
+
config: z.ZodOptional<z.ZodObject<{
|
|
21
|
+
required: z.ZodOptional<z.ZodBoolean>;
|
|
22
|
+
use_select: z.ZodOptional<z.ZodBoolean>;
|
|
23
|
+
date_format: z.ZodOptional<z.ZodString>;
|
|
24
|
+
time_format: z.ZodOptional<z.ZodString>;
|
|
25
|
+
options: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
26
|
+
source: z.ZodOptional<z.ZodObject<{
|
|
27
|
+
type: z.ZodOptional<z.ZodUnion<[z.ZodLiteral<"custom">, z.ZodLiteral<"pages">, z.ZodLiteral<"documents">, z.ZodLiteral<"simple">, z.ZodString]>>;
|
|
28
|
+
section: z.ZodOptional<z.ZodString>;
|
|
29
|
+
}, "strip", z.ZodTypeAny, {
|
|
30
|
+
type?: string;
|
|
31
|
+
section?: string;
|
|
32
|
+
}, {
|
|
33
|
+
type?: string;
|
|
34
|
+
section?: string;
|
|
35
|
+
}>>;
|
|
36
|
+
}, "strip", z.ZodTypeAny, {
|
|
37
|
+
required?: boolean;
|
|
38
|
+
options?: string[];
|
|
39
|
+
use_select?: boolean;
|
|
40
|
+
date_format?: string;
|
|
41
|
+
time_format?: string;
|
|
42
|
+
source?: {
|
|
43
|
+
type?: string;
|
|
44
|
+
section?: string;
|
|
45
|
+
};
|
|
46
|
+
}, {
|
|
47
|
+
required?: boolean;
|
|
48
|
+
options?: string[];
|
|
49
|
+
use_select?: boolean;
|
|
50
|
+
date_format?: string;
|
|
51
|
+
time_format?: string;
|
|
52
|
+
source?: {
|
|
53
|
+
type?: string;
|
|
54
|
+
section?: string;
|
|
55
|
+
};
|
|
56
|
+
}>>;
|
|
57
|
+
}, "strip", z.ZodTypeAny, {
|
|
58
|
+
default?: any;
|
|
59
|
+
label?: string;
|
|
60
|
+
config?: {
|
|
61
|
+
required?: boolean;
|
|
62
|
+
options?: string[];
|
|
63
|
+
use_select?: boolean;
|
|
64
|
+
date_format?: string;
|
|
65
|
+
time_format?: string;
|
|
66
|
+
source?: {
|
|
67
|
+
type?: string;
|
|
68
|
+
section?: string;
|
|
69
|
+
};
|
|
70
|
+
};
|
|
71
|
+
name?: string;
|
|
72
|
+
type?: "number" | "boolean" | "file" | "datetime" | "text" | "list" | "select" | "image_gallery" | "textarea" | "tag_list" | "field_group" | "field_group_list" | "include" | "blocks" | "color";
|
|
73
|
+
}, {
|
|
74
|
+
default?: any;
|
|
75
|
+
label?: string;
|
|
76
|
+
config?: {
|
|
77
|
+
required?: boolean;
|
|
78
|
+
options?: string[];
|
|
79
|
+
use_select?: boolean;
|
|
80
|
+
date_format?: string;
|
|
81
|
+
time_format?: string;
|
|
82
|
+
source?: {
|
|
83
|
+
type?: string;
|
|
84
|
+
section?: string;
|
|
85
|
+
};
|
|
86
|
+
};
|
|
87
|
+
name?: string;
|
|
88
|
+
type?: "number" | "boolean" | "file" | "datetime" | "text" | "list" | "select" | "image_gallery" | "textarea" | "tag_list" | "field_group" | "field_group_list" | "include" | "blocks" | "color";
|
|
89
|
+
}>;
|
|
90
|
+
declare type ForestryFieldWithoutFieldType = z.infer<typeof forestryFieldWithoutField>;
|
|
91
|
+
interface ForestryFieldType extends ForestryFieldWithoutFieldType {
|
|
92
|
+
fields?: ForestryFieldType[];
|
|
93
|
+
}
|
|
94
|
+
declare const FrontmatterTemplateSchema: z.ZodObject<{
|
|
95
|
+
label: z.ZodString;
|
|
96
|
+
hide_body: z.ZodOptional<z.ZodBoolean>;
|
|
97
|
+
fields: z.ZodOptional<z.ZodArray<z.ZodType<ForestryFieldType, z.ZodTypeDef, ForestryFieldType>, "many">>;
|
|
98
|
+
}, "strip", z.ZodTypeAny, {
|
|
99
|
+
label?: string;
|
|
100
|
+
fields?: ForestryFieldType[];
|
|
101
|
+
hide_body?: boolean;
|
|
102
|
+
}, {
|
|
103
|
+
label?: string;
|
|
104
|
+
fields?: ForestryFieldType[];
|
|
105
|
+
hide_body?: boolean;
|
|
106
|
+
}>;
|
|
107
|
+
export declare const transformForestryFieldsToTinaFields: ({ fields, collection, }: {
|
|
108
|
+
fields: z.infer<typeof FrontmatterTemplateSchema>['fields'];
|
|
109
|
+
collection: string;
|
|
110
|
+
}) => TinaFieldInner<false>[];
|
|
111
|
+
export declare const getFieldsFromTemplates: ({ tem, rootPath, collection, }: {
|
|
112
|
+
tem: string;
|
|
113
|
+
collection: string;
|
|
114
|
+
rootPath: string;
|
|
115
|
+
}) => TinaFieldInner<false>[];
|
|
116
|
+
export declare const parseTemplates: ({ val }: {
|
|
117
|
+
val: unknown;
|
|
118
|
+
}) => {
|
|
119
|
+
label?: string;
|
|
120
|
+
fields?: ForestryFieldType[];
|
|
121
|
+
hide_body?: boolean;
|
|
122
|
+
};
|
|
123
|
+
export declare const hasForestryConfig: ({ rootPath }: {
|
|
124
|
+
rootPath: string;
|
|
125
|
+
}) => Promise<{
|
|
126
|
+
path: string;
|
|
127
|
+
exists: boolean;
|
|
128
|
+
}>;
|
|
129
|
+
export declare const parseSections: ({ val }: {
|
|
130
|
+
val: unknown;
|
|
131
|
+
}) => {
|
|
132
|
+
sections?: {
|
|
133
|
+
label?: string;
|
|
134
|
+
path?: string;
|
|
135
|
+
type?: "directory" | "document" | "heading" | "jekyll-pages" | "jekyll-posts";
|
|
136
|
+
match?: string;
|
|
137
|
+
exclude?: string;
|
|
138
|
+
create?: "documents" | "all" | "none";
|
|
139
|
+
templates?: string[];
|
|
140
|
+
new_doc_ext?: string;
|
|
141
|
+
read_only?: boolean;
|
|
142
|
+
}[];
|
|
143
|
+
};
|
|
144
|
+
export {};
|
|
@@ -1,4 +1,17 @@
|
|
|
1
|
+
export interface Framework {
|
|
2
|
+
name: 'next' | 'hugo' | 'jekyll' | 'other';
|
|
3
|
+
reactive: boolean;
|
|
4
|
+
}
|
|
1
5
|
export declare function initStaticTina(ctx: any, next: () => void, options: any): Promise<void>;
|
|
6
|
+
export interface AddConfigArgs {
|
|
7
|
+
publicFolder: string;
|
|
8
|
+
baseDir: string;
|
|
9
|
+
usingTypescript: boolean;
|
|
10
|
+
framework: Framework;
|
|
11
|
+
collections?: string;
|
|
12
|
+
token?: string;
|
|
13
|
+
clientId?: string;
|
|
14
|
+
}
|
|
2
15
|
/**
|
|
3
16
|
* Executes a shell command and return it as a Promise.
|
|
4
17
|
* @param cmd {string}
|
|
@@ -10,9 +10,9 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
10
10
|
See the License for the specific language governing permissions and
|
|
11
11
|
limitations under the License.
|
|
12
12
|
*/
|
|
13
|
+
import type { AddConfigArgs, Framework } from '..';
|
|
14
|
+
declare type Keys = Framework['name'];
|
|
13
15
|
export declare const configExamples: {
|
|
14
|
-
|
|
15
|
-
other: (args: {
|
|
16
|
-
publicFolder: string;
|
|
17
|
-
}) => string;
|
|
16
|
+
[key in Keys]: (args?: AddConfigArgs) => string;
|
|
18
17
|
};
|
|
18
|
+
export {};
|
package/dist/index.js
CHANGED
|
@@ -302,7 +302,7 @@ var commander = __toModule(require("commander"));
|
|
|
302
302
|
|
|
303
303
|
// package.json
|
|
304
304
|
var name = "@tinacms/cli";
|
|
305
|
-
var version = "1.0.
|
|
305
|
+
var version = "1.0.6";
|
|
306
306
|
|
|
307
307
|
// src/cmds/audit/audit.ts
|
|
308
308
|
var import_graphql = __toModule(require("@tinacms/graphql"));
|
|
@@ -626,9 +626,9 @@ var fileExists = ({
|
|
|
626
626
|
}
|
|
627
627
|
const filePaths = allowedTypes.map((ext) => import_path2.default.join(projectDir, `${filename}.${ext}`));
|
|
628
628
|
let inputFile = void 0;
|
|
629
|
-
filePaths.every((
|
|
630
|
-
if (import_fs_extra.default.existsSync(
|
|
631
|
-
inputFile =
|
|
629
|
+
filePaths.every((path10) => {
|
|
630
|
+
if (import_fs_extra.default.existsSync(path10)) {
|
|
631
|
+
inputFile = path10;
|
|
632
632
|
return false;
|
|
633
633
|
}
|
|
634
634
|
return true;
|
|
@@ -646,9 +646,9 @@ var getPath = ({
|
|
|
646
646
|
}
|
|
647
647
|
const filePaths = allowedTypes.map((ext) => import_path2.default.join(projectDir, `${filename}.${ext}`));
|
|
648
648
|
let inputFile = void 0;
|
|
649
|
-
filePaths.every((
|
|
650
|
-
if (import_fs_extra.default.existsSync(
|
|
651
|
-
inputFile =
|
|
649
|
+
filePaths.every((path10) => {
|
|
650
|
+
if (import_fs_extra.default.existsSync(path10)) {
|
|
651
|
+
inputFile = path10;
|
|
652
652
|
return false;
|
|
653
653
|
}
|
|
654
654
|
return true;
|
|
@@ -1391,13 +1391,14 @@ var buildAdmin = async ({
|
|
|
1391
1391
|
var _a;
|
|
1392
1392
|
if ((_a = schema == null ? void 0 : schema.config) == null ? void 0 : _a.build) {
|
|
1393
1393
|
const buildVite = async () => {
|
|
1394
|
-
var _a2, _b, _c, _d;
|
|
1394
|
+
var _a2, _b, _c, _d, _e, _f, _g;
|
|
1395
1395
|
await (0, import_app.viteBuild)({
|
|
1396
1396
|
local,
|
|
1397
1397
|
rootPath: rootPath2,
|
|
1398
1398
|
outputFolder: (_b = (_a2 = schema == null ? void 0 : schema.config) == null ? void 0 : _a2.build) == null ? void 0 : _b.outputFolder,
|
|
1399
1399
|
publicFolder: (_d = (_c = schema == null ? void 0 : schema.config) == null ? void 0 : _c.build) == null ? void 0 : _d.publicFolder,
|
|
1400
|
-
apiUrl
|
|
1400
|
+
apiUrl,
|
|
1401
|
+
host: (_g = (_f = (_e = schema == null ? void 0 : schema.config) == null ? void 0 : _e.build) == null ? void 0 : _f.host) != null ? _g : false
|
|
1401
1402
|
});
|
|
1402
1403
|
};
|
|
1403
1404
|
if (local) {
|
|
@@ -1727,8 +1728,9 @@ stack: ${code.stack || "No stack was provided"}`);
|
|
|
1727
1728
|
};
|
|
1728
1729
|
|
|
1729
1730
|
// src/cmds/init/index.ts
|
|
1730
|
-
var
|
|
1731
|
-
var
|
|
1731
|
+
var import_path13 = __toModule(require("path"));
|
|
1732
|
+
var import_prettier = __toModule(require("prettier"));
|
|
1733
|
+
var import_fs_extra10 = __toModule(require("fs-extra"));
|
|
1732
1734
|
var import_prompts2 = __toModule(require("prompts"));
|
|
1733
1735
|
var import_metrics3 = __toModule(require("@tinacms/metrics"));
|
|
1734
1736
|
|
|
@@ -1966,28 +1968,76 @@ function extendNextScripts(scripts) {
|
|
|
1966
1968
|
}
|
|
1967
1969
|
|
|
1968
1970
|
// src/cmds/init/setup-files/config.ts
|
|
1971
|
+
var other = (args) => {
|
|
1972
|
+
return `
|
|
1973
|
+
import { defineConfig } from "tinacms";
|
|
1974
|
+
|
|
1975
|
+
// Your hosting provider likely exposes this as an environment variable
|
|
1976
|
+
const branch = process.env.HEAD || process.env.VERCEL_GIT_COMMIT_REF || "main";
|
|
1977
|
+
|
|
1978
|
+
export default defineConfig({
|
|
1979
|
+
branch,
|
|
1980
|
+
clientId: ${args.clientId ? `'${args.clientId}'` : "null"}, // Get this from tina.io
|
|
1981
|
+
token: ${args.token ? `'${args.token}'` : "null"}, // Get this from tina.io
|
|
1982
|
+
build: {
|
|
1983
|
+
outputFolder: "admin",
|
|
1984
|
+
publicFolder: "${args.publicFolder}",
|
|
1985
|
+
},
|
|
1986
|
+
media: {
|
|
1987
|
+
tina: {
|
|
1988
|
+
mediaRoot: "",
|
|
1989
|
+
publicFolder: "${args.publicFolder}",
|
|
1990
|
+
},
|
|
1991
|
+
},
|
|
1992
|
+
schema: {
|
|
1993
|
+
collections: ${args.collections || `[
|
|
1994
|
+
{
|
|
1995
|
+
name: "post",
|
|
1996
|
+
label: "Posts",
|
|
1997
|
+
path: "content/posts",
|
|
1998
|
+
fields: [
|
|
1999
|
+
{
|
|
2000
|
+
type: "string",
|
|
2001
|
+
name: "title",
|
|
2002
|
+
label: "Title",
|
|
2003
|
+
isTitle: true,
|
|
2004
|
+
required: true,
|
|
2005
|
+
},
|
|
2006
|
+
{
|
|
2007
|
+
type: "rich-text",
|
|
2008
|
+
name: "body",
|
|
2009
|
+
label: "Body",
|
|
2010
|
+
isBody: true,
|
|
2011
|
+
},
|
|
2012
|
+
],
|
|
2013
|
+
},
|
|
2014
|
+
]`},
|
|
2015
|
+
},
|
|
2016
|
+
});
|
|
2017
|
+
`;
|
|
2018
|
+
};
|
|
1969
2019
|
var configExamples = {
|
|
1970
|
-
next: () => `import { defineConfig } from 'tinacms'
|
|
2020
|
+
next: (args) => `import { defineConfig } from 'tinacms'
|
|
1971
2021
|
|
|
1972
2022
|
// Your hosting provider likely exposes this as an environment variable
|
|
1973
2023
|
const branch = process.env.HEAD || process.env.VERCEL_GIT_COMMIT_REF || 'main'
|
|
1974
2024
|
|
|
1975
2025
|
export default defineConfig({
|
|
1976
2026
|
branch,
|
|
1977
|
-
clientId: null, // Get this from tina.io
|
|
1978
|
-
token: null, // Get this from tina.io
|
|
2027
|
+
clientId: ${args.clientId ? `'${args.clientId}'` : "null"}, // Get this from tina.io
|
|
2028
|
+
token: ${args.token ? `'${args.token}'` : "null"}, // Get this from tina.io
|
|
1979
2029
|
build: {
|
|
1980
|
-
outputFolder:
|
|
1981
|
-
publicFolder:
|
|
2030
|
+
outputFolder: "admin",
|
|
2031
|
+
publicFolder: "${args.publicFolder}",
|
|
1982
2032
|
},
|
|
1983
2033
|
media: {
|
|
1984
2034
|
tina: {
|
|
1985
|
-
mediaRoot:
|
|
1986
|
-
publicFolder:
|
|
2035
|
+
mediaRoot: "",
|
|
2036
|
+
publicFolder: "${args.publicFolder}",
|
|
1987
2037
|
},
|
|
1988
2038
|
},
|
|
1989
2039
|
schema: {
|
|
1990
|
-
collections
|
|
2040
|
+
collections:${args.collections || `[
|
|
1991
2041
|
{
|
|
1992
2042
|
name: 'post',
|
|
1993
2043
|
label: 'Posts',
|
|
@@ -2012,74 +2062,387 @@ var configExamples = {
|
|
|
2012
2062
|
router: ({ document }) => \`/demo/blog/\${document._sys.filename}\`,
|
|
2013
2063
|
},
|
|
2014
2064
|
},
|
|
2015
|
-
],
|
|
2065
|
+
]`},
|
|
2016
2066
|
},
|
|
2017
2067
|
})
|
|
2018
2068
|
`,
|
|
2019
|
-
other
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2069
|
+
other,
|
|
2070
|
+
hugo: other,
|
|
2071
|
+
jekyll: other
|
|
2072
|
+
};
|
|
2073
|
+
|
|
2074
|
+
// src/cmds/forestry-migrate/util/index.ts
|
|
2075
|
+
var import_fs_extra8 = __toModule(require("fs-extra"));
|
|
2076
|
+
var import_path12 = __toModule(require("path"));
|
|
2077
|
+
var import_js_yaml = __toModule(require("js-yaml"));
|
|
2078
|
+
var import_zod = __toModule(require("zod"));
|
|
2079
|
+
var forestryConfigSchema = import_zod.default.object({
|
|
2080
|
+
sections: import_zod.default.array(import_zod.default.object({
|
|
2081
|
+
type: import_zod.default.union([
|
|
2082
|
+
import_zod.default.literal("directory"),
|
|
2083
|
+
import_zod.default.literal("document"),
|
|
2084
|
+
import_zod.default.literal("heading"),
|
|
2085
|
+
import_zod.default.literal("jekyll-pages"),
|
|
2086
|
+
import_zod.default.literal("jekyll-posts")
|
|
2087
|
+
]),
|
|
2088
|
+
label: import_zod.default.string(),
|
|
2089
|
+
path: import_zod.default.string().optional(),
|
|
2090
|
+
match: import_zod.default.string().optional(),
|
|
2091
|
+
exclude: import_zod.default.string().optional(),
|
|
2092
|
+
create: import_zod.default.union([import_zod.default.literal("all"), import_zod.default.literal("documents"), import_zod.default.literal("none")]).optional(),
|
|
2093
|
+
templates: import_zod.default.array(import_zod.default.string()).optional(),
|
|
2094
|
+
new_doc_ext: import_zod.default.string().optional(),
|
|
2095
|
+
read_only: import_zod.default.boolean().optional()
|
|
2096
|
+
}))
|
|
2097
|
+
});
|
|
2098
|
+
var forestryFieldWithoutField = import_zod.default.object({
|
|
2099
|
+
type: import_zod.default.union([
|
|
2100
|
+
import_zod.default.literal("text"),
|
|
2101
|
+
import_zod.default.literal("datetime"),
|
|
2102
|
+
import_zod.default.literal("list"),
|
|
2103
|
+
import_zod.default.literal("file"),
|
|
2104
|
+
import_zod.default.literal("image_gallery"),
|
|
2105
|
+
import_zod.default.literal("textarea"),
|
|
2106
|
+
import_zod.default.literal("tag_list"),
|
|
2107
|
+
import_zod.default.literal("number"),
|
|
2108
|
+
import_zod.default.literal("boolean"),
|
|
2109
|
+
import_zod.default.literal("field_group"),
|
|
2110
|
+
import_zod.default.literal("field_group_list"),
|
|
2111
|
+
import_zod.default.literal("select"),
|
|
2112
|
+
import_zod.default.literal("include"),
|
|
2113
|
+
import_zod.default.literal("blocks"),
|
|
2114
|
+
import_zod.default.literal("color")
|
|
2115
|
+
]),
|
|
2116
|
+
name: import_zod.default.string(),
|
|
2117
|
+
label: import_zod.default.string(),
|
|
2118
|
+
default: import_zod.default.any().optional(),
|
|
2119
|
+
config: import_zod.default.object({
|
|
2120
|
+
required: import_zod.default.boolean().optional(),
|
|
2121
|
+
use_select: import_zod.default.boolean().optional(),
|
|
2122
|
+
date_format: import_zod.default.string().optional(),
|
|
2123
|
+
time_format: import_zod.default.string().optional(),
|
|
2124
|
+
options: import_zod.default.array(import_zod.default.string()).optional(),
|
|
2125
|
+
source: import_zod.default.object({
|
|
2126
|
+
type: import_zod.default.union([
|
|
2127
|
+
import_zod.default.literal("custom"),
|
|
2128
|
+
import_zod.default.literal("pages"),
|
|
2129
|
+
import_zod.default.literal("documents"),
|
|
2130
|
+
import_zod.default.literal("simple"),
|
|
2131
|
+
import_zod.default.string()
|
|
2132
|
+
]).optional(),
|
|
2133
|
+
section: import_zod.default.string().optional()
|
|
2134
|
+
}).optional()
|
|
2135
|
+
}).optional()
|
|
2136
|
+
});
|
|
2137
|
+
var forestryField = import_zod.default.lazy(() => forestryFieldWithoutField.extend({
|
|
2138
|
+
fields: import_zod.default.array(forestryField).optional()
|
|
2139
|
+
}));
|
|
2140
|
+
var FrontmatterTemplateSchema = import_zod.default.object({
|
|
2141
|
+
label: import_zod.default.string(),
|
|
2142
|
+
hide_body: import_zod.default.boolean().optional(),
|
|
2143
|
+
fields: import_zod.default.array(forestryField).optional()
|
|
2144
|
+
});
|
|
2145
|
+
var transformForestryFieldsToTinaFields = ({
|
|
2146
|
+
fields,
|
|
2147
|
+
collection
|
|
2148
|
+
}) => {
|
|
2149
|
+
const tinaFields = [];
|
|
2150
|
+
fields == null ? void 0 : fields.forEach((forestryField2) => {
|
|
2151
|
+
var _a, _b, _c, _d;
|
|
2152
|
+
let field;
|
|
2153
|
+
switch (forestryField2.type) {
|
|
2154
|
+
case "text":
|
|
2155
|
+
field = {
|
|
2156
|
+
type: "string",
|
|
2157
|
+
name: forestryField2.name,
|
|
2158
|
+
label: forestryField2.label
|
|
2159
|
+
};
|
|
2160
|
+
break;
|
|
2161
|
+
case "textarea":
|
|
2162
|
+
field = {
|
|
2163
|
+
type: "string",
|
|
2164
|
+
name: forestryField2.name,
|
|
2165
|
+
label: forestryField2.label,
|
|
2166
|
+
ui: {
|
|
2167
|
+
component: "textarea"
|
|
2168
|
+
}
|
|
2169
|
+
};
|
|
2170
|
+
break;
|
|
2171
|
+
case "datetime":
|
|
2172
|
+
field = {
|
|
2173
|
+
type: forestryField2.type,
|
|
2174
|
+
name: forestryField2.name,
|
|
2175
|
+
label: forestryField2.label
|
|
2176
|
+
};
|
|
2177
|
+
break;
|
|
2178
|
+
case "number":
|
|
2179
|
+
field = {
|
|
2180
|
+
type: "number",
|
|
2181
|
+
name: forestryField2.name,
|
|
2182
|
+
label: forestryField2.label
|
|
2183
|
+
};
|
|
2184
|
+
break;
|
|
2185
|
+
case "boolean":
|
|
2186
|
+
field = {
|
|
2187
|
+
type: "boolean",
|
|
2188
|
+
name: forestryField2.name,
|
|
2189
|
+
label: forestryField2.label
|
|
2190
|
+
};
|
|
2191
|
+
break;
|
|
2192
|
+
case "color":
|
|
2193
|
+
field = {
|
|
2194
|
+
type: "string",
|
|
2195
|
+
name: forestryField2.name,
|
|
2196
|
+
label: forestryField2.label,
|
|
2197
|
+
ui: {
|
|
2198
|
+
component: "color"
|
|
2199
|
+
}
|
|
2200
|
+
};
|
|
2201
|
+
break;
|
|
2202
|
+
case "file":
|
|
2203
|
+
field = {
|
|
2204
|
+
type: "image",
|
|
2205
|
+
name: forestryField2.name || "image",
|
|
2206
|
+
label: forestryField2.label
|
|
2207
|
+
};
|
|
2208
|
+
break;
|
|
2209
|
+
case "select":
|
|
2210
|
+
if ((_a = forestryField2.config) == null ? void 0 : _a.options) {
|
|
2211
|
+
field = {
|
|
2212
|
+
type: "string",
|
|
2213
|
+
name: forestryField2.name,
|
|
2214
|
+
label: forestryField2.label,
|
|
2215
|
+
options: ((_b = forestryField2.config) == null ? void 0 : _b.options) || []
|
|
2216
|
+
};
|
|
2217
|
+
} else {
|
|
2218
|
+
logger.info(`Warning in collection ${collection}. "select" field migration has only been implemented for simple select. Other versions of select have not been implemented yet. To make your \`${forestryField2.name}\` field work, you will need to manually add it to your schema.`);
|
|
2219
|
+
}
|
|
2220
|
+
break;
|
|
2221
|
+
case "list":
|
|
2222
|
+
field = {
|
|
2223
|
+
type: "string",
|
|
2224
|
+
name: forestryField2.name,
|
|
2225
|
+
label: forestryField2.label,
|
|
2226
|
+
list: true
|
|
2227
|
+
};
|
|
2228
|
+
if ((_c = forestryField2.config) == null ? void 0 : _c.options) {
|
|
2229
|
+
field.options = forestryField2.config.options;
|
|
2230
|
+
}
|
|
2231
|
+
break;
|
|
2232
|
+
case "tag_list":
|
|
2233
|
+
field = {
|
|
2234
|
+
type: "string",
|
|
2235
|
+
name: forestryField2.name,
|
|
2236
|
+
label: forestryField2.label,
|
|
2237
|
+
list: true,
|
|
2238
|
+
ui: {
|
|
2239
|
+
component: "tags"
|
|
2240
|
+
}
|
|
2241
|
+
};
|
|
2242
|
+
break;
|
|
2243
|
+
case "field_group":
|
|
2244
|
+
field = {
|
|
2245
|
+
type: "object",
|
|
2246
|
+
name: forestryField2.name,
|
|
2247
|
+
label: forestryField2.label,
|
|
2248
|
+
fields: transformForestryFieldsToTinaFields({
|
|
2249
|
+
fields: forestryField2.fields,
|
|
2250
|
+
collection
|
|
2251
|
+
})
|
|
2252
|
+
};
|
|
2253
|
+
break;
|
|
2254
|
+
case "field_group_list":
|
|
2255
|
+
field = {
|
|
2256
|
+
type: "object",
|
|
2257
|
+
name: forestryField2.name,
|
|
2258
|
+
label: forestryField2.label,
|
|
2259
|
+
list: true,
|
|
2260
|
+
fields: transformForestryFieldsToTinaFields({
|
|
2261
|
+
fields: forestryField2.fields,
|
|
2262
|
+
collection
|
|
2263
|
+
})
|
|
2264
|
+
};
|
|
2265
|
+
break;
|
|
2266
|
+
case "image_gallery":
|
|
2267
|
+
case "include":
|
|
2268
|
+
console.log(`Unsupported field type: ${forestryField2.type}, in collection ${collection}. This will not be added to the schema.`);
|
|
2269
|
+
break;
|
|
2270
|
+
default:
|
|
2271
|
+
logger.info(`Warning in collection ${collection}. "${forestryField2.type}" migration has not been implemented yet. To make your \`${forestryField2.name}\` field work, you will need to manually add it to your schema.`);
|
|
2272
|
+
}
|
|
2273
|
+
if (field) {
|
|
2274
|
+
if ((_d = forestryField2.config) == null ? void 0 : _d.required) {
|
|
2275
|
+
field = __spreadProps(__spreadValues({}, field), { required: true });
|
|
2276
|
+
}
|
|
2277
|
+
tinaFields.push(field);
|
|
2278
|
+
}
|
|
2064
2279
|
});
|
|
2065
|
-
|
|
2280
|
+
return tinaFields;
|
|
2281
|
+
};
|
|
2282
|
+
var getFieldsFromTemplates = ({
|
|
2283
|
+
tem,
|
|
2284
|
+
rootPath: rootPath2,
|
|
2285
|
+
collection
|
|
2286
|
+
}) => {
|
|
2287
|
+
const templatePath = import_path12.default.join(rootPath2, ".forestry", "front_matter", "templates", `${tem}.yml`);
|
|
2288
|
+
let templateString = "";
|
|
2289
|
+
try {
|
|
2290
|
+
templateString = import_fs_extra8.default.readFileSync(templatePath).toString();
|
|
2291
|
+
} catch {
|
|
2292
|
+
throw new Error(`Could not find template ${tem} at ${templatePath}
|
|
2293
|
+
|
|
2294
|
+
This will require manual migration.`);
|
|
2066
2295
|
}
|
|
2296
|
+
const templateObj = import_js_yaml.default.load(templateString);
|
|
2297
|
+
const template = parseTemplates({ val: templateObj });
|
|
2298
|
+
const fields = transformForestryFieldsToTinaFields({
|
|
2299
|
+
fields: template.fields,
|
|
2300
|
+
collection
|
|
2301
|
+
});
|
|
2302
|
+
return fields;
|
|
2303
|
+
};
|
|
2304
|
+
var parseTemplates = ({ val }) => {
|
|
2305
|
+
const template = FrontmatterTemplateSchema.parse(val);
|
|
2306
|
+
return template;
|
|
2307
|
+
};
|
|
2308
|
+
var hasForestryConfig = async ({ rootPath: rootPath2 }) => {
|
|
2309
|
+
const forestryPath = import_path12.default.join(rootPath2, ".forestry", "settings.yml");
|
|
2310
|
+
const exists = await import_fs_extra8.default.pathExists(forestryPath);
|
|
2311
|
+
return {
|
|
2312
|
+
path: forestryPath,
|
|
2313
|
+
exists
|
|
2314
|
+
};
|
|
2315
|
+
};
|
|
2316
|
+
var parseSections = ({ val }) => {
|
|
2317
|
+
const schema = forestryConfigSchema.parse(val);
|
|
2318
|
+
return schema;
|
|
2319
|
+
};
|
|
2320
|
+
|
|
2321
|
+
// src/cmds/forestry-migrate/index.ts
|
|
2322
|
+
var import_fs_extra9 = __toModule(require("fs-extra"));
|
|
2323
|
+
var import_js_yaml2 = __toModule(require("js-yaml"));
|
|
2324
|
+
var stringifyLabel = (label) => {
|
|
2325
|
+
return label.replace(/[^a-zA-Z0-9]/g, "_").toLowerCase();
|
|
2326
|
+
};
|
|
2327
|
+
var generateCollections = async ({
|
|
2328
|
+
forestryPath,
|
|
2329
|
+
rootPath: rootPath2
|
|
2330
|
+
}) => {
|
|
2331
|
+
var _a;
|
|
2332
|
+
const forestryConfig = await import_fs_extra9.default.readFile(forestryPath);
|
|
2333
|
+
const forestryYaml = import_js_yaml2.default.load(forestryConfig.toString());
|
|
2334
|
+
const forestrySchema = parseSections({ val: forestryYaml });
|
|
2335
|
+
const collections = [];
|
|
2336
|
+
(_a = forestrySchema.sections) == null ? void 0 : _a.forEach((section) => {
|
|
2337
|
+
var _a2, _b;
|
|
2338
|
+
if (section.read_only)
|
|
2339
|
+
return;
|
|
2340
|
+
switch (section.type) {
|
|
2341
|
+
case "directory":
|
|
2342
|
+
const fields = [
|
|
2343
|
+
{
|
|
2344
|
+
type: "rich-text",
|
|
2345
|
+
name: "body",
|
|
2346
|
+
label: "Body of Document",
|
|
2347
|
+
description: "This is the markdown body",
|
|
2348
|
+
isBody: true
|
|
2349
|
+
}
|
|
2350
|
+
];
|
|
2351
|
+
if ((((_a2 = section.templates) == null ? void 0 : _a2.length) || 0) > 1) {
|
|
2352
|
+
const templates = [];
|
|
2353
|
+
section.templates.forEach((tem) => {
|
|
2354
|
+
try {
|
|
2355
|
+
const fields2 = getFieldsFromTemplates({
|
|
2356
|
+
tem,
|
|
2357
|
+
collection: stringifyLabel(section.label),
|
|
2358
|
+
rootPath: rootPath2
|
|
2359
|
+
});
|
|
2360
|
+
templates.push({ fields: fields2, label: tem, name: stringifyLabel(tem) });
|
|
2361
|
+
} catch (e) {
|
|
2362
|
+
console.log("Error parsing template ", tem);
|
|
2363
|
+
console.error(e);
|
|
2364
|
+
}
|
|
2365
|
+
});
|
|
2366
|
+
const c = {
|
|
2367
|
+
label: section.label,
|
|
2368
|
+
name: stringifyLabel(section.label),
|
|
2369
|
+
path: section.path,
|
|
2370
|
+
templates
|
|
2371
|
+
};
|
|
2372
|
+
if ((section == null ? void 0 : section.create) === "none") {
|
|
2373
|
+
c.ui = __spreadProps(__spreadValues({}, c.ui), {
|
|
2374
|
+
allowedActions: {
|
|
2375
|
+
create: false
|
|
2376
|
+
}
|
|
2377
|
+
});
|
|
2378
|
+
}
|
|
2379
|
+
collections.push(c);
|
|
2380
|
+
} else {
|
|
2381
|
+
(_b = section.templates) == null ? void 0 : _b.forEach((tem) => {
|
|
2382
|
+
try {
|
|
2383
|
+
const additionalFields = getFieldsFromTemplates({
|
|
2384
|
+
tem,
|
|
2385
|
+
rootPath: rootPath2,
|
|
2386
|
+
collection: stringifyLabel(section.label)
|
|
2387
|
+
});
|
|
2388
|
+
fields.push(...additionalFields);
|
|
2389
|
+
} catch (e) {
|
|
2390
|
+
console.log("Error parsing template ", tem);
|
|
2391
|
+
console.error(e);
|
|
2392
|
+
}
|
|
2393
|
+
});
|
|
2394
|
+
const c = {
|
|
2395
|
+
label: section.label,
|
|
2396
|
+
name: stringifyLabel(section.label),
|
|
2397
|
+
path: section.path,
|
|
2398
|
+
fields
|
|
2399
|
+
};
|
|
2400
|
+
if ((section == null ? void 0 : section.create) === "none") {
|
|
2401
|
+
c.ui = __spreadProps(__spreadValues({}, c.ui), {
|
|
2402
|
+
allowedActions: {
|
|
2403
|
+
create: false
|
|
2404
|
+
}
|
|
2405
|
+
});
|
|
2406
|
+
}
|
|
2407
|
+
collections.push(c);
|
|
2408
|
+
}
|
|
2409
|
+
break;
|
|
2410
|
+
}
|
|
2411
|
+
});
|
|
2412
|
+
return collections;
|
|
2067
2413
|
};
|
|
2068
2414
|
|
|
2069
2415
|
// src/cmds/init/index.ts
|
|
2070
2416
|
async function initStaticTina(ctx, next, options) {
|
|
2071
2417
|
const baseDir = ctx.rootPath;
|
|
2072
2418
|
logger.level = "info";
|
|
2419
|
+
const clientId = await chooseClientId();
|
|
2420
|
+
let token = null;
|
|
2421
|
+
if (clientId) {
|
|
2422
|
+
token = await chooseToken({ clientId });
|
|
2423
|
+
}
|
|
2073
2424
|
const packageManager = await choosePackageManager();
|
|
2074
2425
|
const framework = await chooseFramework();
|
|
2075
2426
|
const usingTypescript = await chooseTypescript();
|
|
2076
2427
|
const publicFolder = await choosePublicFolder({ framework });
|
|
2077
|
-
await
|
|
2078
|
-
|
|
2428
|
+
const forestryPath = await hasForestryConfig({ rootPath: ctx.rootPath });
|
|
2429
|
+
let collections;
|
|
2430
|
+
if (forestryPath.exists) {
|
|
2431
|
+
collections = await forestryMigrate({
|
|
2432
|
+
forestryPath: forestryPath.path,
|
|
2433
|
+
rootPath: ctx.rootPath
|
|
2434
|
+
});
|
|
2435
|
+
}
|
|
2436
|
+
await reportTelemetry({
|
|
2437
|
+
usingTypescript,
|
|
2438
|
+
hasForestryConfig: forestryPath.exists,
|
|
2439
|
+
noTelemetry: options.noTelemetry
|
|
2440
|
+
});
|
|
2441
|
+
const hasPackageJSON = await import_fs_extra10.default.pathExistsSync("package.json");
|
|
2079
2442
|
if (!hasPackageJSON) {
|
|
2080
2443
|
await createPackageJSON();
|
|
2081
2444
|
}
|
|
2082
|
-
const hasGitignore = await
|
|
2445
|
+
const hasGitignore = await import_fs_extra10.default.pathExistsSync(".gitignore");
|
|
2083
2446
|
if (!hasGitignore) {
|
|
2084
2447
|
await createGitignore({ baseDir });
|
|
2085
2448
|
} else {
|
|
@@ -2091,8 +2454,18 @@ async function initStaticTina(ctx, next, options) {
|
|
|
2091
2454
|
}
|
|
2092
2455
|
}
|
|
2093
2456
|
await addDependencies(packageManager);
|
|
2094
|
-
await addConfigFile({
|
|
2095
|
-
|
|
2457
|
+
await addConfigFile({
|
|
2458
|
+
publicFolder,
|
|
2459
|
+
baseDir,
|
|
2460
|
+
usingTypescript,
|
|
2461
|
+
framework,
|
|
2462
|
+
collections,
|
|
2463
|
+
token,
|
|
2464
|
+
clientId
|
|
2465
|
+
});
|
|
2466
|
+
if (!forestryPath.exists) {
|
|
2467
|
+
await addContentFile({ baseDir });
|
|
2468
|
+
}
|
|
2096
2469
|
if (framework.reactive) {
|
|
2097
2470
|
await addReactiveFile[framework.name]({
|
|
2098
2471
|
baseDir,
|
|
@@ -2102,6 +2475,24 @@ async function initStaticTina(ctx, next, options) {
|
|
|
2102
2475
|
}
|
|
2103
2476
|
logNextSteps({ packageManager, framework });
|
|
2104
2477
|
}
|
|
2478
|
+
var chooseClientId = async () => {
|
|
2479
|
+
const option = await (0, import_prompts2.default)({
|
|
2480
|
+
name: "clientId",
|
|
2481
|
+
type: "text",
|
|
2482
|
+
message: `What is your Tina Cloud Client ID? (Hit enter to skip and set up yourself later)
|
|
2483
|
+
${logText("Don't have a Client ID? Create one here: ")}${linkText("https://app.tina.io/projects/new")}`
|
|
2484
|
+
});
|
|
2485
|
+
return option["clientId"];
|
|
2486
|
+
};
|
|
2487
|
+
var chooseToken = async ({ clientId }) => {
|
|
2488
|
+
const option = await (0, import_prompts2.default)({
|
|
2489
|
+
name: "token",
|
|
2490
|
+
type: "text",
|
|
2491
|
+
message: `What is your Tina Cloud Read Only Token?
|
|
2492
|
+
${logText("Don't have a Read Only Token? Create one here: ")}${linkText(`https://app.tina.io/projects/${clientId}/tokens`)}`
|
|
2493
|
+
});
|
|
2494
|
+
return option["token"];
|
|
2495
|
+
};
|
|
2105
2496
|
var choosePackageManager = async () => {
|
|
2106
2497
|
const option = await (0, import_prompts2.default)({
|
|
2107
2498
|
name: "selection",
|
|
@@ -2125,15 +2516,23 @@ var chooseTypescript = async () => {
|
|
|
2125
2516
|
return option["selection"];
|
|
2126
2517
|
};
|
|
2127
2518
|
var choosePublicFolder = async ({ framework }) => {
|
|
2128
|
-
|
|
2129
|
-
|
|
2519
|
+
let suggestion = "public";
|
|
2520
|
+
switch (framework.name) {
|
|
2521
|
+
case "next":
|
|
2522
|
+
return "public";
|
|
2523
|
+
case "hugo":
|
|
2524
|
+
return "static";
|
|
2525
|
+
case "jekyll":
|
|
2526
|
+
suggestion = "public";
|
|
2527
|
+
break;
|
|
2130
2528
|
}
|
|
2131
2529
|
const option = await (0, import_prompts2.default)({
|
|
2132
2530
|
name: "selection",
|
|
2133
2531
|
type: "text",
|
|
2134
|
-
message:
|
|
2532
|
+
message: `Where are public assets stored? (default: "${suggestion}")
|
|
2533
|
+
Not sure what value to use? Refer to our "Frameworks" doc: https://tina.io/docs/integration/frameworks/`
|
|
2135
2534
|
});
|
|
2136
|
-
return option["selection"] ||
|
|
2535
|
+
return option["selection"] || suggestion;
|
|
2137
2536
|
};
|
|
2138
2537
|
var chooseFramework = async () => {
|
|
2139
2538
|
const option = await (0, import_prompts2.default)({
|
|
@@ -2142,15 +2541,43 @@ var chooseFramework = async () => {
|
|
|
2142
2541
|
message: "What framework are you using?",
|
|
2143
2542
|
choices: [
|
|
2144
2543
|
{ title: "Next.js", value: { name: "next", reactive: true } },
|
|
2544
|
+
{ title: "Hugo", value: { name: "hugo", reactive: false } },
|
|
2545
|
+
{ title: "Jekyll", value: { name: "jekyll", reactive: false } },
|
|
2145
2546
|
{
|
|
2146
|
-
title: "Other (SSG frameworks like
|
|
2547
|
+
title: "Other (SSG frameworks like gatsby, etc.)",
|
|
2147
2548
|
value: { name: "other", reactive: false }
|
|
2148
2549
|
}
|
|
2149
2550
|
]
|
|
2150
2551
|
});
|
|
2151
2552
|
return option["selection"];
|
|
2152
2553
|
};
|
|
2153
|
-
var
|
|
2554
|
+
var forestryMigrate = async ({
|
|
2555
|
+
forestryPath,
|
|
2556
|
+
rootPath: rootPath2
|
|
2557
|
+
}) => {
|
|
2558
|
+
logger.info(`It looks like you have a ${focusText(".forestry/settings.yml")} file in your project.`);
|
|
2559
|
+
const option = await (0, import_prompts2.default)({
|
|
2560
|
+
name: "selection",
|
|
2561
|
+
type: "confirm",
|
|
2562
|
+
initial: true,
|
|
2563
|
+
message: `Please note that this is a beta version and may contain some issues
|
|
2564
|
+
Would you like to migrate your Forestry templates?
|
|
2565
|
+
${logText("Note: This migration will not be perfect, but it will get you started.")}`
|
|
2566
|
+
});
|
|
2567
|
+
if (!option["selection"]) {
|
|
2568
|
+
return null;
|
|
2569
|
+
}
|
|
2570
|
+
const collections = await generateCollections({
|
|
2571
|
+
forestryPath,
|
|
2572
|
+
rootPath: rootPath2
|
|
2573
|
+
});
|
|
2574
|
+
return JSON.stringify(collections, null, 2);
|
|
2575
|
+
};
|
|
2576
|
+
var reportTelemetry = async ({
|
|
2577
|
+
hasForestryConfig: hasForestryConfig2,
|
|
2578
|
+
noTelemetry,
|
|
2579
|
+
usingTypescript
|
|
2580
|
+
}) => {
|
|
2154
2581
|
if (noTelemetry) {
|
|
2155
2582
|
logger.info(logText("Telemetry disabled"));
|
|
2156
2583
|
}
|
|
@@ -2159,7 +2586,8 @@ var reportTelemetry = async (usingTypescript, noTelemetry) => {
|
|
|
2159
2586
|
await telemetry.submitRecord({
|
|
2160
2587
|
event: {
|
|
2161
2588
|
name: "tinacms:cli:init:invoke",
|
|
2162
|
-
schemaFileType: schemaFileType2
|
|
2589
|
+
schemaFileType: schemaFileType2,
|
|
2590
|
+
hasForestryConfig: hasForestryConfig2
|
|
2163
2591
|
}
|
|
2164
2592
|
});
|
|
2165
2593
|
};
|
|
@@ -2169,22 +2597,22 @@ var createPackageJSON = async () => {
|
|
|
2169
2597
|
};
|
|
2170
2598
|
var createGitignore = async ({ baseDir }) => {
|
|
2171
2599
|
logger.info(logText("No .gitignore found, creating one"));
|
|
2172
|
-
await
|
|
2600
|
+
await import_fs_extra10.default.outputFileSync(import_path13.default.join(baseDir, ".gitignore"), "node_modules");
|
|
2173
2601
|
};
|
|
2174
2602
|
var checkGitignoreForNodeModules = async ({
|
|
2175
2603
|
baseDir
|
|
2176
2604
|
}) => {
|
|
2177
|
-
const gitignoreContent = await
|
|
2605
|
+
const gitignoreContent = await import_fs_extra10.default.readFileSync(import_path13.default.join(baseDir, ".gitignore")).toString();
|
|
2178
2606
|
return gitignoreContent.split("\n").some((item) => item === "node_modules");
|
|
2179
2607
|
};
|
|
2180
2608
|
var addNodeModulesToGitignore = async ({ baseDir }) => {
|
|
2181
2609
|
logger.info(logText("Adding node_modules to .gitignore"));
|
|
2182
|
-
const gitignoreContent = await
|
|
2610
|
+
const gitignoreContent = await import_fs_extra10.default.readFileSync(import_path13.default.join(baseDir, ".gitignore")).toString();
|
|
2183
2611
|
const newGitignoreContent = [
|
|
2184
2612
|
...gitignoreContent.split("\n"),
|
|
2185
2613
|
"node_modules"
|
|
2186
2614
|
].join("\n");
|
|
2187
|
-
await
|
|
2615
|
+
await import_fs_extra10.default.writeFileSync(import_path13.default.join(baseDir, ".gitignore"), newGitignoreContent);
|
|
2188
2616
|
};
|
|
2189
2617
|
var addDependencies = async (packageManager) => {
|
|
2190
2618
|
logger.info(logText("Adding dependencies, this might take a moment..."));
|
|
@@ -2197,15 +2625,11 @@ var addDependencies = async (packageManager) => {
|
|
|
2197
2625
|
logger.info(indentedCmd(`${logText(packageManagers[packageManager])}`));
|
|
2198
2626
|
await execShellCommand(packageManagers[packageManager]);
|
|
2199
2627
|
};
|
|
2200
|
-
var addConfigFile = async ({
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
}) => {
|
|
2206
|
-
const configPath = import_path12.default.join(".tina", `config.${usingTypescript ? "ts" : "js"}`);
|
|
2207
|
-
const fullConfigPath = import_path12.default.join(baseDir, configPath);
|
|
2208
|
-
if (import_fs_extra8.default.pathExistsSync(fullConfigPath)) {
|
|
2628
|
+
var addConfigFile = async (args) => {
|
|
2629
|
+
const { baseDir, usingTypescript } = args;
|
|
2630
|
+
const configPath = import_path13.default.join(".tina", `config.${usingTypescript ? "ts" : "js"}`);
|
|
2631
|
+
const fullConfigPath = import_path13.default.join(baseDir, configPath);
|
|
2632
|
+
if (import_fs_extra10.default.pathExistsSync(fullConfigPath)) {
|
|
2209
2633
|
const override = await (0, import_prompts2.default)({
|
|
2210
2634
|
name: "selection",
|
|
2211
2635
|
type: "confirm",
|
|
@@ -2213,19 +2637,19 @@ var addConfigFile = async ({
|
|
|
2213
2637
|
});
|
|
2214
2638
|
if (override["selection"]) {
|
|
2215
2639
|
logger.info(logText(`Overriding file at ${configPath}.`));
|
|
2216
|
-
await
|
|
2640
|
+
await import_fs_extra10.default.outputFileSync(fullConfigPath, config(args));
|
|
2217
2641
|
} else {
|
|
2218
2642
|
logger.info(logText(`Not overriding file at ${configPath}.`));
|
|
2219
2643
|
}
|
|
2220
2644
|
} else {
|
|
2221
2645
|
logger.info(logText(`Adding config file at .tina/config.${usingTypescript ? "ts" : "js"}`));
|
|
2222
|
-
await
|
|
2646
|
+
await import_fs_extra10.default.outputFileSync(fullConfigPath, config(args));
|
|
2223
2647
|
}
|
|
2224
2648
|
};
|
|
2225
2649
|
var addContentFile = async ({ baseDir }) => {
|
|
2226
|
-
const contentPath =
|
|
2227
|
-
const fullContentPath =
|
|
2228
|
-
if (
|
|
2650
|
+
const contentPath = import_path13.default.join("content", "posts", "hello-world.md");
|
|
2651
|
+
const fullContentPath = import_path13.default.join(baseDir, contentPath);
|
|
2652
|
+
if (import_fs_extra10.default.pathExistsSync(fullContentPath)) {
|
|
2229
2653
|
const override = await (0, import_prompts2.default)({
|
|
2230
2654
|
name: "selection",
|
|
2231
2655
|
type: "confirm",
|
|
@@ -2233,13 +2657,13 @@ var addContentFile = async ({ baseDir }) => {
|
|
|
2233
2657
|
});
|
|
2234
2658
|
if (override["selection"]) {
|
|
2235
2659
|
logger.info(logText(`Overriding file at ${contentPath}.`));
|
|
2236
|
-
await
|
|
2660
|
+
await import_fs_extra10.default.outputFileSync(fullContentPath, content);
|
|
2237
2661
|
} else {
|
|
2238
2662
|
logger.info(logText(`Not overriding file at ${contentPath}.`));
|
|
2239
2663
|
}
|
|
2240
2664
|
} else {
|
|
2241
2665
|
logger.info(logText(`Adding content file at ${contentPath}`));
|
|
2242
|
-
await
|
|
2666
|
+
await import_fs_extra10.default.outputFileSync(fullContentPath, content);
|
|
2243
2667
|
}
|
|
2244
2668
|
};
|
|
2245
2669
|
var logNextSteps = ({
|
|
@@ -2252,16 +2676,19 @@ ${titleText(" TinaCMS ")} has been initialized!`));
|
|
|
2252
2676
|
logger.info(`
|
|
2253
2677
|
Once your site is running, access the CMS at ${linkText("<YourDevURL>/admin/index.html")}`);
|
|
2254
2678
|
};
|
|
2679
|
+
var other2 = ({ packageManager }) => {
|
|
2680
|
+
const packageManagers = {
|
|
2681
|
+
pnpm: `pnpm`,
|
|
2682
|
+
npm: `npx`,
|
|
2683
|
+
yarn: `yarn`
|
|
2684
|
+
};
|
|
2685
|
+
const installText = `${packageManagers[packageManager]} tinacms dev -c "<your dev command>"`;
|
|
2686
|
+
return installText;
|
|
2687
|
+
};
|
|
2255
2688
|
var frameworkDevCmds = {
|
|
2256
|
-
other:
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
npm: `npx`,
|
|
2260
|
-
yarn: `yarn`
|
|
2261
|
-
};
|
|
2262
|
-
const installText = `${packageManagers[packageManager]} tinacms dev -c "<your dev command>"`;
|
|
2263
|
-
return installText;
|
|
2264
|
-
},
|
|
2689
|
+
other: other2,
|
|
2690
|
+
hugo: other2,
|
|
2691
|
+
jekyll: other2,
|
|
2265
2692
|
next: ({ packageManager }) => {
|
|
2266
2693
|
const packageManagers = {
|
|
2267
2694
|
pnpm: `pnpm`,
|
|
@@ -2273,7 +2700,7 @@ var frameworkDevCmds = {
|
|
|
2273
2700
|
}
|
|
2274
2701
|
};
|
|
2275
2702
|
var config = (args) => {
|
|
2276
|
-
return configExamples[args.framework.name](args);
|
|
2703
|
+
return (0, import_prettier.format)(configExamples[args.framework.name](args));
|
|
2277
2704
|
};
|
|
2278
2705
|
var content = `---
|
|
2279
2706
|
title: Hello, World!
|
|
@@ -2290,22 +2717,22 @@ var addReactiveFile = {
|
|
|
2290
2717
|
baseDir,
|
|
2291
2718
|
usingTypescript
|
|
2292
2719
|
}) => {
|
|
2293
|
-
const usingSrc = !
|
|
2294
|
-
const pagesPath =
|
|
2295
|
-
const packageJSONPath =
|
|
2296
|
-
const tinaBlogPagePath =
|
|
2297
|
-
const tinaBlogPagePathFile =
|
|
2298
|
-
if (!
|
|
2299
|
-
|
|
2300
|
-
|
|
2720
|
+
const usingSrc = !import_fs_extra10.default.pathExistsSync(import_path13.default.join(baseDir, "pages"));
|
|
2721
|
+
const pagesPath = import_path13.default.join(baseDir, usingSrc ? "src" : "", "pages");
|
|
2722
|
+
const packageJSONPath = import_path13.default.join(baseDir, "package.json");
|
|
2723
|
+
const tinaBlogPagePath = import_path13.default.join(pagesPath, "demo", "blog");
|
|
2724
|
+
const tinaBlogPagePathFile = import_path13.default.join(tinaBlogPagePath, `[filename].${usingTypescript ? "tsx" : "js"}`);
|
|
2725
|
+
if (!import_fs_extra10.default.pathExistsSync(tinaBlogPagePathFile)) {
|
|
2726
|
+
import_fs_extra10.default.mkdirpSync(tinaBlogPagePath);
|
|
2727
|
+
import_fs_extra10.default.writeFileSync(tinaBlogPagePathFile, nextPostPage({ usingSrc }));
|
|
2301
2728
|
}
|
|
2302
2729
|
logger.info("Adding a nextjs example... \u2705");
|
|
2303
|
-
const pack = JSON.parse(
|
|
2730
|
+
const pack = JSON.parse(import_fs_extra10.default.readFileSync(packageJSONPath).toString());
|
|
2304
2731
|
const oldScripts = pack.scripts || {};
|
|
2305
2732
|
const newPack = JSON.stringify(__spreadProps(__spreadValues({}, pack), {
|
|
2306
2733
|
scripts: extendNextScripts(oldScripts)
|
|
2307
2734
|
}), null, 2);
|
|
2308
|
-
|
|
2735
|
+
import_fs_extra10.default.writeFileSync(packageJSONPath, newPack);
|
|
2309
2736
|
}
|
|
2310
2737
|
};
|
|
2311
2738
|
function execShellCommand(cmd) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tinacms/cli",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.6",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"typings": "dist/index.d.ts",
|
|
6
6
|
"files": [
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
]
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
|
-
"@tinacms/scripts": "1.0.
|
|
24
|
+
"@tinacms/scripts": "1.0.1",
|
|
25
25
|
"@types/clear": "0.1.0",
|
|
26
26
|
"@types/cli-spinner": "^0.2.1",
|
|
27
27
|
"@types/cors": "2.8.5",
|
|
@@ -52,11 +52,11 @@
|
|
|
52
52
|
"@graphql-codegen/visitor-plugin-common": "^2.4.0",
|
|
53
53
|
"@graphql-tools/graphql-file-loader": "^7.2.0",
|
|
54
54
|
"@graphql-tools/load": "^7.3.2",
|
|
55
|
-
"@tinacms/app": "1.0.
|
|
55
|
+
"@tinacms/app": "1.0.4",
|
|
56
56
|
"@tinacms/datalayer": "1.0.0",
|
|
57
|
-
"@tinacms/graphql": "1.0.
|
|
58
|
-
"@tinacms/metrics": "1.0.
|
|
59
|
-
"@tinacms/schema-tools": "1.0
|
|
57
|
+
"@tinacms/graphql": "1.0.5",
|
|
58
|
+
"@tinacms/metrics": "1.0.1",
|
|
59
|
+
"@tinacms/schema-tools": "1.2.0",
|
|
60
60
|
"add": "^2.0.6",
|
|
61
61
|
"ajv": "^6.12.3",
|
|
62
62
|
"altair-express-middleware": "4.0.6",
|
|
@@ -82,10 +82,12 @@
|
|
|
82
82
|
"multer": "1.4.5-lts.1",
|
|
83
83
|
"normalize-path": "^3.0.0",
|
|
84
84
|
"url-pattern": "^1.0.3",
|
|
85
|
+
"prettier": "^2.2.1",
|
|
85
86
|
"progress": "^2.0.3",
|
|
86
87
|
"prompts": "^2.4.1",
|
|
87
88
|
"yarn": "^1.22.17",
|
|
88
|
-
"yup": "^0.32.9"
|
|
89
|
+
"yup": "^0.32.9",
|
|
90
|
+
"zod": "^3.14.3"
|
|
89
91
|
},
|
|
90
92
|
"publishConfig": {
|
|
91
93
|
"registry": "https://registry.npmjs.org"
|