@tinacms/cli 0.61.8 → 0.61.9
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/buildTina/index.d.ts +3 -1
- package/dist/cmds/audit/audit.d.ts +6 -0
- package/dist/index.js +87 -136
- package/package.json +3 -3
|
@@ -17,6 +17,8 @@ interface BuildOptions {
|
|
|
17
17
|
database: Database;
|
|
18
18
|
store: Store;
|
|
19
19
|
bridge: Bridge;
|
|
20
|
+
/** In some cases (like audit) there's no need to build the SPA */
|
|
21
|
+
buildFrontend?: boolean;
|
|
20
22
|
noWatch?: boolean;
|
|
21
23
|
isomorphicGitBridge?: boolean;
|
|
22
24
|
verbose?: boolean;
|
|
@@ -38,5 +40,5 @@ export declare const buildSetupCmdAudit: (ctx: any, next: () => void, options: {
|
|
|
38
40
|
}) => Promise<void>;
|
|
39
41
|
export declare const buildCmdBuild: (ctx: any, next: () => void, options: Omit<BuildOptions & BuildSetupOptions, 'bridge' | 'database' | 'store'>) => Promise<void>;
|
|
40
42
|
export declare const auditCmdBuild: (ctx: any, next: () => void, options: Omit<BuildOptions & BuildSetupOptions, 'bridge' | 'database' | 'store'>) => Promise<void>;
|
|
41
|
-
export declare const build: ({ noWatch, ctx, bridge, database, store, beforeBuild, afterBuild, dev, local, verbose, noSDK, skipIndex, }: BuildOptions) => Promise<void>;
|
|
43
|
+
export declare const build: ({ noWatch, ctx, bridge, database, store, beforeBuild, afterBuild, dev, local, verbose, buildFrontend, noSDK, skipIndex, }: BuildOptions) => Promise<void>;
|
|
42
44
|
export {};
|
|
@@ -15,7 +15,13 @@ declare type AuditArgs = {
|
|
|
15
15
|
collection: TinaCloudCollection;
|
|
16
16
|
database: Database;
|
|
17
17
|
rootPath: string;
|
|
18
|
+
documents: {
|
|
19
|
+
node: {
|
|
20
|
+
path: string;
|
|
21
|
+
};
|
|
22
|
+
}[];
|
|
18
23
|
useDefaultValues: boolean;
|
|
24
|
+
verbose?: boolean;
|
|
19
25
|
};
|
|
20
26
|
export declare const auditCollection: (args: AuditArgs) => Promise<boolean>;
|
|
21
27
|
export declare const auditDocuments: (args: AuditArgs) => Promise<boolean>;
|
package/dist/index.js
CHANGED
|
@@ -293,7 +293,7 @@ var commander = __toModule(require("commander"));
|
|
|
293
293
|
|
|
294
294
|
// package.json
|
|
295
295
|
var name = "@tinacms/cli";
|
|
296
|
-
var version = "0.61.
|
|
296
|
+
var version = "0.61.9";
|
|
297
297
|
|
|
298
298
|
// src/cmds/audit/audit.ts
|
|
299
299
|
var import_graphql = __toModule(require("@tinacms/graphql"));
|
|
@@ -313,81 +313,14 @@ logger.level = "info";
|
|
|
313
313
|
// src/cmds/audit/audit.ts
|
|
314
314
|
var import_graphql2 = __toModule(require("@tinacms/graphql"));
|
|
315
315
|
var import_chalk = __toModule(require("chalk"));
|
|
316
|
-
var auditCollection = async (args) => {
|
|
317
|
-
let warning = false;
|
|
318
|
-
const { collection, database, rootPath: rootPath2 } = args;
|
|
319
|
-
logger.info(`Checking collection ${collection.name}`);
|
|
320
|
-
const query = `query {
|
|
321
|
-
collection(collection: "${collection.name}") {
|
|
322
|
-
format
|
|
323
|
-
documents {
|
|
324
|
-
edges {
|
|
325
|
-
node {
|
|
326
|
-
...on Document {
|
|
327
|
-
_sys {
|
|
328
|
-
extension
|
|
329
|
-
path
|
|
330
|
-
}
|
|
331
|
-
}
|
|
332
|
-
}
|
|
333
|
-
}
|
|
334
|
-
}
|
|
335
|
-
}
|
|
336
|
-
}
|
|
337
|
-
`;
|
|
338
|
-
const result = await (0, import_graphql.resolve)({
|
|
339
|
-
database,
|
|
340
|
-
query,
|
|
341
|
-
variables: {}
|
|
342
|
-
});
|
|
343
|
-
const format = result.data.collection.format;
|
|
344
|
-
const docs = result.data.collection.documents.edges;
|
|
345
|
-
docs.forEach((x) => {
|
|
346
|
-
const node = x.node;
|
|
347
|
-
if (node._sys.extension.replace(".", "") !== format) {
|
|
348
|
-
warning = true;
|
|
349
|
-
logger.warn(import_chalk.default.yellowBright(`WARNING: there is a file with extension \`${node._sys.extension}\` but in your schema it is defined to be \`.${format}\`
|
|
350
|
-
|
|
351
|
-
location: ${import_path.default.join(rootPath2, node._sys.path)}`));
|
|
352
|
-
}
|
|
353
|
-
});
|
|
354
|
-
return warning;
|
|
355
|
-
};
|
|
356
316
|
var auditDocuments = async (args) => {
|
|
357
|
-
const { collection, database,
|
|
358
|
-
const query = `query {
|
|
359
|
-
collection(collection: "${collection.name}") {
|
|
360
|
-
format
|
|
361
|
-
slug
|
|
362
|
-
documents {
|
|
363
|
-
edges {
|
|
364
|
-
node {
|
|
365
|
-
...on Document {
|
|
366
|
-
_sys {
|
|
367
|
-
extension
|
|
368
|
-
path
|
|
369
|
-
relativePath
|
|
370
|
-
}
|
|
371
|
-
}
|
|
372
|
-
}
|
|
373
|
-
}
|
|
374
|
-
}
|
|
375
|
-
}
|
|
376
|
-
}
|
|
377
|
-
`;
|
|
378
|
-
const result = await (0, import_graphql.resolve)({
|
|
379
|
-
database,
|
|
380
|
-
query,
|
|
381
|
-
variables: {}
|
|
382
|
-
});
|
|
317
|
+
const { collection, database, useDefaultValues, documents } = args;
|
|
383
318
|
let error = false;
|
|
384
|
-
const documents = result.data.collection.documents.edges;
|
|
385
319
|
for (let i = 0; i < documents.length; i++) {
|
|
386
320
|
const node = documents[i].node;
|
|
387
|
-
const
|
|
388
|
-
logger.info(`Checking document: ${fullPath}`);
|
|
321
|
+
const relativePath = node.path.replace(`${collection.path}/`, "");
|
|
389
322
|
const documentQuery = `query {
|
|
390
|
-
document(collection: "${collection.name}", relativePath: "${
|
|
323
|
+
document(collection: "${collection.name}", relativePath: "${relativePath}") {
|
|
391
324
|
__typename
|
|
392
325
|
...on Document {
|
|
393
326
|
_values
|
|
@@ -397,44 +330,58 @@ var auditDocuments = async (args) => {
|
|
|
397
330
|
const docResult = await (0, import_graphql.resolve)({
|
|
398
331
|
database,
|
|
399
332
|
query: documentQuery,
|
|
400
|
-
variables: {}
|
|
333
|
+
variables: {},
|
|
334
|
+
silenceErrors: true,
|
|
335
|
+
verbose: args.verbose || false,
|
|
336
|
+
isAudit: true
|
|
401
337
|
});
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
if (
|
|
407
|
-
|
|
338
|
+
if (docResult.errors) {
|
|
339
|
+
error = true;
|
|
340
|
+
docResult.errors.forEach((err) => {
|
|
341
|
+
logger.error(import_chalk.default.red(err.message));
|
|
342
|
+
if (err.originalError.originalError) {
|
|
343
|
+
logger.error(import_chalk.default.red(` ${err.originalError.originalError.message}`));
|
|
408
344
|
}
|
|
409
345
|
});
|
|
410
|
-
}
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
346
|
+
} else {
|
|
347
|
+
const topLevelDefaults = {};
|
|
348
|
+
if (useDefaultValues && typeof collection.fields !== "string") {
|
|
349
|
+
collection.fields.filter((x) => !x.list).forEach((x) => {
|
|
350
|
+
const value = x.ui;
|
|
351
|
+
if (typeof value !== "undefined") {
|
|
352
|
+
topLevelDefaults[x.name] = value.defaultValue;
|
|
353
|
+
}
|
|
354
|
+
});
|
|
355
|
+
}
|
|
356
|
+
const params = transformDocumentIntoMutationRequestPayload(docResult.data.document._values, {
|
|
357
|
+
includeCollection: true,
|
|
358
|
+
includeTemplate: typeof collection.templates !== "undefined"
|
|
359
|
+
}, topLevelDefaults);
|
|
360
|
+
const mutation = `mutation($collection: String!, $relativePath: String!, $params: DocumentMutation!) {
|
|
416
361
|
updateDocument(
|
|
417
362
|
collection: $collection,
|
|
418
363
|
relativePath: $relativePath,
|
|
419
364
|
params: $params
|
|
420
365
|
){__typename}
|
|
421
366
|
}`;
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
if (mutationRes.errors) {
|
|
434
|
-
mutationRes.errors.forEach((err) => {
|
|
435
|
-
error = true;
|
|
436
|
-
logger.error(import_chalk.default.red(err.message));
|
|
367
|
+
const mutationRes = await (0, import_graphql.resolve)({
|
|
368
|
+
database,
|
|
369
|
+
query: mutation,
|
|
370
|
+
variables: {
|
|
371
|
+
params,
|
|
372
|
+
collection: collection.name,
|
|
373
|
+
relativePath
|
|
374
|
+
},
|
|
375
|
+
isAudit: true,
|
|
376
|
+
silenceErrors: true,
|
|
377
|
+
verbose: args.verbose || false
|
|
437
378
|
});
|
|
379
|
+
if (mutationRes.errors) {
|
|
380
|
+
mutationRes.errors.forEach((err) => {
|
|
381
|
+
error = true;
|
|
382
|
+
logger.error(import_chalk.default.red(err.message));
|
|
383
|
+
});
|
|
384
|
+
}
|
|
438
385
|
}
|
|
439
386
|
}
|
|
440
387
|
return error;
|
|
@@ -484,9 +431,22 @@ function filterObject(obj) {
|
|
|
484
431
|
}
|
|
485
432
|
|
|
486
433
|
// src/cmds/audit/index.ts
|
|
487
|
-
var
|
|
434
|
+
var import_chalk3 = __toModule(require("chalk"));
|
|
488
435
|
var import_prompts = __toModule(require("prompts"));
|
|
489
436
|
var import_metrics = __toModule(require("@tinacms/metrics"));
|
|
437
|
+
|
|
438
|
+
// src/utils/theme.ts
|
|
439
|
+
var import_chalk2 = __toModule(require("chalk"));
|
|
440
|
+
var successText = import_chalk2.default.bold.green;
|
|
441
|
+
var dangerText = import_chalk2.default.bold.red;
|
|
442
|
+
var neutralText = import_chalk2.default.bold.cyan;
|
|
443
|
+
var labelText = import_chalk2.default.bold;
|
|
444
|
+
var cmdText = import_chalk2.default.inverse;
|
|
445
|
+
var logText = import_chalk2.default.italic.gray;
|
|
446
|
+
var warnText = import_chalk2.default.yellowBright.bgBlack;
|
|
447
|
+
var CONFIRMATION_TEXT = import_chalk2.default.dim("enter to confirm");
|
|
448
|
+
|
|
449
|
+
// src/cmds/audit/index.ts
|
|
490
450
|
var rootPath = process.cwd();
|
|
491
451
|
var audit = async (ctx, next, options) => {
|
|
492
452
|
const telemetry = new import_metrics.Telemetry({ disabled: options.noTelemetry });
|
|
@@ -498,7 +458,7 @@ var audit = async (ctx, next, options) => {
|
|
|
498
458
|
}
|
|
499
459
|
});
|
|
500
460
|
if (options.clean) {
|
|
501
|
-
logger.info(`You are using the \`--clean\` option. This will modify your content as if a user is submitting a form. Before running this you should have a ${
|
|
461
|
+
logger.info(`You are using the \`--clean\` option. This will modify your content as if a user is submitting a form. Before running this you should have a ${import_chalk3.default.bold("clean git tree")} so unwanted changes can be undone.
|
|
502
462
|
|
|
503
463
|
`);
|
|
504
464
|
const res = await (0, import_prompts.default)({
|
|
@@ -507,52 +467,47 @@ var audit = async (ctx, next, options) => {
|
|
|
507
467
|
message: `Do you want to continue?`
|
|
508
468
|
});
|
|
509
469
|
if (!res.useClean) {
|
|
510
|
-
logger.warn(
|
|
470
|
+
logger.warn(import_chalk3.default.yellowBright("\u26A0\uFE0F Audit not complete"));
|
|
511
471
|
process.exit(0);
|
|
512
472
|
}
|
|
513
473
|
}
|
|
514
474
|
if (options.useDefaultValues && !options.clean) {
|
|
515
|
-
logger.warn(
|
|
475
|
+
logger.warn(import_chalk3.default.yellowBright("WARNING: using the `--useDefaultValues` without the `--clean` flag has no effect. Please re-run audit and add the `--clean` flag"));
|
|
516
476
|
}
|
|
517
477
|
const database = ctx.database;
|
|
518
478
|
const schema = await database.getSchema();
|
|
519
479
|
const collections = schema.getCollections();
|
|
520
|
-
let warning = false;
|
|
521
480
|
let error = false;
|
|
522
481
|
for (let i = 0; i < collections.length; i++) {
|
|
523
482
|
const collection = collections[i];
|
|
524
|
-
const
|
|
525
|
-
|
|
526
|
-
database,
|
|
527
|
-
rootPath,
|
|
528
|
-
useDefaultValues: options.useDefaultValues
|
|
529
|
-
});
|
|
483
|
+
const docs = await database.query({ collection: collection.name, first: -1, filterChain: [] }, (item) => ({ path: item }));
|
|
484
|
+
logger.info(`Checking ${neutralText(collection.name)} collection`);
|
|
530
485
|
const returnError = await auditDocuments({
|
|
531
486
|
collection,
|
|
532
487
|
database,
|
|
533
488
|
rootPath,
|
|
534
|
-
useDefaultValues: options.useDefaultValues
|
|
489
|
+
useDefaultValues: options.useDefaultValues,
|
|
490
|
+
documents: docs.edges,
|
|
491
|
+
verbose: ctx.verbose
|
|
535
492
|
});
|
|
536
|
-
warning = warning || returnWarning;
|
|
537
493
|
error = error || returnError;
|
|
538
494
|
}
|
|
539
|
-
ctx.warning = warning;
|
|
540
495
|
ctx.error = error;
|
|
541
496
|
next();
|
|
542
497
|
};
|
|
543
498
|
var printFinalMessage = async (ctx, next, _options) => {
|
|
544
499
|
if (ctx.error) {
|
|
545
|
-
logger.error(
|
|
500
|
+
logger.error(import_chalk3.default.redBright(`\u203C\uFE0F Audit ${import_chalk3.default.bold("failed")} with errors`));
|
|
546
501
|
} else if (ctx.warning) {
|
|
547
|
-
logger.warn(
|
|
502
|
+
logger.warn(import_chalk3.default.yellowBright("\u26A0\uFE0F Audit passed with warnings"));
|
|
548
503
|
} else {
|
|
549
|
-
logger.info(
|
|
504
|
+
logger.info(import_chalk3.default.greenBright("\u2705 Audit passed"));
|
|
550
505
|
}
|
|
551
506
|
next();
|
|
552
507
|
};
|
|
553
508
|
|
|
554
509
|
// src/cmds/init/setup-files/index.ts
|
|
555
|
-
var
|
|
510
|
+
var import_chalk4 = __toModule(require("chalk"));
|
|
556
511
|
var adminPage = `import { TinaAdmin } from 'tinacms';
|
|
557
512
|
export default TinaAdmin;
|
|
558
513
|
`;
|
|
@@ -856,15 +811,15 @@ export default App
|
|
|
856
811
|
`;
|
|
857
812
|
};
|
|
858
813
|
var AppJsContentPrintout = (usingSrc, extraImports) => {
|
|
859
|
-
const importLine =
|
|
814
|
+
const importLine = import_chalk4.default.green(`+ import Tina from '${usingSrc ? "../" : ""}../.tina/components/TinaDynamicProvider.js'`);
|
|
860
815
|
return `${importLine}
|
|
861
816
|
${extraImports || ""}
|
|
862
817
|
|
|
863
818
|
const App = ({ Component, pageProps }) => {
|
|
864
819
|
return (
|
|
865
|
-
${
|
|
820
|
+
${import_chalk4.default.green("+ <Tina>")}
|
|
866
821
|
<Component {...pageProps} />
|
|
867
|
-
${
|
|
822
|
+
${import_chalk4.default.green("+ </Tina>")}
|
|
868
823
|
)
|
|
869
824
|
}
|
|
870
825
|
|
|
@@ -905,17 +860,6 @@ const DynamicTina = ({ children }) => {
|
|
|
905
860
|
export default DynamicTina
|
|
906
861
|
`;
|
|
907
862
|
|
|
908
|
-
// src/utils/theme.ts
|
|
909
|
-
var import_chalk4 = __toModule(require("chalk"));
|
|
910
|
-
var successText = import_chalk4.default.bold.green;
|
|
911
|
-
var dangerText = import_chalk4.default.bold.red;
|
|
912
|
-
var neutralText = import_chalk4.default.bold.cyan;
|
|
913
|
-
var labelText = import_chalk4.default.bold;
|
|
914
|
-
var cmdText = import_chalk4.default.inverse;
|
|
915
|
-
var logText = import_chalk4.default.italic.gray;
|
|
916
|
-
var warnText = import_chalk4.default.yellowBright.bgBlack;
|
|
917
|
-
var CONFIRMATION_TEXT = import_chalk4.default.dim("enter to confirm");
|
|
918
|
-
|
|
919
863
|
// src/utils/script-helpers.ts
|
|
920
864
|
function generateGqlScript(scriptValue) {
|
|
921
865
|
return `tinacms dev -c "${scriptValue}"`;
|
|
@@ -1304,9 +1248,9 @@ var getPath = ({
|
|
|
1304
1248
|
}
|
|
1305
1249
|
const filePaths = allowedTypes.map((ext) => import_path3.default.join(projectDir, `${filename}.${ext}`));
|
|
1306
1250
|
let inputFile = void 0;
|
|
1307
|
-
filePaths.every((
|
|
1308
|
-
if (import_fs_extra2.default.existsSync(
|
|
1309
|
-
inputFile =
|
|
1251
|
+
filePaths.every((path8) => {
|
|
1252
|
+
if (import_fs_extra2.default.existsSync(path8)) {
|
|
1253
|
+
inputFile = path8;
|
|
1310
1254
|
return false;
|
|
1311
1255
|
}
|
|
1312
1256
|
return true;
|
|
@@ -2044,6 +1988,7 @@ var auditCmdBuild = async (ctx, next, options) => {
|
|
|
2044
1988
|
bridge,
|
|
2045
1989
|
database,
|
|
2046
1990
|
store,
|
|
1991
|
+
buildFrontend: false,
|
|
2047
1992
|
ctx
|
|
2048
1993
|
}));
|
|
2049
1994
|
next();
|
|
@@ -2059,6 +2004,7 @@ var build2 = async ({
|
|
|
2059
2004
|
dev,
|
|
2060
2005
|
local,
|
|
2061
2006
|
verbose,
|
|
2007
|
+
buildFrontend = true,
|
|
2062
2008
|
noSDK,
|
|
2063
2009
|
skipIndex
|
|
2064
2010
|
}) => {
|
|
@@ -2095,7 +2041,7 @@ var build2 = async ({
|
|
|
2095
2041
|
}, {
|
|
2096
2042
|
local
|
|
2097
2043
|
});
|
|
2098
|
-
if ((_b = (_a = ctx.schema) == null ? void 0 : _a.config) == null ? void 0 : _b.build) {
|
|
2044
|
+
if (buildFrontend && ((_b = (_a = ctx.schema) == null ? void 0 : _a.config) == null ? void 0 : _b.build)) {
|
|
2099
2045
|
await spin({
|
|
2100
2046
|
text: "Building static site",
|
|
2101
2047
|
waitFor: async () => {
|
|
@@ -2596,7 +2542,12 @@ var baseCmds = [
|
|
|
2596
2542
|
], options)
|
|
2597
2543
|
},
|
|
2598
2544
|
{
|
|
2599
|
-
options: [
|
|
2545
|
+
options: [
|
|
2546
|
+
cleanOption,
|
|
2547
|
+
useDefaultValuesOption,
|
|
2548
|
+
noTelemetryOption,
|
|
2549
|
+
verboseOption
|
|
2550
|
+
],
|
|
2600
2551
|
command: AUDIT,
|
|
2601
2552
|
description: "Audit your schema and the files to check for errors",
|
|
2602
2553
|
action: (options) => chain([
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tinacms/cli",
|
|
3
|
-
"version": "0.61.
|
|
3
|
+
"version": "0.61.9",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"typings": "dist/index.d.ts",
|
|
6
6
|
"files": [
|
|
@@ -52,9 +52,9 @@
|
|
|
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": "0.0.
|
|
55
|
+
"@tinacms/app": "0.0.9",
|
|
56
56
|
"@tinacms/datalayer": "0.2.3",
|
|
57
|
-
"@tinacms/graphql": "0.63.
|
|
57
|
+
"@tinacms/graphql": "0.63.5",
|
|
58
58
|
"@tinacms/metrics": "0.0.3",
|
|
59
59
|
"@tinacms/schema-tools": "0.1.0",
|
|
60
60
|
"add": "^2.0.6",
|