@tinacms/cli 2.2.3 → 2.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -2,7 +2,7 @@
2
2
  import { Cli, Builtins } from "clipanion";
3
3
 
4
4
  // package.json
5
- var version = "2.2.3";
5
+ var version = "2.2.4";
6
6
 
7
7
  // src/next/commands/dev-command/index.ts
8
8
  import path8 from "path";
@@ -472,22 +472,28 @@ var Codegen = class {
472
472
  localUrl;
473
473
  // production url
474
474
  productionUrl;
475
+ // URL for the local GraphQL server used during --content=local builds
476
+ localBuildUrl;
475
477
  graphqlSchemaDoc;
476
478
  tinaSchema;
477
479
  lookup;
478
480
  noClientBuildCache;
481
+ // When true, queries run locally but the generated client points to TinaCloud
482
+ localContentBuild;
479
483
  constructor({
480
484
  configManager,
481
485
  port,
482
486
  queryDoc,
483
487
  fragDoc,
484
488
  isLocal,
489
+ localContentBuild,
485
490
  graphqlSchemaDoc,
486
491
  tinaSchema,
487
492
  lookup,
488
493
  noClientBuildCache
489
494
  }) {
490
495
  this.isLocal = isLocal;
496
+ this.localContentBuild = localContentBuild || false;
491
497
  this.graphqlSchemaDoc = graphqlSchemaDoc;
492
498
  this.configManager = configManager;
493
499
  this.port = port;
@@ -536,10 +542,11 @@ var Codegen = class {
536
542
  JSON.stringify(this.tinaSchema.schema)
537
543
  );
538
544
  await this.writeConfigFile("_lookup.json", JSON.stringify(this.lookup));
539
- const { apiURL, localUrl, tinaCloudUrl } = this._createApiUrl();
545
+ const { apiURL, localUrl, tinaCloudUrl, localBuildUrl } = this._createApiUrl();
540
546
  this.apiURL = apiURL;
541
547
  this.localUrl = localUrl;
542
548
  this.productionUrl = tinaCloudUrl;
549
+ this.localBuildUrl = localBuildUrl;
543
550
  if (this.configManager.shouldSkipSDK()) {
544
551
  await this.removeGeneratedFilesIfExists();
545
552
  return apiURL;
@@ -638,13 +645,19 @@ var Codegen = class {
638
645
  }
639
646
  let localUrl = `http://localhost:${this.port}/graphql`;
640
647
  let tinaCloudUrl = `${baseUrl}/${version2}/content/${clientId}/github/${branch}`;
641
- let apiURL = this.isLocal ? `http://localhost:${this.port}/graphql` : `${baseUrl}/${version2}/content/${clientId}/github/${branch}`;
648
+ let apiURL;
649
+ if (this.isLocal && !this.localContentBuild) {
650
+ apiURL = `http://localhost:${this.port}/graphql`;
651
+ } else {
652
+ apiURL = `${baseUrl}/${version2}/content/${clientId}/github/${branch}`;
653
+ }
642
654
  if (this.configManager.config.contentApiUrlOverride) {
643
655
  apiURL = this.configManager.config.contentApiUrlOverride;
644
656
  localUrl = apiURL;
645
657
  tinaCloudUrl = apiURL;
646
658
  }
647
- return { apiURL, localUrl, tinaCloudUrl };
659
+ const localBuildUrl = this.port ? `http://localhost:${this.port}/graphql` : void 0;
660
+ return { apiURL, localUrl, tinaCloudUrl, localBuildUrl };
648
661
  }
649
662
  getApiURL() {
650
663
  if (!this.apiURL)
@@ -747,7 +760,7 @@ export default databaseClient;
747
760
  import { queries } from "./types";
748
761
  export const client = createClient({ ${this.noClientBuildCache === false ? `cacheDir: '${normalizePath(
749
762
  this.configManager.generatedCachePath
750
- )}', ` : ""}url: '${apiURL}', token: '${token}', queries, ${errorPolicy ? `errorPolicy: '${errorPolicy}'` : ""} });
763
+ )}', ` : ""}url: ${this.localContentBuild ? `process.env.TINA_LOCAL_URL || '${apiURL}'` : `'${apiURL}'`}, token: '${token}', queries, ${errorPolicy ? `errorPolicy: '${errorPolicy}'` : ""} });
751
764
  export default client;
752
765
  `;
753
766
  return { apiURL, clientString };
@@ -3137,6 +3150,9 @@ var BuildCommand = class extends BaseCommand {
3137
3150
  localOption = Option3.Boolean("--local", {
3138
3151
  description: "Starts local Graphql server and builds the local client instead of production client"
3139
3152
  });
3153
+ contentOption = Option3.String("--content", {
3154
+ description: "Source for content during the build. Use `--content=local` to build from local content for fast builds while still generating a production client that connects to TinaCloud when deployed."
3155
+ });
3140
3156
  skipIndexing = Option3.Boolean("--skip-indexing", false, {
3141
3157
  description: "Skips indexing the content. This can be used for building the site without indexing the content (defaults to false)"
3142
3158
  });
@@ -3199,6 +3215,15 @@ var BuildCommand = class extends BaseCommand {
3199
3215
  );
3200
3216
  process.exit(1);
3201
3217
  }
3218
+ if (this.contentOption !== void 0 && this.contentOption !== "local") {
3219
+ logger.error(
3220
+ `${dangerText(
3221
+ `ERROR: --content only accepts 'local'. Received '${this.contentOption}'.`
3222
+ )}`
3223
+ );
3224
+ process.exit(1);
3225
+ }
3226
+ const localContentOnly = this.contentOption === "local";
3202
3227
  try {
3203
3228
  await configManager.processConfig();
3204
3229
  } catch (e) {
@@ -3209,6 +3234,21 @@ ${dangerText(e.message)}`);
3209
3234
  );
