@tinacms/cli 1.5.0 → 1.5.1

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.
@@ -2,7 +2,8 @@ export interface Framework {
2
2
  name: 'next' | 'hugo' | 'jekyll' | 'other';
3
3
  reactive: boolean;
4
4
  }
5
- export declare function initStaticTina({ pathToForestryConfig, noTelemetry, }: {
5
+ export declare function initStaticTina({ rootPath, pathToForestryConfig, noTelemetry, }: {
6
+ rootPath: string;
6
7
  pathToForestryConfig: string;
7
8
  noTelemetry: boolean;
8
9
  }): Promise<void>;
@@ -14,6 +15,7 @@ export interface AddConfigArgs {
14
15
  collections?: string;
15
16
  token?: string;
16
17
  clientId?: string;
18
+ isForestryMigration?: boolean;
17
19
  }
18
20
  /**
19
21
  * Executes a shell command and return it as a Promise.
package/dist/index.js CHANGED
@@ -28,10 +28,10 @@ __export(src_exports, {
28
28
  default: () => src_default
29
29
  });
30
30
  module.exports = __toCommonJS(src_exports);
31
- var import_clipanion5 = require("clipanion");
31
+ var import_clipanion6 = require("clipanion");
32
32
 
33
33
  // package.json
34
- var version = "1.5.0";
34
+ var version = "1.5.1";
35
35
 
36
36
  // src/next/commands/dev-command/index.ts
37
37
  var import_clipanion = require("clipanion");
@@ -1462,7 +1462,7 @@ var createDBServer = (port) => {
1462
1462
  });
1463
1463
  dbServer.listen(port);
1464
1464
  };
1465
- async function createAndInitializeDatabase(configManager, bridgeOverride) {
1465
+ async function createAndInitializeDatabase(configManager, datalayerPort, bridgeOverride) {
1466
1466
  let database;
1467
1467
  const bridge = bridgeOverride || new import_graphql7.FilesystemBridge(configManager.rootPath, configManager.contentRootPath);
1468
1468
  if (configManager.hasSelfHostedConfig() && configManager.config.contentApiUrlOverride) {
@@ -1476,7 +1476,7 @@ async function createAndInitializeDatabase(configManager, bridgeOverride) {
1476
1476
  )} but there was no "contentApiUrlOverride" set. Falling back to built-in datalayer`
1477
1477
  );
1478
1478
  }
1479
- const level = new import_graphql7.TinaLevelClient();
1479
+ const level = new import_graphql7.TinaLevelClient(datalayerPort);
1480
1480
  level.openConnection();
1481
1481
  database = (0, import_graphql7.createDatabase)({
1482
1482
  bridge,
@@ -1531,7 +1531,7 @@ var DevCommand = class extends import_clipanion.Command {
1531
1531
  description: "Specify a port to run the server on. (default 4001)"
1532
1532
  });
1533
1533
  this.datalayerPort = import_clipanion.Option.String("--datalayer-port", "9000", {
1534
- description: "Specify a port to run the datalayer server on. (default 4001)"
1534
+ description: "Specify a port to run the datalayer server on. (default 9000)"
1535
1535
  });
1536
1536
  this.subCommand = import_clipanion.Option.String("-c,--command", {
1537
1537
  description: "The sub-command to run"
@@ -1608,7 +1608,10 @@ var DevCommand = class extends import_clipanion.Command {
1608
1608
  }
1609
1609
  }
1610
1610
  if (firstTime) {
1611
- database = await createAndInitializeDatabase(configManager);
1611
+ database = await createAndInitializeDatabase(
1612
+ configManager,
1613
+ Number(this.datalayerPort)
1614
+ );
1612
1615
  } else {
1613
1616
  database.clearCache();
1614
1617
  }
@@ -1963,7 +1966,7 @@ var BuildCommand = class extends import_clipanion2.Command {
1963
1966
  description: "DEPRECATED - This should now be set in the config at client.skip = true'. Don't generate the generated client SDK"
1964
1967
  });
1965
1968
  this.datalayerPort = import_clipanion2.Option.String("--datalayer-port", "9000", {
1966
- description: "Specify a port to run the datalayer server on. (default 4001)"
1969
+ description: "Specify a port to run the datalayer server on. (default 9000)"
1967
1970
  });
1968
1971
  this.isomorphicGitBridge = import_clipanion2.Option.Boolean("--isomorphicGitBridge", {
1969
1972
  description: "DEPRECATED - Enable Isomorphic Git Bridge Implementation"
@@ -2016,7 +2019,10 @@ var BuildCommand = class extends import_clipanion2.Command {
2016
2019
  process.exit(1);
2017
2020
  }
2018
2021
  createDBServer(Number(this.datalayerPort));
2019
- const database = await createAndInitializeDatabase(configManager);
2022
+ const database = await createAndInitializeDatabase(
2023
+ configManager,
2024
+ Number(this.datalayerPort)
2025
+ );
2020
2026
  const { queryDoc, fragDoc } = await (0, import_graphql9.buildSchema)(
2021
2027
  database,
2022
2028
  configManager.config
@@ -2434,7 +2440,7 @@ var AuditCommand = class extends import_clipanion3.Command {
2434
2440
  description: "Disable anonymous telemetry that is collected"
2435
2441
  });
2436
2442
  this.datalayerPort = import_clipanion3.Option.String("--datalayer-port", "9000", {
2437
- description: "Specify a port to run the datalayer server on. (default 4001)"
2443
+ description: "Specify a port to run the datalayer server on. (default 9000)"
2438
2444
  });
2439
2445
  }
2440
2446
  async catch(error) {
@@ -2456,6 +2462,7 @@ var AuditCommand = class extends import_clipanion3.Command {
2456
2462
  createDBServer(Number(this.datalayerPort));
2457
2463
  const database = await createAndInitializeDatabase(
2458
2464
  configManager,
2465
+ Number(this.datalayerPort),
2459
2466
  this.clean ? void 0 : new import_graphql13.AuditFileSystemBridge(configManager.rootPath)
2460
2467
  );
2461
2468
  const { tinaSchema, graphQLSchema } = await (0, import_graphql12.buildSchema)(
@@ -2496,12 +2503,12 @@ AuditCommand.usage = import_clipanion3.Command.Usage({
2496
2503
  });
2497
2504
 
2498
2505
  // src/next/commands/init-command/index.ts
2499
- var import_clipanion4 = require("clipanion");
2506
+ var import_clipanion5 = require("clipanion");
2500
2507
 
2501
2508
  // src/cmds/init/index.ts
2502
- var import_path9 = __toESM(require("path"));
2509
+ var import_path10 = __toESM(require("path"));
2503
2510
  var import_prettier = require("prettier");
2504
- var import_fs_extra8 = __toESM(require("fs-extra"));
2511
+ var import_fs_extra9 = __toESM(require("fs-extra"));
2505
2512
  var import_prompts2 = __toESM(require("prompts"));
2506
2513
  var import_metrics2 = require("@tinacms/metrics");
2507
2514
 
@@ -2510,19 +2517,19 @@ var nextPostPage = ({
2510
2517
  usingSrc
2511
2518
  }) => `// THIS FILE HAS BEEN GENERATED WITH THE TINA CLI.
2512
2519
  // This is a demo file once you have tina setup feel free to delete this file
2513
-
2520
+
2514
2521
  import Head from 'next/head'
2515
2522
  import { useTina } from 'tinacms/dist/react'
2516
2523
  import { TinaMarkdown } from 'tinacms/dist/rich-text'
2517
- import client from '${usingSrc ? "../" : ""}../../../.tina/__generated__/client'
2518
-
2524
+ import client from '${usingSrc ? "../" : ""}../../../tina/__generated__/client'
2525
+
2519
2526
  const BlogPage = (props) => {
2520
2527
  const { data } = useTina({
2521
2528
  query: props.query,
2522
2529
  variables: props.variables,
2523
2530
  data: props.data,
2524
2531
  })
2525
-
2532
+
2526
2533
  return (
2527
2534
  <>
2528
2535
  <Head>
@@ -2561,7 +2568,7 @@ var nextPostPage = ({
2561
2568
  </>
2562
2569
  )
2563
2570
  }
2564
-
2571
+
2565
2572
  export const getStaticProps = async ({ params }) => {
2566
2573
  let data = {}
2567
2574
  let query = {}
@@ -2574,7 +2581,7 @@ var nextPostPage = ({
2574
2581
  } catch {
2575
2582
  // swallow errors related to document creation
2576
2583
  }
2577
-
2584
+
2578
2585
  return {
2579
2586
  props: {
2580
2587
  variables: variables,
@@ -2584,10 +2591,10 @@ var nextPostPage = ({
2584
2591
  },
2585
2592
  }
2586
2593
  }
2587
-
2594
+
2588
2595
  export const getStaticPaths = async () => {
2589
2596
  const postsListData = await client.queries.postConnection()
2590
-
2597
+
2591
2598
  return {
2592
2599
  paths: postsListData.data.postConnection.edges.map((post) => ({
2593
2600
  params: { filename: post.node._sys.filename },
@@ -2595,9 +2602,9 @@ var nextPostPage = ({
2595
2602
  fallback: false,
2596
2603
  }
2597
2604
  }
2598
-
2605
+
2599
2606
  export default BlogPage
2600
-
2607
+
2601
2608
  const PageSection = (props) => {
2602
2609
  return (
2603
2610
  <>
@@ -2606,11 +2613,11 @@ var nextPostPage = ({
2606
2613
  </>
2607
2614
  )
2608
2615
  }
2609
-
2616
+
2610
2617
  const components = {
2611
2618
  PageSection: PageSection,
2612
2619
  }
2613
-
2620
+
2614
2621
  const ContentSection = ({ content }) => {
2615
2622
  return (
2616
2623
  <div className="relative py-16 bg-white overflow-hidden">
@@ -2740,6 +2747,12 @@ function extendNextScripts(scripts) {
2740
2747
  }
2741
2748
 
2742
2749
  // src/cmds/init/setup-files/config.ts
2750
+ var clientConfig = (isForestryMigration) => {
2751
+ if (isForestryMigration) {
2752
+ return "client: {skip: true},";
2753
+ }
2754
+ return "";
2755
+ };
2743
2756
  var other = (args) => {
2744
2757
  return `
2745
2758
  import { defineConfig } from "tinacms";
@@ -2751,6 +2764,7 @@ export default defineConfig({
2751
2764
  branch,
2752
2765
  clientId: ${args.clientId ? `'${args.clientId}'` : "null"}, // Get this from tina.io
2753
2766
  token: ${args.token ? `'${args.token}'` : "null"}, // Get this from tina.io
2767
+ ${clientConfig(args.isForestryMigration)}
2754
2768
  build: {
2755
2769
  outputFolder: "admin",
2756
2770
  publicFolder: "${args.publicFolder}",
@@ -2793,11 +2807,12 @@ var configExamples = {
2793
2807
 
2794
2808
  // Your hosting provider likely exposes this as an environment variable
2795
2809
  const branch = process.env.HEAD || process.env.VERCEL_GIT_COMMIT_REF || 'main'
2796
-
2810
+
2797
2811
  export default defineConfig({
2798
2812
  branch,
2799
2813
  clientId: ${args.clientId ? `'${args.clientId}'` : "null"}, // Get this from tina.io
2800
2814
  token: ${args.token ? `'${args.token}'` : "null"}, // Get this from tina.io
2815
+ ${clientConfig(args.isForestryMigration)}
2801
2816
  build: {
2802
2817
  outputFolder: "admin",
2803
2818
  publicFolder: "${args.publicFolder}",
@@ -2996,7 +3011,6 @@ var transformForestryFieldsToTinaFields = ({
2996
3011
  skipBlocks = false
2997
3012
  }) => {
2998
3013
  const tinaFields = [];
2999
- const blockFields = [];
3000
3014
  fields == null ? void 0 : fields.forEach((forestryField2) => {
3001
3015
  var _a, _b, _c, _d;
3002
3016
  if (forestryField2.name === "menu") {
@@ -3139,7 +3153,6 @@ var transformForestryFieldsToTinaFields = ({
3139
3153
  break;
3140
3154
  case "blocks":
3141
3155
  if (skipBlocks) {
3142
- blockFields.push(forestryField2.name);
3143
3156
  break;
3144
3157
  }
3145
3158
  const templates = [];
@@ -3159,6 +3172,7 @@ var transformForestryFieldsToTinaFields = ({
3159
3172
  field = {
3160
3173
  type: "object",
3161
3174
  list: true,
3175
+ templateKey: "template",
3162
3176
  label: forestryField2.label,
3163
3177
  ...getTinaFieldsFromName(forestryField2.name),
3164
3178
  templates
@@ -3185,20 +3199,9 @@ var transformForestryFieldsToTinaFields = ({
3185
3199
  tinaFields.push(field);
3186
3200
  }
3187
3201
  });
3188
- if (blockFields.length > 0) {
3189
- logger.info(
3190
- warnText(
3191
- `Skipping blocks field${blockFields.length > 1 ? "s" : ""}: ${blockFields.map((b) => `"${b}"`).join(
3192
- ", "
3193
- )}" in ${template}.yaml. Blocks fields need to be manually imported: ${linkText(
3194
- "https://tina.io/docs/forestry/common-errors/#migrating-blocks"
3195
- )}`
3196
- )
3197
- );
3198
- }
3199
3202
  return tinaFields;
3200
3203
  };
3201
- var getFieldsFromTemplates = ({ tem, pathToForestryConfig, skipBlocks = true }) => {
3204
+ var getFieldsFromTemplates = ({ tem, pathToForestryConfig, skipBlocks = false }) => {
3202
3205
  const templatePath = import_path7.default.join(
3203
3206
  pathToForestryConfig,
3204
3207
  ".forestry",
@@ -3433,6 +3436,9 @@ var rewriteTemplateKeysInDocs = (templateMap, rootPath) => {
3433
3436
  (_a = templateObj == null ? void 0 : templateObj.pages) == null ? void 0 : _a.forEach((page) => {
3434
3437
  try {
3435
3438
  const filePath = import_path8.default.join(page);
3439
+ if (import_fs_extra7.default.lstatSync(filePath).isDirectory()) {
3440
+ return;
3441
+ }
3436
3442
  const extname = import_path8.default.extname(filePath);
3437
3443
  const fileContent = import_fs_extra7.default.readFileSync(filePath).toString();
3438
3444
  const content2 = (0, import_graphql14.parseFile)(fileContent, extname, (yup) => yup.object({}));
@@ -3450,12 +3456,81 @@ var rewriteTemplateKeysInDocs = (templateMap, rootPath) => {
3450
3456
  }
3451
3457
  };
3452
3458
 
3459
+ // src/next/commands/codemod-command/index.ts
3460
+ var import_clipanion4 = require("clipanion");
3461
+ var import_fs_extra8 = __toESM(require("fs-extra"));
3462
+ var import_path9 = __toESM(require("path"));
3463
+ var CodemodCommand = class extends import_clipanion4.Command {
3464
+ constructor() {
3465
+ super(...arguments);
3466
+ this.rootPath = import_clipanion4.Option.String("--rootPath", {
3467
+ description: "Specify the root directory to run the CLI from"
3468
+ });
3469
+ this.verbose = import_clipanion4.Option.Boolean("-v,--verbose", false, {
3470
+ description: "increase verbosity of logged output"
3471
+ });
3472
+ }
3473
+ async catch(error) {
3474
+ console.log(error);
3475
+ }
3476
+ async execute() {
3477
+ const mod = this.path[1];
3478
+ if (!mod) {
3479
+ logger.error(
3480
+ "Must specify an additional argument (eg. 'move-tina-folder')"
3481
+ );
3482
+ process.exit(1);
3483
+ }
3484
+ const mods = { "move-tina-folder": () => moveTinaFolder(this.rootPath) };
3485
+ const command = mods[mod];
3486
+ if (!command) {
3487
+ logger.error(`Mod not found for ${mod}`);
3488
+ process.exit(1);
3489
+ }
3490
+ await command();
3491
+ }
3492
+ };
3493
+ CodemodCommand.paths = [["codemod"], ["codemod", "move-tina-folder"]];
3494
+ CodemodCommand.usage = import_clipanion4.Command.Usage({
3495
+ category: `Commands`,
3496
+ description: `Use codemods for various Tina tasks`
3497
+ });
3498
+ var moveTinaFolder = async (rootPath = process.cwd()) => {
3499
+ const configManager = new ConfigManager({ rootPath });
3500
+ try {
3501
+ await configManager.processConfig();
3502
+ } catch (e) {
3503
+ logger.error(e.message);
3504
+ process.exit(1);
3505
+ }
3506
+ const tinaDestination = import_path9.default.join(configManager.rootPath, "tina");
3507
+ if (await import_fs_extra8.default.existsSync(tinaDestination)) {
3508
+ logger.info(
3509
+ `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.`
3510
+ );
3511
+ } else {
3512
+ await import_fs_extra8.default.moveSync(configManager.tinaFolderPath, tinaDestination);
3513
+ await writeGitignore(configManager.rootPath);
3514
+ logger.info(
3515
+ "Move to 'tina' folder complete. Be sure to update any imports of the autogenerated client!"
3516
+ );
3517
+ }
3518
+ };
3519
+ var writeGitignore = async (rootPath) => {
3520
+ await import_fs_extra8.default.outputFileSync(
3521
+ import_path9.default.join(rootPath, "tina", ".gitignore"),
3522
+ "__generated__"
3523
+ );
3524
+ };
3525
+
3453
3526
  // src/cmds/init/index.ts
3454
3527
  async function initStaticTina({
3528
+ rootPath,
3455
3529
  pathToForestryConfig,
3456
3530
  noTelemetry
3457
3531
  }) {
3458
3532
  logger.level = "info";
3533
+ process.chdir(rootPath);
3459
3534
  const clientId = await chooseClientId();
3460
3535
  let token = null;
3461
3536
  if (clientId) {
@@ -3466,24 +3541,28 @@ async function initStaticTina({
3466
3541
  const usingTypescript = await chooseTypescript();
3467
3542
  const publicFolder = await choosePublicFolder({ framework });
3468
3543
  let collections;
3469
- const hasForestryConfig = await import_fs_extra8.default.pathExists(
3470
- import_path9.default.join(pathToForestryConfig, ".forestry", "settings.yml")
3544
+ const hasForestryConfig = await import_fs_extra9.default.pathExists(
3545
+ import_path10.default.join(pathToForestryConfig, ".forestry", "settings.yml")
3471
3546
  );
3547
+ let isForestryMigration = false;
3472
3548
  if (hasForestryConfig) {
3473
3549
  collections = await forestryMigrate({
3474
3550
  pathToForestryConfig
3475
3551
  });
3552
+ if (collections) {
3553
+ isForestryMigration = true;
3554
+ }
3476
3555
  }
3477
3556
  await reportTelemetry({
3478
3557
  usingTypescript,
3479
3558
  hasForestryConfig,
3480
3559
  noTelemetry
3481
3560
  });
3482
- const hasPackageJSON = await import_fs_extra8.default.pathExistsSync("package.json");
3561
+ const hasPackageJSON = await import_fs_extra9.default.pathExistsSync("package.json");
3483
3562
  if (!hasPackageJSON) {
3484
3563
  await createPackageJSON();
3485
3564
  }
3486
- const hasGitignore = await import_fs_extra8.default.pathExistsSync(".gitignore");
3565
+ const hasGitignore = await import_fs_extra9.default.pathExistsSync(".gitignore");
3487
3566
  if (!hasGitignore) {
3488
3567
  await createGitignore({ baseDir: "" });
3489
3568
  } else {
@@ -3496,8 +3575,8 @@ async function initStaticTina({
3496
3575
  }
3497
3576
  await addDependencies(packageManager);
3498
3577
  await addConfigFile({
3499
- publicFolder: import_path9.default.join(
3500
- import_path9.default.relative(process.cwd(), pathToForestryConfig),
3578
+ publicFolder: import_path10.default.join(
3579
+ import_path10.default.relative(process.cwd(), pathToForestryConfig),
3501
3580
  publicFolder
3502
3581
  ),
3503
3582
  baseDir: "",
@@ -3505,7 +3584,8 @@ async function initStaticTina({
3505
3584
  framework,
3506
3585
  collections,
3507
3586
  token,
3508
- clientId
3587
+ clientId,
3588
+ isForestryMigration
3509
3589
  });
3510
3590
  if (!hasForestryConfig) {
3511
3591
  await addContentFile({ baseDir: "" });
@@ -3650,22 +3730,22 @@ var createPackageJSON = async () => {
3650
3730
  };
3651
3731
  var createGitignore = async ({ baseDir }) => {
3652
3732
  logger.info(logText("No .gitignore found, creating one"));
3653
- await import_fs_extra8.default.outputFileSync(import_path9.default.join(baseDir, ".gitignore"), "node_modules");
3733
+ await import_fs_extra9.default.outputFileSync(import_path10.default.join(baseDir, ".gitignore"), "node_modules");
3654
3734
  };
3655
3735
  var checkGitignoreForNodeModules = async ({
3656
3736
  baseDir
3657
3737
  }) => {
3658
- const gitignoreContent = await import_fs_extra8.default.readFileSync(import_path9.default.join(baseDir, ".gitignore")).toString();
3738
+ const gitignoreContent = await import_fs_extra9.default.readFileSync(import_path10.default.join(baseDir, ".gitignore")).toString();
3659
3739
  return gitignoreContent.split("\n").some((item) => item === "node_modules");
3660
3740
  };
3661
3741
  var addNodeModulesToGitignore = async ({ baseDir }) => {
3662
3742
  logger.info(logText("Adding node_modules to .gitignore"));
3663
- const gitignoreContent = await import_fs_extra8.default.readFileSync(import_path9.default.join(baseDir, ".gitignore")).toString();
3743
+ const gitignoreContent = await import_fs_extra9.default.readFileSync(import_path10.default.join(baseDir, ".gitignore")).toString();
3664
3744
  const newGitignoreContent = [
3665
3745
  ...gitignoreContent.split("\n"),
3666
3746
  "node_modules"
3667
3747
  ].join("\n");
3668
- await import_fs_extra8.default.writeFileSync(import_path9.default.join(baseDir, ".gitignore"), newGitignoreContent);
3748
+ await import_fs_extra9.default.writeFileSync(import_path10.default.join(baseDir, ".gitignore"), newGitignoreContent);
3669
3749
  };
3670
3750
  var addDependencies = async (packageManager) => {
3671
3751
  logger.info(logText("Adding dependencies, this might take a moment..."));
@@ -3680,12 +3760,12 @@ var addDependencies = async (packageManager) => {
3680
3760
  };
3681
3761
  var addConfigFile = async (args) => {
3682
3762
  const { baseDir, usingTypescript } = args;
3683
- const configPath = import_path9.default.join(
3684
- ".tina",
3763
+ const configPath = import_path10.default.join(
3764
+ "tina",
3685
3765
  `config.${usingTypescript ? "ts" : "js"}`
3686
3766
  );
3687
- const fullConfigPath = import_path9.default.join(baseDir, configPath);
3688
- if (import_fs_extra8.default.pathExistsSync(fullConfigPath)) {
3767
+ const fullConfigPath = import_path10.default.join(baseDir, configPath);
3768
+ if (import_fs_extra9.default.pathExistsSync(fullConfigPath)) {
3689
3769
  const override = await (0, import_prompts2.default)({
3690
3770
  name: "selection",
3691
3771
  type: "confirm",
@@ -3693,23 +3773,24 @@ var addConfigFile = async (args) => {
3693
3773
  });
3694
3774
  if (override["selection"]) {
3695
3775
  logger.info(logText(`Overriding file at ${configPath}.`));
3696
- await import_fs_extra8.default.outputFileSync(fullConfigPath, config2(args));
3776
+ await import_fs_extra9.default.outputFileSync(fullConfigPath, config2(args));
3697
3777
  } else {
3698
3778
  logger.info(logText(`Not overriding file at ${configPath}.`));
3699
3779
  }
3700
3780
  } else {
3701
3781
  logger.info(
3702
3782
  logText(
3703
- `Adding config file at .tina/config.${usingTypescript ? "ts" : "js"}`
3783
+ `Adding config file at tina/config.${usingTypescript ? "ts" : "js"}`
3704
3784
  )
3705
3785
  );
3706
- await import_fs_extra8.default.outputFileSync(fullConfigPath, config2(args));
3786
+ await import_fs_extra9.default.outputFileSync(fullConfigPath, config2(args));
3787
+ await writeGitignore(baseDir);
3707
3788
  }
3708
3789
  };
3709
3790
  var addContentFile = async ({ baseDir }) => {
3710
- const contentPath = import_path9.default.join("content", "posts", "hello-world.md");
3711
- const fullContentPath = import_path9.default.join(baseDir, contentPath);
3712
- if (import_fs_extra8.default.pathExistsSync(fullContentPath)) {
3791
+ const contentPath = import_path10.default.join("content", "posts", "hello-world.md");
3792
+ const fullContentPath = import_path10.default.join(baseDir, contentPath);
3793
+ if (import_fs_extra9.default.pathExistsSync(fullContentPath)) {
3713
3794
  const override = await (0, import_prompts2.default)({
3714
3795
  name: "selection",
3715
3796
  type: "confirm",
@@ -3717,13 +3798,13 @@ var addContentFile = async ({ baseDir }) => {
3717
3798
  });
3718
3799
  if (override["selection"]) {
3719
3800
  logger.info(logText(`Overriding file at ${contentPath}.`));
3720
- await import_fs_extra8.default.outputFileSync(fullContentPath, content);
3801
+ await import_fs_extra9.default.outputFileSync(fullContentPath, content);
3721
3802
  } else {
3722
3803
  logger.info(logText(`Not overriding file at ${contentPath}.`));
3723
3804
  }
3724
3805
  } else {
3725
3806
  logger.info(logText(`Adding content file at ${contentPath}`));
3726
- await import_fs_extra8.default.outputFileSync(fullContentPath, content);
3807
+ await import_fs_extra9.default.outputFileSync(fullContentPath, content);
3727
3808
  }
3728
3809
  };
3729
3810
  var logNextSteps = ({
@@ -3783,20 +3864,20 @@ var addReactiveFile = {
3783
3864
  baseDir,
3784
3865
  usingTypescript
3785
3866
  }) => {
3786
- const usingSrc = !import_fs_extra8.default.pathExistsSync(import_path9.default.join(baseDir, "pages"));
3787
- const pagesPath = import_path9.default.join(baseDir, usingSrc ? "src" : "", "pages");
3788
- const packageJSONPath = import_path9.default.join(baseDir, "package.json");
3789
- const tinaBlogPagePath = import_path9.default.join(pagesPath, "demo", "blog");
3790
- const tinaBlogPagePathFile = import_path9.default.join(
3867
+ const usingSrc = !import_fs_extra9.default.pathExistsSync(import_path10.default.join(baseDir, "pages"));
3868
+ const pagesPath = import_path10.default.join(baseDir, usingSrc ? "src" : "", "pages");
3869
+ const packageJSONPath = import_path10.default.join(baseDir, "package.json");
3870
+ const tinaBlogPagePath = import_path10.default.join(pagesPath, "demo", "blog");
3871
+ const tinaBlogPagePathFile = import_path10.default.join(
3791
3872
  tinaBlogPagePath,
3792
3873
  `[filename].${usingTypescript ? "tsx" : "js"}`
3793
3874
  );
3794
- if (!import_fs_extra8.default.pathExistsSync(tinaBlogPagePathFile)) {
3795
- import_fs_extra8.default.mkdirpSync(tinaBlogPagePath);
3796
- import_fs_extra8.default.writeFileSync(tinaBlogPagePathFile, nextPostPage({ usingSrc }));
3875
+ if (!import_fs_extra9.default.pathExistsSync(tinaBlogPagePathFile)) {
3876
+ import_fs_extra9.default.mkdirpSync(tinaBlogPagePath);
3877
+ import_fs_extra9.default.writeFileSync(tinaBlogPagePathFile, nextPostPage({ usingSrc }));
3797
3878
  }
3798
3879
  logger.info("Adding a nextjs example... \u2705");
3799
- const pack = JSON.parse(import_fs_extra8.default.readFileSync(packageJSONPath).toString());
3880
+ const pack = JSON.parse(import_fs_extra9.default.readFileSync(packageJSONPath).toString());
3800
3881
  const oldScripts = pack.scripts || {};
3801
3882
  const newPack = JSON.stringify(
3802
3883
  {
@@ -3806,7 +3887,7 @@ var addReactiveFile = {
3806
3887
  null,
3807
3888
  2
3808
3889
  );
3809
- import_fs_extra8.default.writeFileSync(packageJSONPath, newPack);
3890
+ import_fs_extra9.default.writeFileSync(packageJSONPath, newPack);
3810
3891
  }
3811
3892
  };
3812
3893
  function execShellCommand(cmd) {
@@ -3822,13 +3903,16 @@ function execShellCommand(cmd) {
3822
3903
  }
3823
3904
 
3824
3905
  // src/next/commands/init-command/index.ts
3825
- var InitCommand = class extends import_clipanion4.Command {
3906
+ var InitCommand = class extends import_clipanion5.Command {
3826
3907
  constructor() {
3827
3908
  super(...arguments);
3828
- this.pathToForestryConfig = import_clipanion4.Option.String("--forestryPath", {
3909
+ this.pathToForestryConfig = import_clipanion5.Option.String("--forestryPath", {
3829
3910
  description: "Specify the relative path to the .forestry directory, if importing an existing forestry site."
3830
3911
  });
3831
- this.noTelemetry = import_clipanion4.Option.Boolean("--noTelemetry", false, {
3912
+ this.rootPath = import_clipanion5.Option.String("--rootPath", {
3913
+ description: "Specify the root directory to run the CLI from (defaults to current working directory)"
3914
+ });
3915
+ this.noTelemetry = import_clipanion5.Option.Boolean("--noTelemetry", false, {
3832
3916
  description: "Disable anonymous telemetry that is collected"
3833
3917
  });
3834
3918
  }
@@ -3838,21 +3922,23 @@ var InitCommand = class extends import_clipanion4.Command {
3838
3922
  process.exit(1);
3839
3923
  }
3840
3924
  async execute() {
3925
+ const rootPath = this.rootPath || process.cwd();
3841
3926
  await initStaticTina({
3842
- pathToForestryConfig: this.pathToForestryConfig || process.cwd(),
3927
+ rootPath,
3928
+ pathToForestryConfig: this.pathToForestryConfig || rootPath,
3843
3929
  noTelemetry: this.noTelemetry
3844
3930
  });
3845
3931
  process.exit();
3846
3932
  }
3847
3933
  };
3848
3934
  InitCommand.paths = [["init"]];
3849
- InitCommand.usage = import_clipanion4.Command.Usage({
3935
+ InitCommand.usage = import_clipanion5.Command.Usage({
3850
3936
  category: `Commands`,
3851
3937
  description: `Add Tina to an existing project`
3852
3938
  });
3853
3939
 
3854
3940
  // src/index.ts
3855
- var cli = new import_clipanion5.Cli({
3941
+ var cli = new import_clipanion6.Cli({
3856
3942
  binaryName: `tinacms`,
3857
3943
  binaryLabel: `TinaCMS`,
3858
3944
  binaryVersion: version
@@ -3861,9 +3947,10 @@ cli.register(DevCommand);
3861
3947
  cli.register(BuildCommand);
3862
3948
  cli.register(AuditCommand);
3863
3949
  cli.register(InitCommand);
3864
- cli.register(import_clipanion5.Builtins.DefinitionsCommand);
3865
- cli.register(import_clipanion5.Builtins.HelpCommand);
3866
- cli.register(import_clipanion5.Builtins.VersionCommand);
3950
+ cli.register(CodemodCommand);
3951
+ cli.register(import_clipanion6.Builtins.DefinitionsCommand);
3952
+ cli.register(import_clipanion6.Builtins.HelpCommand);
3953
+ cli.register(import_clipanion6.Builtins.VersionCommand);
3867
3954
  var src_default = cli;
3868
3955
  // Annotate the CommonJS export names for ESM import in node:
3869
3956
  0 && (module.exports = {});
@@ -7,3 +7,4 @@ export declare class CodemodCommand extends Command {
7
7
  catch(error: any): Promise<void>;
8
8
  execute(): Promise<number | void>;
9
9
  }
10
+ export declare const writeGitignore: (rootPath: string) => Promise<void>;
@@ -2,6 +2,7 @@ import { Command } from 'clipanion';
2
2
  export declare class InitCommand extends Command {
3
3
  static paths: string[][];
4
4
  pathToForestryConfig: string;
5
+ rootPath: string;
5
6
  noTelemetry: boolean;
6
7
  static usage: import("clipanion").Usage;
7
8
  catch(error: any): Promise<void>;
@@ -1,4 +1,4 @@
1
1
  import { Database, Bridge } from '@tinacms/graphql';
2
2
  import { ConfigManager } from './config-manager';
3
3
  export declare const createDBServer: (port: number) => void;
4
- export declare function createAndInitializeDatabase(configManager: ConfigManager, bridgeOverride?: Bridge): Promise<Database>;
4
+ export declare function createAndInitializeDatabase(configManager: ConfigManager, datalayerPort: number, bridgeOverride?: Bridge): Promise<Database>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tinacms/cli",
3
- "version": "1.5.0",
3
+ "version": "1.5.1",
4
4
  "main": "dist/index.js",
5
5
  "typings": "dist/index.d.ts",
6
6
  "files": [
@@ -56,11 +56,11 @@
56
56
  "@tailwindcss/aspect-ratio": "^0.4.0",
57
57
  "@tailwindcss/line-clamp": "^0.3.1",
58
58
  "@tailwindcss/typography": "^0.5.9",
59
- "@tinacms/app": "1.2.1",
60
- "@tinacms/datalayer": "1.2.1",
61
- "@tinacms/graphql": "1.4.1",
59
+ "@tinacms/app": "1.2.2",
60
+ "@tinacms/datalayer": "1.2.2",
61
+ "@tinacms/graphql": "1.4.2",
62
62
  "@tinacms/metrics": "1.0.2",
63
- "@tinacms/schema-tools": "1.4.1",
63
+ "@tinacms/schema-tools": "1.4.2",
64
64
  "@vitejs/plugin-react": "^2.1.0",
65
65
  "ajv": "^6.12.3",
66
66
  "altair-express-middleware": "4.0.6",