npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@kworq/storyblok-space-cloner

v0.2.0

Published

Tools to efficiently copy components, stories, and assets from one Storyblok space to another. Simplifies cloning for development, testing, or migration purposes, ensuring seamless transfer of content and structure.

Downloads

281

Readme

Storyblok Space Cloner

⚠️ Warning:
As a precaution, it is highly recommended to duplicate your space within each account that it is associated with before proceeding. See here for details. If you mistakenly mix up your source and target environments, you could unintentionally overwrite Blocks or Stories that share the same name, leading to permanent loss of data. This package uses the Storyblok Management API, which requires a personal access token for each account that is used. This token grants access to all associated spaces for your account, along with their respective permissions. Use with caution and at your own risk.

Description

This package provides tools to efficiently copy components, stories, and assets from one Storyblok space to another. It is designed to simplify the process of cloning spaces for development, testing, or migration purposes, ensuring a seamless transfer of content and structure.

Features

  • Copy Assets: Clone all digital assets.
  • Copy Components: Clone all components' schemas.
  • Copy Stories: Clone all stories including all associated content and configurations. If the toDisk option is false or not set, then all story references from any other story will be updated with cloned story UUID.

Prerequisites

Before using this package, you must:

  • Have administrative access to both the source and target Storyblok spaces.
  • Obtain the API OAuth personal access tokens for each account that controls the relative space. If it's the same account, then it's the same personal access token.

Example

import "dotenv/config";
import StoryblokSpaceCloner from "@kworq/storyblok-space-cloner";

const config = {
  SOURCE_OAUTH_TOKEN: process.env.SOURCE_OAUTH_TOKEN,
  TARGET_OAUTH_TOKEN: process.env.TARGET_OAUTH_TOKEN,
  SOURCE_SPACE_ID: process.env.SOURCE_SPACE_ID,
  TARGET_SPACE_ID: process.env.TARGET_SPACE_ID,
  API_ENDPOINT: process.env.API_ENDPOINT,
  API_REGION: process.env.API_REGION, 
  SOURCE_API_ENDPOINT: process.env.SOURCE_API_ENDPOINT,
  SOURCE_API_REGION: process.env.SOURCE_API_REGION,
  TARGET_API_ENDPOINT: process.env.TARGET_API_ENDPOINT,
  TARGET_API_REGION: process.env.TARGET_API_REGION,
  // Where a specific endpoint and/or region is not provided, 
  // API_ENDPOINT and API_REGION will used.
  TO_DISK_PATH: "/path/to/backup/directory",
};

const cloner = new StoryblokSpaceCloner(config);

cloner.copy({
  assets: true,
  // TODO: add toDisk option for `assets`.
  // Currently if toDisk is set to true for `assets`,
  // it will not work, nor will it copy assets to the target space.
  components: { toDisk: false },
  /*
    Options for components: 
    {
      toDisk: boolean, 
      fromDisk: { path: string }
    }
    If `fromDisk` option exists, `toDisk` is ignored.
    For `fromDisk` option, `path` is the local absolute path directory and 
    should have both `component_groups` and `components` directories within it.
    These are the same direcories created when using the `toDisk` option
  */
  stories: { toDisk: false },
  // TODO: add fromDisk – will need to consider assets: local and/or remote
});

Run

node --import ./esm-loader.mjs app.ts

Plugins

In the plugins folder, there are Storyblok packages. These are field type plugins for Storyblok's visual UI. Not related to the main cloning features, but perhaps usefull to some. We will continue to add more of them.

License

This project is licensed under the MIT License.