3210
3235
  process.exit(1);
3211
3236
  }
3237
+ if (localContentOnly && !this.localOption) {
3238
+ const config2 = configManager.config;
3239
+ const missing = [];
3240
+ if (!config2.branch) missing.push("branch");
3241
+ if (!config2.clientId) missing.push("clientId");
3242
+ if (!config2.token) missing.push("token");
3243
+ if (missing.length > 0) {
3244
+ logger.error(
3245
+ `${dangerText(
3246
+ `ERROR: --content=local requires ${missing.join(", ")} to be configured, since the generated client must point to TinaCloud.`
3247
+ )}`
3248
+ );
3249
+ process.exit(1);
3250
+ }
3251
+ }
3212
3252
  let server;
3213
3253
  createDBServer(Number(this.datalayerPort));
3214
3254
  const database = await createAndInitializeDatabase(
@@ -3216,10 +3256,12 @@ ${dangerText(e.message)}`);
3216
3256
  Number(this.datalayerPort)
3217
3257
  );
3218
3258
  const { queryDoc, fragDoc, graphQLSchema, tinaSchema, lookup } = await buildSchema2(configManager.config);
3259
+ const useLocalServer = this.localOption || localContentOnly;
3219
3260
  const codegen2 = new Codegen({
3220
3261
  configManager,
3221
- port: this.localOption ? Number(this.port) : void 0,
3222
- isLocal: this.localOption,
3262
+ port: useLocalServer ? Number(this.port) : void 0,
3263
+ isLocal: useLocalServer,
3264
+ localContentBuild: localContentOnly && !this.localOption,
3223
3265
  queryDoc,
3224
3266
  fragDoc,
3225
3267
  graphqlSchemaDoc: graphQLSchema,
@@ -3228,8 +3270,8 @@ ${dangerText(e.message)}`);
3228
3270
  noClientBuildCache: this.noClientBuildCache
3229
3271
  });
3230
3272
  const apiURL = await codegen2.execute();
