storyblok 4.17.4 → 4.17.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.
package/dist/index.mjs CHANGED
@@ -6583,6 +6583,58 @@ const createOctokit = (token) => {
6583
6583
  return octokit;
6584
6584
  };
6585
6585
 
6586
+ const templates = {
6587
+ REACT: {
6588
+ name: "React",
6589
+ value: "react",
6590
+ template: "https://github.com/storyblok/blueprint-core-react",
6591
+ location: "https://localhost:5173/"
6592
+ },
6593
+ VUE: {
6594
+ name: "Vue",
6595
+ value: "vue",
6596
+ template: "https://github.com/storyblok/blueprint-core-vue",
6597
+ location: "https://localhost:5173/"
6598
+ },
6599
+ SVELTE: {
6600
+ name: "Svelte",
6601
+ value: "svelte",
6602
+ template: "https://github.com/storyblok/blueprint-core-svelte",
6603
+ location: "https://localhost:5173/"
6604
+ },
6605
+ ASTRO: {
6606
+ name: "Astro",
6607
+ value: "astro",
6608
+ template: "https://github.com/storyblok/blueprint-core-astro",
6609
+ location: "https://localhost:4321/"
6610
+ },
6611
+ NUXT: {
6612
+ name: "Nuxt",
6613
+ value: "nuxt",
6614
+ template: "https://github.com/storyblok/blueprint-core-nuxt",
6615
+ location: "https://localhost:3000/"
6616
+ },
6617
+ NEXTJS: {
6618
+ name: "Next.js",
6619
+ value: "nextjs",
6620
+ template: "https://github.com/storyblok/blueprint-core-nextjs",
6621
+ location: "https://localhost:3000/"
6622
+ },
6623
+ ELEVENTY: {
6624
+ name: "Eleventy",
6625
+ value: "eleventy",
6626
+ template: "https://github.com/storyblok/blueprint-core-eleventy",
6627
+ location: "https://localhost:8080/"
6628
+ },
6629
+ ANGULAR: {
6630
+ name: "Angular",
6631
+ value: "angular",
6632
+ template: "https://github.com/storyblok/blueprint-core-angular",
6633
+ location: "https://localhost:4200/"
6634
+ }
6635
+ };
6636
+
6637
+ const ui$1 = getUI({ enabled: true });
6586
6638
  const generateProject = async (blueprint, projectName, targetPath = process.cwd()) => {
6587
6639
  try {
6588
6640
  const projectPath = join(targetPath, projectName);
@@ -6641,23 +6693,23 @@ async function handleEnvFileCreation(resolvedPath, token, region) {
6641
6693
  envVars.STORYBLOK_REGION = region;
6642
6694
  }
6643
6695
  if (Object.keys(envVars).length === 0) {
6644
- konsola.info("No environment variables to write");
6696
+ ui$1.info("No environment variables to write");
6645
6697
  return true;
6646
6698
  }
6647
6699
  try {
6648
6700
  await createEnvFile(resolvedPath, envVars);
6649
6701
  const writtenKeys = Object.keys(envVars).join(", ");
6650
- konsola.ok(`Created .env file with: ${writtenKeys}`, true);
6702
+ ui$1.ok(`Created .env file with: ${writtenKeys}`, true);
6651
6703
  return true;
6652
6704
  } catch (error) {
6653
- konsola.warn(`Failed to create .env file: ${error.message}`);
6705
+ ui$1.warn(`Failed to create .env file: ${error.message}`);
6654
6706
  if (token) {
6655
- konsola.info(
6707
+ ui$1.info(
6656
6708
  `You can manually add STORYBLOK_DELIVERY_API_TOKEN to your .env file.`
6657
6709
  );
6658
6710
  }
6659
6711
  if (region) {
6660
- konsola.info(
6712
+ ui$1.info(
6661
6713
  `You can manually add STORYBLOK_REGION to your .env file.`
6662
6714
  );
6663
6715
  }
@@ -6694,11 +6746,14 @@ const extractPortFromTopics = (topics) => {
6694
6746
  const repositoryToTemplate = (repo) => {
6695
6747
  const technology = repo.name.replace("blueprint-core-", "");
6696
6748
  const port = extractPortFromTopics(repo.topics || []);
6749
+ const staticTemplate = templates[technology.toUpperCase()];
6697
6750
  return {
6698
- name: technology.charAt(0).toUpperCase() + technology.slice(1),
6751
+ // Prioritize static template name over derived name
6752
+ name: staticTemplate?.name || technology.charAt(0).toUpperCase() + technology.slice(1),
6699
6753
  value: technology,
6700
6754
  template: repo.clone_url,
6701
- location: port ? `https://localhost:${port}/` : "https://localhost:3000/",
6755
+ // Prioritize static template location over topic-derived port
6756
+ location: staticTemplate?.location || (port ? `https://localhost:${port}/` : "https://localhost:3000/"),
6702
6757
  description: repo.description,
6703
6758
  updated_at: repo.updated_at,
6704
6759
  stars: repo.stargazers_count
@@ -6715,36 +6770,38 @@ const fetchBlueprintRepositories = async () => {
6715
6770
  });
6716
6771
  const blueprints = data.items.filter((repo) => repo.name.startsWith("blueprint-core-")).map(repositoryToTemplate).sort((a, b) => (b.stars || 0) - (a.stars || 0));
6717
6772
  return blueprints;
6718
- } catch (error) {
6719
- handleAPIError("fetch_blueprints", error, "Failed to fetch blueprints from GitHub");
6773
+ } catch {
6774
+ ui$1.warn("Failed to fetch blueprints from GitHub. Using offline template list.");
6775
+ return Object.values(templates);
6720
6776
  }
6721
6777
  };
6722
6778
 
6779
+ const ui = getUI({ enabled: true });
6723
6780
  function showNextSteps(technologyTemplate, finalProjectPath) {
6724
- konsola.br();
6725
- konsola.ok(`Your ${chalk.hex(colorPalette.PRIMARY)(technologyTemplate)} project is ready \u{1F389} !`);
6726
- konsola.br();
6727
- konsola.info(`Next steps:
6781
+ ui.br();
6782
+ ui.ok(`Your ${chalk.hex(colorPalette.PRIMARY)(technologyTemplate)} project is ready \u{1F389} !`);
6783
+ ui.br();
6784
+ ui.info(`Next steps:
6728
6785
  cd ${finalProjectPath}
6729
6786
  npm install
6730
6787
  npm run dev
6731
6788
  `);
6732
- konsola.info(`Or check the dedicated guide at: ${chalk.hex(colorPalette.PRIMARY)(`https://www.storyblok.com/docs/guides/${technologyTemplate}`)}`);
6789
+ ui.info(`Or check the dedicated guide at: ${chalk.hex(colorPalette.PRIMARY)(`https://www.storyblok.com/docs/guides/${technologyTemplate}`)}`);
6733
6790
  }
6734
6791
  async function promptForLogin(verbose) {
6735
6792
  try {
6736
- konsola.br();
6793
+ ui.br();
6737
6794
  const shouldLogin = await confirm({
6738
6795
  message: "Would you like to login now?",
6739
6796
  default: true
6740
6797
  });
6741
6798
  if (!shouldLogin) {
6742
- konsola.warn('Login cancelled. You can login later using the "storyblok login" command.');
6799
+ ui.warn('Login cancelled. You can login later using the "storyblok login" command.');
6743
6800
  return null;
6744
6801
  }
6745
6802
  return await performInteractiveLogin({ verbose, showWelcomeMessage: true });
6746
6803
  } catch (error) {
6747
- konsola.br();
6804
+ ui.br();
6748
6805
  handleError(error, verbose);
6749
6806
  return null;
6750
6807
  }
@@ -6754,7 +6811,7 @@ program$5.command(`${commands.CREATE} [project-path]`).alias("c").description(`S
6754
6811
  "-r, --region <region>",
6755
6812
  `The region to apply to the generated project template (does not affect space creation).`
6756
6813
  ).action(async (projectPath, options) => {
6757
- konsola.title(`${commands.CREATE}`, colorPalette.CREATE);
6814
+ ui.title(`${commands.CREATE}`, colorPalette.CREATE);
6758
6815
  const verbose = program$5.opts().verbose;
6759
6816
  const { template, blueprint, token } = options;
6760
6817
  if (options.region && !isRegion(options.region)) {
@@ -6763,10 +6820,10 @@ program$5.command(`${commands.CREATE} [project-path]`).alias("c").description(`S
6763
6820
  }
6764
6821
  let selectedTemplate = template;
6765
6822
  if (blueprint && !template) {
6766
- konsola.warn(`The --blueprint flag is deprecated. Please use --template instead.`);
6823
+ ui.warn(`The --blueprint flag is deprecated. Please use --template instead.`);
6767
6824
  selectedTemplate = blueprint;
6768
6825
  } else if (blueprint && template) {
6769
- konsola.warn(`Both --blueprint and --template provided. Using --template and ignoring --blueprint.`);
6826
+ ui.warn(`Both --blueprint and --template provided. Using --template and ignoring --blueprint.`);
6770
6827
  }
6771
6828
  const { state, initializeSession } = session();
6772
6829
  let password;
@@ -6805,10 +6862,10 @@ program$5.command(`${commands.CREATE} [project-path]`).alias("c").description(`S
6805
6862
  spinnerBlueprints.start("Fetching starter templates...");
6806
6863
  const templates = await fetchBlueprintRepositories();
6807
6864
  spinnerBlueprints.succeed("Starter templates fetched successfully");
6808
- if (!templates) {
6865
+ if (templates.length === 0) {
6809
6866
  spinnerBlueprints.failed();
6810
- konsola.warn("No starter templates found. Please contact support@storyblok.com");
6811
- konsola.br();
6867
+ ui.warn("No starter templates found. Please contact support@storyblok.com");
6868
+ ui.br();
6812
6869
  return;
6813
6870
  }
6814
6871
  let technologyTemplate = selectedTemplate;
@@ -6817,8 +6874,8 @@ program$5.command(`${commands.CREATE} [project-path]`).alias("c").description(`S
6817
6874
  const isValidTemplate = validTemplates.find((bp) => bp.value === selectedTemplate);
6818
6875
  if (!isValidTemplate) {
6819
6876
  const validOptions = validTemplates.map((bp) => bp.value).join(", ");
6820
- konsola.warn(`Invalid template "${chalk.hex(colorPalette.CREATE)(selectedTemplate)}". Valid options are: ${chalk.hex(colorPalette.CREATE)(validOptions)}`);
6821
- konsola.br();
6877
+ ui.warn(`Invalid template "${chalk.hex(colorPalette.CREATE)(selectedTemplate)}". Valid options are: ${chalk.hex(colorPalette.CREATE)(validOptions)}`);
6878
+ ui.br();
6822
6879
  technologyTemplate = void 0;
6823
6880
  }
6824
6881
  }
@@ -6851,10 +6908,10 @@ program$5.command(`${commands.CREATE} [project-path]`).alias("c").description(`S
6851
6908
  const resolvedPath = resolve(finalProjectPath);
6852
6909
  const targetDirectory = dirname(resolvedPath);
6853
6910
  const projectName = basename(resolvedPath);
6854
- konsola.br();
6855
- konsola.info(`Scaffolding your project using the ${chalk.hex(colorPalette.CREATE)(technologyTemplate)} template...`);
6911
+ ui.br();
6912
+ ui.info(`Scaffolding your project using the ${chalk.hex(colorPalette.CREATE)(technologyTemplate)} template...`);
6856
6913
  await generateProject(technologyTemplate, projectName, targetDirectory);
6857
- konsola.ok(`Project ${chalk.hex(colorPalette.PRIMARY)(projectName)} created successfully in ${chalk.hex(colorPalette.PRIMARY)(finalProjectPath)}`, true);
6914
+ ui.ok(`Project ${chalk.hex(colorPalette.PRIMARY)(projectName)} created successfully in ${chalk.hex(colorPalette.PRIMARY)(finalProjectPath)}`, true);
6858
6915
  let createdSpace;
6859
6916
  let userData;
6860
6917
  let whereToCreateSpace = "personal";
@@ -6878,10 +6935,10 @@ program$5.command(`${commands.CREATE} [project-path]`).alias("c").description(`S
6878
6935
  }
6879
6936
  userData = user;
6880
6937
  } catch {
6881
- konsola.error("Failed to fetch user info. Your session may have expired.");
6938
+ ui.error("Failed to fetch user info. Your session may have expired.");
6882
6939
  const loginResult = await promptForLogin(verbose);
6883
6940
  if (!loginResult) {
6884
- konsola.br();
6941
+ ui.br();
6885
6942
  return;
6886
6943
  }
6887
6944
  await initializeSession();
@@ -6893,8 +6950,8 @@ program$5.command(`${commands.CREATE} [project-path]`).alias("c").description(`S
6893
6950
  }
6894
6951
  userData = user;
6895
6952
  } catch (retryError) {
6896
- konsola.error("Failed to fetch user info after login.", retryError);
6897
- konsola.br();
6953
+ ui.error("Failed to fetch user info after login.", retryError);
6954
+ ui.br();
6898
6955
  return;
6899
6956
  }
6900
6957
  }
@@ -6917,8 +6974,8 @@ program$5.command(`${commands.CREATE} [project-path]`).alias("c").description(`S
6917
6974
  whereToCreateSpace = "org";
6918
6975
  }
6919
6976
  if (region !== regions.EU && !userData.has_org) {
6920
- konsola.warn(`Space creation in this region is limited to Enterprise accounts. If you're part of an organization, please ensure you have the required permissions. For more information about Enterprise access, contact our Sales Team.`);
6921
- konsola.br();
6977
+ ui.warn(`Space creation in this region is limited to Enterprise accounts. If you're part of an organization, please ensure you have the required permissions. For more information about Enterprise access, contact our Sales Team.`);
6978
+ ui.br();
6922
6979
  return;
6923
6980
  }
6924
6981
  spinnerSpace.start(`Creating space "${toHumanReadable(projectName)}"`);
@@ -6942,36 +6999,36 @@ program$5.command(`${commands.CREATE} [project-path]`).alias("c").description(`S
6942
6999
  if (createdSpace?.id) {
6943
7000
  try {
6944
7001
  await openSpaceInBrowser(createdSpace.id, region);
6945
- konsola.info(`Opened space in your browser`);
7002
+ ui.info(`Opened space in your browser`);
6946
7003
  } catch (error) {
6947
- konsola.warn(`Failed to open browser: ${error.message}`);
7004
+ ui.warn(`Failed to open browser: ${error.message}`);
6948
7005
  const spaceUrl = generateSpaceUrl(createdSpace.id, region);
6949
- konsola.info(`You can manually open your space at: ${chalk.hex(colorPalette.PRIMARY)(spaceUrl)}`);
7006
+ ui.info(`You can manually open your space at: ${chalk.hex(colorPalette.PRIMARY)(spaceUrl)}`);
6950
7007
  }
6951
7008
  }
6952
7009
  showNextSteps(technologyTemplate, finalProjectPath);
6953
7010
  if (createdSpace?.first_token) {
6954
7011
  if (whereToCreateSpace === "org") {
6955
- konsola.ok(`Storyblok space created in organization ${chalk.hex(colorPalette.PRIMARY)(userData?.org?.name)}, preview url and .env configured automatically. You can now open your space in the browser at ${chalk.hex(colorPalette.PRIMARY)(generateSpaceUrl(createdSpace.id, region))}`);
7012
+ ui.ok(`Storyblok space created in organization ${chalk.hex(colorPalette.PRIMARY)(userData?.org?.name)}, preview url and .env configured automatically. You can now open your space in the browser at ${chalk.hex(colorPalette.PRIMARY)(generateSpaceUrl(createdSpace.id, region))}`);
6956
7013
  } else if (whereToCreateSpace === "partner") {
6957
- konsola.ok(`Storyblok space created in partner portal, preview url and .env configured automatically. You can now open your space in the browser at ${chalk.hex(colorPalette.PRIMARY)(generateSpaceUrl(createdSpace.id, region))}`);
7014
+ ui.ok(`Storyblok space created in partner portal, preview url and .env configured automatically. You can now open your space in the browser at ${chalk.hex(colorPalette.PRIMARY)(generateSpaceUrl(createdSpace.id, region))}`);
6958
7015
  } else {
6959
- konsola.ok(`Storyblok space created, preview url and .env configured automatically. You can now open your space in the browser at ${chalk.hex(colorPalette.PRIMARY)(generateSpaceUrl(createdSpace.id, region))}`);
7016
+ ui.ok(`Storyblok space created, preview url and .env configured automatically. You can now open your space in the browser at ${chalk.hex(colorPalette.PRIMARY)(generateSpaceUrl(createdSpace.id, region))}`);
6960
7017
  }
6961
7018
  }
6962
7019
  } catch (error) {
6963
7020
  spinnerSpace.failed();
6964
- konsola.br();
7021
+ ui.br();
6965
7022
  handleError(error, verbose);
6966
7023
  return;
6967
7024
  }
6968
7025
  } catch (error) {
6969
7026
  spinnerSpace.failed();
6970
7027
  spinnerBlueprints.failed();
6971
- konsola.br();
7028
+ ui.br();
6972
7029
  handleError(error, verbose);
6973
7030
  }
6974
- konsola.br();
7031
+ ui.br();
6975
7032
  });
6976
7033
 
6977
7034
  const program$4 = getProgram();