storyblok 4.8.0 → 4.9.0
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 +110 -99
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1952,7 +1952,7 @@ function buildDependencyGraph(context) {
|
|
|
1952
1952
|
graph.nodes.set(nodeId, node);
|
|
1953
1953
|
});
|
|
1954
1954
|
spaceState.local.groups.forEach((group) => {
|
|
1955
|
-
if (group.parent_uuid) {
|
|
1955
|
+
if (group.parent_uuid && group.parent_id && group.parent_uuid !== group.uuid) {
|
|
1956
1956
|
const childId = `group:${group.uuid}`;
|
|
1957
1957
|
const parentId = `group:${group.parent_uuid}`;
|
|
1958
1958
|
addDependency(childId, parentId);
|
|
@@ -2852,7 +2852,8 @@ componentsCommand.command("push [componentName]").description(`Push your space's
|
|
|
2852
2852
|
konsola.title(`${commands.COMPONENTS}`, colorPalette.COMPONENTS, componentName ? `Pushing component ${componentName}...` : "Pushing components...");
|
|
2853
2853
|
const verbose = program$a.opts().verbose;
|
|
2854
2854
|
const { space, path } = componentsCommand.opts();
|
|
2855
|
-
const {
|
|
2855
|
+
const { filter } = options;
|
|
2856
|
+
const fromSpace = options.from || space;
|
|
2856
2857
|
const { state, initializeSession } = session();
|
|
2857
2858
|
await initializeSession();
|
|
2858
2859
|
if (!requireAuthentication(state, verbose)) {
|
|
@@ -2862,10 +2863,7 @@ componentsCommand.command("push [componentName]").description(`Push your space's
|
|
|
2862
2863
|
handleError(new CommandError(`Please provide the target space as argument --space TARGET_SPACE_ID.`), verbose);
|
|
2863
2864
|
return;
|
|
2864
2865
|
}
|
|
2865
|
-
|
|
2866
|
-
options.from = space;
|
|
2867
|
-
}
|
|
2868
|
-
konsola.info(`Attempting to push components ${chalk.bold("from")} space ${chalk.hex(colorPalette.COMPONENTS)(options.from)} ${chalk.bold("to")} ${chalk.hex(colorPalette.COMPONENTS)(space)}`);
|
|
2866
|
+
konsola.info(`Attempting to push components ${chalk.bold("from")} space ${chalk.hex(colorPalette.COMPONENTS)(fromSpace)} ${chalk.bold("to")} ${chalk.hex(colorPalette.COMPONENTS)(space)}`);
|
|
2869
2867
|
konsola.br();
|
|
2870
2868
|
const { password, region } = state;
|
|
2871
2869
|
let requestCount = 0;
|
|
@@ -2883,7 +2881,7 @@ componentsCommand.command("push [componentName]").description(`Push your space's
|
|
|
2883
2881
|
const componentsData = await readComponentsFiles({
|
|
2884
2882
|
...options,
|
|
2885
2883
|
path,
|
|
2886
|
-
|
|
2884
|
+
from: fromSpace
|
|
2887
2885
|
});
|
|
2888
2886
|
const localData = {
|
|
2889
2887
|
...componentsData,
|
|
@@ -4869,7 +4867,7 @@ const upsertDatasourceEntry = async (space, datasourceId, entry, existingId) =>
|
|
|
4869
4867
|
}
|
|
4870
4868
|
};
|
|
4871
4869
|
const readDatasourcesFiles = async (options) => {
|
|
4872
|
-
const { from, path, separateFiles = false, suffix
|
|
4870
|
+
const { from, path, separateFiles = false, suffix } = options;
|
|
4873
4871
|
const resolvedPath = resolvePath(path, `datasources/${from}`);
|
|
4874
4872
|
try {
|
|
4875
4873
|
await readdir(resolvedPath);
|
|
@@ -4880,7 +4878,7 @@ const readDatasourcesFiles = async (options) => {
|
|
|
4880
4878
|
${chalk.cyan(`storyblok datasources pull --space ${from}`)}
|
|
4881
4879
|
|
|
4882
4880
|
2. Then try pushing again:
|
|
4883
|
-
${chalk.cyan(`storyblok datasources push --space
|
|
4881
|
+
${chalk.cyan(`storyblok datasources push --space <target_space> --from ${from}`)}`;
|
|
4884
4882
|
throw new FileSystemError(
|
|
4885
4883
|
"file_not_found",
|
|
4886
4884
|
"read",
|
|
@@ -5180,7 +5178,8 @@ datasourcesCommand.command("push [datasourceName]").description(`Push your space
|
|
|
5180
5178
|
konsola.title(`${commands.DATASOURCES}`, colorPalette.DATASOURCES, datasourceName ? `Pushing datasource ${datasourceName}...` : "Pushing datasources...");
|
|
5181
5179
|
const verbose = program$3.opts().verbose;
|
|
5182
5180
|
const { space, path } = datasourcesCommand.opts();
|
|
5183
|
-
const {
|
|
5181
|
+
const { filter } = options;
|
|
5182
|
+
const fromSpace = options.from || space;
|
|
5184
5183
|
const { state, initializeSession } = session();
|
|
5185
5184
|
await initializeSession();
|
|
5186
5185
|
if (!requireAuthentication(state, verbose)) {
|
|
@@ -5190,10 +5189,7 @@ datasourcesCommand.command("push [datasourceName]").description(`Push your space
|
|
|
5190
5189
|
handleError(new CommandError(`Please provide the target space as argument --space TARGET_SPACE_ID.`), verbose);
|
|
5191
5190
|
return;
|
|
5192
5191
|
}
|
|
5193
|
-
|
|
5194
|
-
options.from = space;
|
|
5195
|
-
}
|
|
5196
|
-
konsola.info(`Attempting to push datasources ${chalk.bold("from")} space ${chalk.hex(colorPalette.DATASOURCES)(options.from || space)} ${chalk.bold("to")} ${chalk.hex(colorPalette.DATASOURCES)(space)}`);
|
|
5192
|
+
konsola.info(`Attempting to push datasources ${chalk.bold("from")} space ${chalk.hex(colorPalette.DATASOURCES)(fromSpace)} ${chalk.bold("to")} ${chalk.hex(colorPalette.DATASOURCES)(space)}`);
|
|
5197
5193
|
konsola.br();
|
|
5198
5194
|
const { password, region } = state;
|
|
5199
5195
|
mapiClient({
|
|
@@ -5207,7 +5203,7 @@ datasourcesCommand.command("push [datasourceName]").description(`Push your space
|
|
|
5207
5203
|
local: await readDatasourcesFiles({
|
|
5208
5204
|
...options,
|
|
5209
5205
|
path,
|
|
5210
|
-
|
|
5206
|
+
from: fromSpace
|
|
5211
5207
|
}),
|
|
5212
5208
|
target: {
|
|
5213
5209
|
datasources: /* @__PURE__ */ new Map()
|
|
@@ -5495,11 +5491,33 @@ const fetchBlueprintRepositories = async () => {
|
|
|
5495
5491
|
}
|
|
5496
5492
|
};
|
|
5497
5493
|
|
|
5494
|
+
function showNextSteps(technologyTemplate, finalProjectPath) {
|
|
5495
|
+
konsola.br();
|
|
5496
|
+
konsola.ok(`Your ${chalk.hex(colorPalette.PRIMARY)(technologyTemplate)} project is ready \u{1F389} !`);
|
|
5497
|
+
konsola.br();
|
|
5498
|
+
konsola.info(`Next steps:
|
|
5499
|
+
cd ${finalProjectPath}
|
|
5500
|
+
npm install
|
|
5501
|
+
npm run dev
|
|
5502
|
+
`);
|
|
5503
|
+
konsola.info(`Or check the dedicated guide at: ${chalk.hex(colorPalette.PRIMARY)(`https://www.storyblok.com/docs/guides/${technologyTemplate}`)}`);
|
|
5504
|
+
}
|
|
5505
|
+
async function handleEnvFileCreation(resolvedPath, token) {
|
|
5506
|
+
try {
|
|
5507
|
+
await createEnvFile(resolvedPath, token);
|
|
5508
|
+
konsola.ok(`Created .env file with Storyblok access token`, true);
|
|
5509
|
+
return true;
|
|
5510
|
+
} catch (error) {
|
|
5511
|
+
konsola.warn(`Failed to create .env file: ${error.message}`);
|
|
5512
|
+
konsola.info(`You can manually add this token to your .env file: ${token}`);
|
|
5513
|
+
return false;
|
|
5514
|
+
}
|
|
5515
|
+
}
|
|
5498
5516
|
const program$2 = getProgram();
|
|
5499
|
-
program$2.command(`${commands.CREATE} [project-path]`).alias("c").description(`Scaffold a new project using Storyblok`).option("-t, --template <template>", "technology starter template").option("-b, --blueprint <blueprint>", "[DEPRECATED] use --template instead").option("--skip-space", "skip space creation").action(async (projectPath, options) => {
|
|
5517
|
+
program$2.command(`${commands.CREATE} [project-path]`).alias("c").description(`Scaffold a new project using Storyblok`).option("-t, --template <template>", "technology starter template").option("-b, --blueprint <blueprint>", "[DEPRECATED] use --template instead").option("--skip-space", "skip space creation").option("--token <token>", "Storyblok access token (skip space creation and use this token)").action(async (projectPath, options) => {
|
|
5500
5518
|
konsola.title(`${commands.CREATE}`, colorPalette.CREATE);
|
|
5501
5519
|
const verbose = program$2.opts().verbose;
|
|
5502
|
-
const { template, blueprint } = options;
|
|
5520
|
+
const { template, blueprint, token } = options;
|
|
5503
5521
|
let selectedTemplate = template;
|
|
5504
5522
|
if (blueprint && !template) {
|
|
5505
5523
|
konsola.warn(`The --blueprint flag is deprecated. Please use --template instead.`);
|
|
@@ -5525,18 +5543,6 @@ program$2.command(`${commands.CREATE} [project-path]`).alias("c").description(`S
|
|
|
5525
5543
|
const spinnerSpace = new Spinner({
|
|
5526
5544
|
verbose: !isVitest
|
|
5527
5545
|
});
|
|
5528
|
-
let userData;
|
|
5529
|
-
try {
|
|
5530
|
-
const user = await getUser(password, region);
|
|
5531
|
-
if (!user) {
|
|
5532
|
-
throw new Error("User data is undefined");
|
|
5533
|
-
}
|
|
5534
|
-
userData = user;
|
|
5535
|
-
} catch (error) {
|
|
5536
|
-
konsola.error("Failed to fetch user info. Please login again.", error);
|
|
5537
|
-
konsola.br();
|
|
5538
|
-
return;
|
|
5539
|
-
}
|
|
5540
5546
|
try {
|
|
5541
5547
|
spinnerBlueprints.start("Fetching starter templates...");
|
|
5542
5548
|
const templates = await fetchBlueprintRepositories();
|
|
@@ -5592,91 +5598,96 @@ program$2.command(`${commands.CREATE} [project-path]`).alias("c").description(`S
|
|
|
5592
5598
|
await generateProject(technologyTemplate, projectName, targetDirectory);
|
|
5593
5599
|
konsola.ok(`Project ${chalk.hex(colorPalette.PRIMARY)(projectName)} created successfully in ${chalk.hex(colorPalette.PRIMARY)(finalProjectPath)}`, true);
|
|
5594
5600
|
let createdSpace;
|
|
5595
|
-
|
|
5596
|
-
{ name: "My personal account", value: "personal" }
|
|
5597
|
-
];
|
|
5598
|
-
if (userData.has_org) {
|
|
5599
|
-
choices.push({ name: `Organization (${userData?.org?.name})`, value: "org" });
|
|
5600
|
-
}
|
|
5601
|
-
if (userData.has_partner) {
|
|
5602
|
-
choices.push({ name: "Partner Portal", value: "partner" });
|
|
5603
|
-
}
|
|
5601
|
+
let userData;
|
|
5604
5602
|
let whereToCreateSpace = "personal";
|
|
5605
|
-
if (
|
|
5606
|
-
|
|
5607
|
-
|
|
5608
|
-
|
|
5609
|
-
});
|
|
5610
|
-
}
|
|
5611
|
-
if (region !== "eu" && userData.has_org) {
|
|
5612
|
-
whereToCreateSpace = "org";
|
|
5603
|
+
if (token) {
|
|
5604
|
+
await handleEnvFileCreation(resolvedPath, token);
|
|
5605
|
+
showNextSteps(technologyTemplate, finalProjectPath);
|
|
5606
|
+
return;
|
|
5613
5607
|
}
|
|
5614
|
-
if (
|
|
5615
|
-
|
|
5616
|
-
konsola.br();
|
|
5608
|
+
if (options.skipSpace) {
|
|
5609
|
+
showNextSteps(technologyTemplate, finalProjectPath);
|
|
5617
5610
|
return;
|
|
5618
5611
|
}
|
|
5619
|
-
|
|
5612
|
+
try {
|
|
5620
5613
|
try {
|
|
5621
|
-
|
|
5622
|
-
|
|
5623
|
-
|
|
5624
|
-
const spaceToCreate = {
|
|
5625
|
-
name: toHumanReadable(projectName),
|
|
5626
|
-
domain: blueprintDomain
|
|
5627
|
-
};
|
|
5628
|
-
if (whereToCreateSpace === "org") {
|
|
5629
|
-
spaceToCreate.org = userData.org;
|
|
5630
|
-
spaceToCreate.in_org = true;
|
|
5631
|
-
} else if (whereToCreateSpace === "partner") {
|
|
5632
|
-
spaceToCreate.assign_partner = true;
|
|
5614
|
+
const user = await getUser(password, region);
|
|
5615
|
+
if (!user) {
|
|
5616
|
+
throw new Error("User data is undefined");
|
|
5633
5617
|
}
|
|
5634
|
-
|
|
5635
|
-
spinnerSpace.succeed(`Space "${chalk.hex(colorPalette.PRIMARY)(toHumanReadable(projectName))}" created successfully`);
|
|
5618
|
+
userData = user;
|
|
5636
5619
|
} catch (error) {
|
|
5637
|
-
|
|
5620
|
+
konsola.error("Failed to fetch user info. Please login again.", error);
|
|
5638
5621
|
konsola.br();
|
|
5639
|
-
handleError(error, verbose);
|
|
5640
5622
|
return;
|
|
5641
5623
|
}
|
|
5642
|
-
|
|
5643
|
-
|
|
5644
|
-
|
|
5645
|
-
|
|
5646
|
-
|
|
5647
|
-
} catch (error) {
|
|
5648
|
-
konsola.warn(`Failed to create .env file: ${error.message}`);
|
|
5649
|
-
konsola.info(`You can manually add this token to your .env file: ${createdSpace.first_token}`);
|
|
5624
|
+
const choices = [
|
|
5625
|
+
{ name: "My personal account", value: "personal" }
|
|
5626
|
+
];
|
|
5627
|
+
if (userData.has_org) {
|
|
5628
|
+
choices.push({ name: `Organization (${userData?.org?.name})`, value: "org" });
|
|
5650
5629
|
}
|
|
5651
|
-
|
|
5652
|
-
|
|
5653
|
-
try {
|
|
5654
|
-
await openSpaceInBrowser(createdSpace.id, region);
|
|
5655
|
-
konsola.info(`Opened space in your browser`);
|
|
5656
|
-
} catch (error) {
|
|
5657
|
-
konsola.warn(`Failed to open browser: ${error.message}`);
|
|
5658
|
-
const spaceUrl = generateSpaceUrl(createdSpace.id, region);
|
|
5659
|
-
konsola.info(`You can manually open your space at: ${chalk.hex(colorPalette.PRIMARY)(spaceUrl)}`);
|
|
5630
|
+
if (userData.has_partner) {
|
|
5631
|
+
choices.push({ name: "Partner Portal", value: "partner" });
|
|
5660
5632
|
}
|
|
5661
|
-
|
|
5662
|
-
|
|
5663
|
-
|
|
5664
|
-
|
|
5633
|
+
if (region === regions.EU && (userData.has_partner || userData.has_org)) {
|
|
5634
|
+
whereToCreateSpace = await select({
|
|
5635
|
+
message: `Where would you like to create this space?`,
|
|
5636
|
+
choices
|
|
5637
|
+
});
|
|
5638
|
+
}
|
|
5639
|
+
if (region !== regions.EU && userData.has_org) {
|
|
5640
|
+
whereToCreateSpace = "org";
|
|
5641
|
+
}
|
|
5642
|
+
if (region !== regions.EU && !userData.has_org) {
|
|
5643
|
+
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.`);
|
|
5644
|
+
konsola.br();
|
|
5645
|
+
return;
|
|
5646
|
+
}
|
|
5647
|
+
spinnerSpace.start(`Creating space "${toHumanReadable(projectName)}"`);
|
|
5648
|
+
const selectedBlueprint = templates.find((bp) => bp.value === technologyTemplate);
|
|
5649
|
+
const blueprintDomain = selectedBlueprint?.location || "https://localhost:3000/";
|
|
5650
|
+
const spaceToCreate = {
|
|
5651
|
+
name: toHumanReadable(projectName),
|
|
5652
|
+
domain: blueprintDomain
|
|
5653
|
+
};
|
|
5665
5654
|
if (whereToCreateSpace === "org") {
|
|
5666
|
-
|
|
5655
|
+
spaceToCreate.org = userData.org;
|
|
5656
|
+
spaceToCreate.in_org = true;
|
|
5667
5657
|
} else if (whereToCreateSpace === "partner") {
|
|
5668
|
-
|
|
5669
|
-
} else {
|
|
5670
|
-
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))}`);
|
|
5658
|
+
spaceToCreate.assign_partner = true;
|
|
5671
5659
|
}
|
|
5660
|
+
createdSpace = await createSpace(spaceToCreate);
|
|
5661
|
+
spinnerSpace.succeed(`Space "${chalk.hex(colorPalette.PRIMARY)(toHumanReadable(projectName))}" created successfully`);
|
|
5662
|
+
if (createdSpace?.first_token) {
|
|
5663
|
+
await handleEnvFileCreation(resolvedPath, createdSpace.first_token);
|
|
5664
|
+
}
|
|
5665
|
+
if (createdSpace?.id) {
|
|
5666
|
+
try {
|
|
5667
|
+
await openSpaceInBrowser(createdSpace.id, region);
|
|
5668
|
+
konsola.info(`Opened space in your browser`);
|
|
5669
|
+
} catch (error) {
|
|
5670
|
+
konsola.warn(`Failed to open browser: ${error.message}`);
|
|
5671
|
+
const spaceUrl = generateSpaceUrl(createdSpace.id, region);
|
|
5672
|
+
konsola.info(`You can manually open your space at: ${chalk.hex(colorPalette.PRIMARY)(spaceUrl)}`);
|
|
5673
|
+
}
|
|
5674
|
+
}
|
|
5675
|
+
showNextSteps(technologyTemplate, finalProjectPath);
|
|
5676
|
+
if (createdSpace?.first_token) {
|
|
5677
|
+
if (whereToCreateSpace === "org") {
|
|
5678
|
+
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))}`);
|
|
5679
|
+
} else if (whereToCreateSpace === "partner") {
|
|
5680
|
+
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))}`);
|
|
5681
|
+
} else {
|
|
5682
|
+
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))}`);
|
|
5683
|
+
}
|
|
5684
|
+
}
|
|
5685
|
+
} catch (error) {
|
|
5686
|
+
spinnerSpace.failed();
|
|
5687
|
+
konsola.br();
|
|
5688
|
+
handleError(error, verbose);
|
|
5689
|
+
return;
|
|
5672
5690
|
}
|
|
5673
|
-
konsola.br();
|
|
5674
|
-
konsola.info(`Next steps:
|
|
5675
|
-
cd ${finalProjectPath}
|
|
5676
|
-
npm install
|
|
5677
|
-
npm run dev
|
|
5678
|
-
`);
|
|
5679
|
-
konsola.info(`Or check the dedicated guide at: ${chalk.hex(colorPalette.PRIMARY)(`https://www.storyblok.com/docs/guides/${technologyTemplate}`)}`);
|
|
5680
5691
|
} catch (error) {
|
|
5681
5692
|
spinnerSpace.failed();
|
|
5682
5693
|
spinnerBlueprints.failed();
|
|
@@ -5710,7 +5721,7 @@ logsCommand.command("prune").description("Prune logs").option("--keep <number>",
|
|
|
5710
5721
|
ui.info(`Deleted ${deletedFilesCount} log file${deletedFilesCount === 1 ? "" : "s"}`);
|
|
5711
5722
|
});
|
|
5712
5723
|
|
|
5713
|
-
const version = "4.
|
|
5724
|
+
const version = "4.9.0";
|
|
5714
5725
|
const pkg = {
|
|
5715
5726
|
version: version};
|
|
5716
5727
|
|