3231
- if ((configManager.hasSelfHostedConfig() || this.localOption) && !this.skipIndexing) {
3232
- const text = this.localOption ? void 0 : "Indexing to self-hosted data layer";
3273
+ if ((configManager.hasSelfHostedConfig() || this.localOption || localContentOnly) && !this.skipIndexing) {
3274
+ const text = this.localOption || localContentOnly ? void 0 : "Indexing to self-hosted data layer";
3233
3275
  try {
3234
3276
  await this.indexContentWithSpinner({
3235
3277
  text,
@@ -3250,12 +3292,13 @@ ${dangerText(e.message)}
3250
3292
  process.exit(1);
3251
3293
  }
3252
3294
  }
3253
- if (this.localOption) {
3295
+ if (this.localOption || localContentOnly) {
3296
+ const serverUrl = codegen2.localBuildUrl || apiURL;
3254
3297
  server = await createDevServer(
3255
3298
  configManager,
3256
3299
  database,
3257
3300
  null,
3258
- apiURL,
3301
+ serverUrl,
3259
3302
  true,
3260
3303
  (lockedFn) => lockedFn()
3261
3304
  );
@@ -3327,7 +3370,12 @@ ${dangerText(e.message)}
3327
3370
  configManager.outputGitignorePath,
3328
3371
  "index.html\nassets/"
3329
3372
  );
3330
- if (configManager.config.search && !this.skipSearchIndex && !this.localOption) {
3373
+ if (localContentOnly && configManager.config.search && !this.skipSearchIndex) {
3374
+ logger.warn(
3375
+ `${warnText("WARN: Search indexing skipped when building with --content=local. The search index on TinaCloud was not updated.")}`
3376
+ );
3377
+ }
3378
+ if (configManager.config.search && !this.skipSearchIndex && !this.localOption && !localContentOnly) {
3331
3379
  let client;
3332
3380
  const hasTinaSearch = Boolean(configManager.config?.search?.tina);
3333
3381
  if (hasTinaSearch) {
@@ -3426,6 +3474,12 @@ ${dangerText(e.message)}
3426
3474
  ...summaryItems
3427
3475
  ]
3428
3476
  });
3477
+ if (localContentOnly && codegen2.localBuildUrl) {
3478
+ process.env.TINA_LOCAL_URL = codegen2.localBuildUrl;
3479
+ if (!process.env.NODE_ENV || process.env.NODE_ENV !== "production") {
3480
+ process.env.NODE_ENV = "production";
3481
+ }
3482
+ }
3429
3483
  if (this.subCommand) {
3430
3484
  await this.startSubCommand();
3431
3485
  } else {
@@ -4845,7 +4899,7 @@ var ErrorSingleton = class _ErrorSingleton {
4845
4899
  });
4846
4900
  logger.error(
4847
4901
  `If you wish to edit any of the following templates, you will have to update your content and code to use the new name. See ${linkText(
4848
- "https://tina.io/docs/forestry/common-errors/#migrating-fields-with-non-alphanumeric-characters"
4902
+ "https://tina.io/docs/r/forestry-common-errors#migrating-fields-with-non-alphanumeric-characters"
4849
4903
  )} for more information.`
4850
4904
  );
4851
4905
  }
@@ -5289,7 +5343,7 @@ var transformForestryMatchToTinaMatch = (match) => {
5289
5343
  if (match !== newMatch) {
5290
5344
  logger.info(
5291
5345
  `Info: Match ${match} was transformed to ${newMatch}. See ${linkText(
5292
- "https://tina.io/docs/forestry/common-errors/#info-match-match-was-transformed-to-newmatch"
5346
+ "https://tina.io/docs/r/forestry-common-errors#info-match-match-was-transformed-to-newmatch"
5293
5347
  )}`
5294
5348
  );
5295
5349
  }
@@ -5433,7 +5487,7 @@ var generateCollectionFromForestrySection = (args) => {
5433
5487
  logger.warn(
5434
5488
  warnText(
5435
5489
  `No templates found for section ${section.label}. Please see ${linkText(
5436
- "https://tina.io/docs/forestry/content-modelling/"
5490
+ "https://tina.io/docs/r/forestry-content-modelling"
5437
5491
  )} for more information`
5438
5492
  )
5439
5493
  );
@@ -6381,7 +6435,7 @@ async function apply({
6381
6435
  if (config2.framework.name === "other" && config2.hosting === "self-host") {
6382
6436
  logger.error(
6383
6437
  logText(
6384
- "Self-hosted Tina requires init setup only works with next.js right now. Please check out the docs for info on how to setup Tina on another framework: https://tina.io/docs/self-hosted/existing-site/"
6438
+ "Self-hosted Tina requires init setup only works with next.js right now. Please check out the docs for info on how to setup Tina on another framework: https://tina.io/docs/r/self-hosting-nextjs"
6385
6439
  )
6386
6440
  );
6387
6441
  return;
@@ -6766,7 +6820,7 @@ TINA_PUBLIC_IS_LOCAL=true`;
6766
6820
  logger.info(indentText(envFileText));
6767
6821
  }
6768
6822
  logger.info(
6769
- "Before you can run your site you will need to update it to use the backend client.\nSee docs for more info: https://tina.io/docs/self-hosted/querying-data/"
6823
+ "Before you can run your site you will need to update it to use the backend client.\nSee docs for more info: https://tina.io/docs/r/self-hosted-querying-data"
6770
6824
  );
6771
6825
  logger.info(
6772
6826
  "If you are deploying to vercel make sure to add the environment variables to your project."
@@ -12,16 +12,19 @@ export declare class Codegen {
12
12
  apiURL: string;
13
13
  localUrl: string;
14
14
  productionUrl: string;
15
+ localBuildUrl?: string;
15
16
  graphqlSchemaDoc: DocumentNode;
16
17
  tinaSchema: TinaSchema;
17
18
  lookup: any;
18
19
  noClientBuildCache: boolean;
19
- constructor({ configManager, port, queryDoc, fragDoc, isLocal, graphqlSchemaDoc, tinaSchema, lookup, noClientBuildCache, }: {
20
+ localContentBuild: boolean;
21
+ constructor({ configManager, port, queryDoc, fragDoc, isLocal, localContentBuild, graphqlSchemaDoc, tinaSchema, lookup, noClientBuildCache, }: {
20
22
  configManager: ConfigManager;
21
23
  port?: number;
22
24
  queryDoc: string;
23
25
  fragDoc: string;
24
26
  isLocal: boolean;
27
+ localContentBuild?: boolean;
25
28
  graphqlSchemaDoc: DocumentNode;
26
29
  tinaSchema: TinaSchema;
27
30
  lookup: any;
@@ -4,6 +4,7 @@ import { BaseCommand } from '../baseCommands';
4
4
  export declare class BuildCommand extends BaseCommand {
5
5
  static paths: string[][];
6
6
  localOption: boolean;
7
+ contentOption: string;
7
8
  skipIndexing: boolean;
8
9
  partialReindex: boolean;
9
10
  tinaGraphQLVersion: string;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tinacms/cli",
3
3
  "type": "module",
4
- "version": "2.2.3",
4
+ "version": "2.2.4",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
7
7
  "files": [
@@ -88,12 +88,12 @@
88
88
  "vite": "^4.5.9",
89
89
  "yup": "^1.6.1",
90
90
  "zod": "^3.24.2",
91
- "@tinacms/app": "2.4.3",
92
- "@tinacms/metrics": "2.0.1",
93
- "@tinacms/graphql": "2.2.4",
94
- "@tinacms/search": "1.2.10",
91
+ "@tinacms/graphql": "2.2.5",
92
+ "@tinacms/app": "2.4.4",
95
93
  "@tinacms/schema-tools": "2.7.2",
96
- "tinacms": "3.7.3"
94
+ "@tinacms/metrics": "2.0.1",
95
+ "@tinacms/search": "1.2.11",
96
+ "tinacms": "3.7.4"
97
97
  },
98
98
  "publishConfig": {
99
99
  "registry": "https://registry.npmjs.org"