@tinacms/cli 1.5.5 → 1.5.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cmds/forestry-migrate/index.d.ts +2 -1
- package/dist/index.js +107 -32
- package/package.json +5 -5
|
@@ -7,7 +7,8 @@ export declare const generateAllTemplates: ({ pathToForestryConfig, }: {
|
|
|
7
7
|
fields: TinaField[];
|
|
8
8
|
templateObj: any;
|
|
9
9
|
}>>;
|
|
10
|
-
export declare const generateCollections: ({ pathToForestryConfig, usingTypescript, }: {
|
|
10
|
+
export declare const generateCollections: ({ pathToForestryConfig, usingTypescript, frontMatterFormat, }: {
|
|
11
|
+
frontMatterFormat?: 'toml' | 'yaml' | 'json';
|
|
11
12
|
pathToForestryConfig: string;
|
|
12
13
|
usingTypescript: boolean;
|
|
13
14
|
}) => Promise<{
|
package/dist/index.js
CHANGED
|
@@ -31,7 +31,7 @@ module.exports = __toCommonJS(src_exports);
|
|
|
31
31
|
var import_clipanion6 = require("clipanion");
|
|
32
32
|
|
|
33
33
|
// package.json
|
|
34
|
-
var version = "1.5.
|
|
34
|
+
var version = "1.5.7";
|
|
35
35
|
|
|
36
36
|
// src/next/commands/dev-command/index.ts
|
|
37
37
|
var import_clipanion = require("clipanion");
|
|
@@ -200,7 +200,7 @@ var ConfigManager = class {
|
|
|
200
200
|
);
|
|
201
201
|
if (!this.tinaConfigFilePath) {
|
|
202
202
|
throw new Error(
|
|
203
|
-
`Unable to find
|
|
203
|
+
`Unable to find config file in ${this.tinaFolderPath}. Looking for a file named "config.{ts,tsx,js,jsx}"`
|
|
204
204
|
);
|
|
205
205
|
}
|
|
206
206
|
this.selfHostedDatabaseFilePath = await this.getPathWithExtension(
|
|
@@ -339,13 +339,13 @@ var ConfigManager = class {
|
|
|
339
339
|
}
|
|
340
340
|
printRelativePath(filename) {
|
|
341
341
|
if (filename) {
|
|
342
|
-
return filename.replace(`${this.rootPath}/`, "");
|
|
342
|
+
return filename.replace(/\\/g, "/").replace(`${this.rootPath}/`, "");
|
|
343
343
|
}
|
|
344
344
|
throw `No path provided to print`;
|
|
345
345
|
}
|
|
346
346
|
printContentRelativePath(filename) {
|
|
347
347
|
if (filename) {
|
|
348
|
-
return filename.replace(`${this.contentRootPath}/`, "");
|
|
348
|
+
return filename.replace(/\\/g, "/").replace(`${this.contentRootPath}/`, "");
|
|
349
349
|
}
|
|
350
350
|
throw `No path provided to print`;
|
|
351
351
|
}
|
|
@@ -989,7 +989,7 @@ var devServerEndPointsPlugin = ({
|
|
|
989
989
|
name: "graphql-endpoints",
|
|
990
990
|
configureServer(server) {
|
|
991
991
|
server.middlewares.use((0, import_cors.default)());
|
|
992
|
-
server.middlewares.use(import_body_parser.default.json());
|
|
992
|
+
server.middlewares.use(import_body_parser.default.json({ limit: "5mb" }));
|
|
993
993
|
server.middlewares.use(async (req, res, next) => {
|
|
994
994
|
var _a;
|
|
995
995
|
const mediaPaths = (_a = configManager.config.media) == null ? void 0 : _a.tina;
|
|
@@ -2110,9 +2110,11 @@ var BuildCommand = class extends import_clipanion2.Command {
|
|
|
2110
2110
|
fragDoc
|
|
2111
2111
|
});
|
|
2112
2112
|
const apiURL = await codegen2.execute();
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2113
|
+
if (!configManager.hasSelfHostedConfig()) {
|
|
2114
|
+
await this.checkClientInfo(configManager, apiURL);
|
|
2115
|
+
await waitForDB(configManager.config, apiURL, false);
|
|
2116
|
+
await this.checkGraphqlSchema(configManager, database, apiURL);
|
|
2117
|
+
}
|
|
2116
2118
|
await buildProductionSpa(configManager, database, apiURL);
|
|
2117
2119
|
await import_fs_extra5.default.outputFile(
|
|
2118
2120
|
configManager.outputGitignorePath,
|
|
@@ -2248,22 +2250,34 @@ var BuildCommand = class extends import_clipanion2.Command {
|
|
|
2248
2250
|
const remoteGqlSchema = (0, import_graphql10.buildClientSchema)(remoteSchema);
|
|
2249
2251
|
const localSchemaDocument = await database.getGraphQLSchemaFromBridge();
|
|
2250
2252
|
const localGraphqlSchema = (0, import_graphql10.buildASTSchema)(localSchemaDocument);
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
2253
|
+
try {
|
|
2254
|
+
const diffResult = await (0, import_core2.diff)(localGraphqlSchema, remoteGqlSchema);
|
|
2255
|
+
if (diffResult.length === 0) {
|
|
2256
|
+
bar2.tick({
|
|
2257
|
+
prog: "\u2705"
|
|
2258
|
+
});
|
|
2259
|
+
} else {
|
|
2260
|
+
bar2.tick({
|
|
2261
|
+
prog: "\u274C"
|
|
2262
|
+
});
|
|
2263
|
+
let errorMessage = `The local GraphQL schema doesn't match the remote GraphQL schema. Please push up your changes to Github to update your remote GraphQL schema.`;
|
|
2264
|
+
if (config3 == null ? void 0 : config3.branch) {
|
|
2265
|
+
errorMessage += `
|
|
2263
2266
|
|
|
2264
2267
|
Additional info: Branch: ${config3.branch}, Client ID: ${config3.clientId} `;
|
|
2268
|
+
}
|
|
2269
|
+
throw new Error(errorMessage);
|
|
2270
|
+
}
|
|
2271
|
+
} catch (e) {
|
|
2272
|
+
if (e.message.startsWith("Cannot use")) {
|
|
2273
|
+
logger.warn(
|
|
2274
|
+
`${warnText(
|
|
2275
|
+
"Skipping schema check due to conflicting GraphQL versions"
|
|
2276
|
+
)}`
|
|
2277
|
+
);
|
|
2278
|
+
} else {
|
|
2279
|
+
throw e;
|
|
2265
2280
|
}
|
|
2266
|
-
throw new Error(errorMessage);
|
|
2267
2281
|
}
|
|
2268
2282
|
}
|
|
2269
2283
|
};
|
|
@@ -3449,7 +3463,8 @@ var generateAllTemplates = async ({
|
|
|
3449
3463
|
await Promise.all(proms);
|
|
3450
3464
|
return templateMap;
|
|
3451
3465
|
};
|
|
3452
|
-
var generateCollectionFromForestrySection = (
|
|
3466
|
+
var generateCollectionFromForestrySection = (args) => {
|
|
3467
|
+
const { section, templateMap } = args;
|
|
3453
3468
|
if (section.read_only)
|
|
3454
3469
|
return;
|
|
3455
3470
|
let format3 = "md";
|
|
@@ -3465,6 +3480,12 @@ var generateCollectionFromForestrySection = (section, templateMap) => {
|
|
|
3465
3480
|
name: stringifyLabel(section.label),
|
|
3466
3481
|
path: section.path || "/"
|
|
3467
3482
|
};
|
|
3483
|
+
if (args.frontMatterFormat) {
|
|
3484
|
+
baseCollection.frontmatterFormat = args.frontMatterFormat;
|
|
3485
|
+
if (args.frontMatterFormat === "toml") {
|
|
3486
|
+
baseCollection.frontmatterDelimiters = "+++";
|
|
3487
|
+
}
|
|
3488
|
+
}
|
|
3468
3489
|
if (section.match) {
|
|
3469
3490
|
baseCollection.match = {
|
|
3470
3491
|
...(baseCollection == null ? void 0 : baseCollection.match) || {},
|
|
@@ -3622,7 +3643,8 @@ var generateCollectionFromForestrySection = (section, templateMap) => {
|
|
|
3622
3643
|
};
|
|
3623
3644
|
var generateCollections = async ({
|
|
3624
3645
|
pathToForestryConfig,
|
|
3625
|
-
usingTypescript
|
|
3646
|
+
usingTypescript,
|
|
3647
|
+
frontMatterFormat
|
|
3626
3648
|
}) => {
|
|
3627
3649
|
const templateMap = await generateAllTemplates({ pathToForestryConfig });
|
|
3628
3650
|
const { importStatements, templateCodeText } = await makeTemplateFile({
|
|
@@ -3632,11 +3654,21 @@ var generateCollections = async ({
|
|
|
3632
3654
|
const forestryConfig = await import_fs_extra7.default.readFile(
|
|
3633
3655
|
import_path8.default.join(pathToForestryConfig, ".forestry", "settings.yml")
|
|
3634
3656
|
);
|
|
3635
|
-
rewriteTemplateKeysInDocs(
|
|
3657
|
+
rewriteTemplateKeysInDocs({
|
|
3658
|
+
templateMap,
|
|
3659
|
+
markdownParseConfig: {
|
|
3660
|
+
frontmatterFormat: frontMatterFormat,
|
|
3661
|
+
frontmatterDelimiters: frontMatterFormat === "toml" ? "+++" : void 0
|
|
3662
|
+
}
|
|
3663
|
+
});
|
|
3636
3664
|
const collections = parseSections({
|
|
3637
3665
|
val: import_js_yaml2.default.load(forestryConfig.toString())
|
|
3638
3666
|
}).sections.map(
|
|
3639
|
-
(section) => generateCollectionFromForestrySection(
|
|
3667
|
+
(section) => generateCollectionFromForestrySection({
|
|
3668
|
+
section,
|
|
3669
|
+
templateMap,
|
|
3670
|
+
frontMatterFormat
|
|
3671
|
+
})
|
|
3640
3672
|
).filter((c) => c !== void 0);
|
|
3641
3673
|
return {
|
|
3642
3674
|
collections,
|
|
@@ -3644,8 +3676,9 @@ var generateCollections = async ({
|
|
|
3644
3676
|
templateCode: templateCodeText
|
|
3645
3677
|
};
|
|
3646
3678
|
};
|
|
3647
|
-
var rewriteTemplateKeysInDocs = (
|
|
3679
|
+
var rewriteTemplateKeysInDocs = (args) => {
|
|
3648
3680
|
var _a;
|
|
3681
|
+
const { templateMap, markdownParseConfig } = args;
|
|
3649
3682
|
for (const templateKey of templateMap.keys()) {
|
|
3650
3683
|
const { templateObj } = templateMap.get(templateKey);
|
|
3651
3684
|
(_a = templateObj == null ? void 0 : templateObj.pages) == null ? void 0 : _a.forEach((page) => {
|
|
@@ -3656,12 +3689,20 @@ var rewriteTemplateKeysInDocs = (templateMap, rootPath) => {
|
|
|
3656
3689
|
}
|
|
3657
3690
|
const extname = import_path8.default.extname(filePath);
|
|
3658
3691
|
const fileContent = import_fs_extra7.default.readFileSync(filePath).toString();
|
|
3659
|
-
const content2 = (0, import_graphql14.parseFile)(
|
|
3692
|
+
const content2 = (0, import_graphql14.parseFile)(
|
|
3693
|
+
fileContent,
|
|
3694
|
+
extname,
|
|
3695
|
+
(yup) => yup.object({}),
|
|
3696
|
+
markdownParseConfig
|
|
3697
|
+
);
|
|
3660
3698
|
const newContent = {
|
|
3661
3699
|
_template: stringifyLabel(templateKey),
|
|
3662
3700
|
...content2
|
|
3663
3701
|
};
|
|
3664
|
-
import_fs_extra7.default.writeFileSync(
|
|
3702
|
+
import_fs_extra7.default.writeFileSync(
|
|
3703
|
+
filePath,
|
|
3704
|
+
(0, import_graphql14.stringifyFile)(newContent, extname, true, markdownParseConfig)
|
|
3705
|
+
);
|
|
3665
3706
|
} catch (error) {
|
|
3666
3707
|
console.log(
|
|
3667
3708
|
dangerText("Error updating template -> _template in ", page)
|
|
@@ -3765,7 +3806,9 @@ async function initStaticTina({
|
|
|
3765
3806
|
if (hasForestryConfig) {
|
|
3766
3807
|
const { collectionString, importStatements, templateCodeString } = await forestryMigrate({
|
|
3767
3808
|
usingTypescript,
|
|
3768
|
-
pathToForestryConfig
|
|
3809
|
+
pathToForestryConfig,
|
|
3810
|
+
rootPath,
|
|
3811
|
+
framework
|
|
3769
3812
|
});
|
|
3770
3813
|
if (collectionString) {
|
|
3771
3814
|
templateCode = templateCodeString;
|
|
@@ -3910,7 +3953,9 @@ var chooseFramework = async () => {
|
|
|
3910
3953
|
};
|
|
3911
3954
|
var forestryMigrate = async ({
|
|
3912
3955
|
pathToForestryConfig,
|
|
3913
|
-
usingTypescript
|
|
3956
|
+
usingTypescript,
|
|
3957
|
+
rootPath,
|
|
3958
|
+
framework
|
|
3914
3959
|
}) => {
|
|
3915
3960
|
logger.info(`Forestry.io configuration found.`);
|
|
3916
3961
|
const disclaimer = logText(
|
|
@@ -3926,11 +3971,15 @@ ${disclaimer}`
|
|
|
3926
3971
|
if (!option["selection"]) {
|
|
3927
3972
|
return null;
|
|
3928
3973
|
}
|
|
3974
|
+
let frontMatterFormat = null;
|
|
3975
|
+
if (framework.name === "hugo") {
|
|
3976
|
+
frontMatterFormat = await getFrontmatterFormat(rootPath);
|
|
3977
|
+
}
|
|
3929
3978
|
const { collections, importStatements, templateCode } = await generateCollections({
|
|
3930
3979
|
pathToForestryConfig,
|
|
3931
|
-
usingTypescript
|
|
3980
|
+
usingTypescript,
|
|
3981
|
+
frontMatterFormat
|
|
3932
3982
|
});
|
|
3933
|
-
ErrorSingleton.getInstance().printCollectionNameErrors();
|
|
3934
3983
|
const JSONString = JSON.stringify(collections, null, 2);
|
|
3935
3984
|
const { code } = addVariablesToCode(JSONString);
|
|
3936
3985
|
return {
|
|
@@ -3939,6 +3988,32 @@ ${disclaimer}`
|
|
|
3939
3988
|
templateCodeString: templateCode
|
|
3940
3989
|
};
|
|
3941
3990
|
};
|
|
3991
|
+
var getFrontmatterFormat = async (rootPath) => {
|
|
3992
|
+
try {
|
|
3993
|
+
const hugoConfigPath = import_path10.default.join(rootPath, "config.toml");
|
|
3994
|
+
const hugoConfig = await import_fs_extra9.default.readFile(hugoConfigPath, "utf8");
|
|
3995
|
+
const frontMatterFormat = hugoConfig.match(/metaDataFormat = "(.*)"/);
|
|
3996
|
+
console.log({ frontMatterFormat });
|
|
3997
|
+
if (frontMatterFormat && frontMatterFormat[1]) {
|
|
3998
|
+
return frontMatterFormat[1];
|
|
3999
|
+
}
|
|
4000
|
+
} catch (e) {
|
|
4001
|
+
}
|
|
4002
|
+
const option = await (0, import_prompts2.default)({
|
|
4003
|
+
name: "selection",
|
|
4004
|
+
type: "select",
|
|
4005
|
+
choices: [
|
|
4006
|
+
{ title: "yaml", value: "yaml" },
|
|
4007
|
+
{ title: "toml", value: "toml" },
|
|
4008
|
+
{ title: "json", value: "json" }
|
|
4009
|
+
],
|
|
4010
|
+
message: `What format are you using in your frontmatter?`
|
|
4011
|
+
});
|
|
4012
|
+
if (!option["selection"]) {
|
|
4013
|
+
return null;
|
|
4014
|
+
}
|
|
4015
|
+
return option["selection"];
|
|
4016
|
+
};
|
|
3942
4017
|
var reportTelemetry = async ({
|
|
3943
4018
|
hasForestryConfig,
|
|
3944
4019
|
noTelemetry,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tinacms/cli",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.7",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"typings": "dist/index.d.ts",
|
|
6
6
|
"files": [
|
|
@@ -58,11 +58,11 @@
|
|
|
58
58
|
"@tailwindcss/aspect-ratio": "^0.4.0",
|
|
59
59
|
"@tailwindcss/line-clamp": "^0.3.1",
|
|
60
60
|
"@tailwindcss/typography": "^0.5.9",
|
|
61
|
-
"@tinacms/app": "1.2.
|
|
62
|
-
"@tinacms/datalayer": "1.2.
|
|
63
|
-
"@tinacms/graphql": "1.4.
|
|
61
|
+
"@tinacms/app": "1.2.7",
|
|
62
|
+
"@tinacms/datalayer": "1.2.8",
|
|
63
|
+
"@tinacms/graphql": "1.4.8",
|
|
64
64
|
"@tinacms/metrics": "1.0.2",
|
|
65
|
-
"@tinacms/schema-tools": "1.4.
|
|
65
|
+
"@tinacms/schema-tools": "1.4.3",
|
|
66
66
|
"@vitejs/plugin-react": "3.1.0",
|
|
67
67
|
"ajv": "^6.12.3",
|
|
68
68
|
"altair-express-middleware": "4.0.6",
|