create-zephyr-apps
Version:
A CLI tool to create web applications using Zephyr.
46 lines (45 loc) • 2.34 kB
JavaScript
import node_path from "node:path";
import { getTemplate } from "./templates.js";
function createNextSteps(options) {
const relativeDirectory = node_path.relative(options.invocationDirectory, options.outputDirectory) || node_path.basename(options.outputDirectory);
const changeDirectory = `cd ./${relativeDirectory}`;
const alreadyInstalled = options.alreadyInstalled || options.alreadyBuilt;
if ('react-native' === options.projectType) {
const repositoryName = node_path.basename(options.outputDirectory);
const commands = [
changeDirectory,
...alreadyInstalled ? [] : [
`${options.packageManager} install`
],
`git remote add origin https://github.com/<name>/${repositoryName}.git`,
`ZC=1 ${options.packageManager} start`
];
return {
commands: commands.join('\n'),
commandsTitle: 'Run the application!',
guidance: {
body: "Make sure to commit and add a remote to the remote repository!\nRead more about how Module Federation works with Zephyr:\n- https://docs.zephyr-cloud.io/tutorials/mf-guide",
title: 'Read more about Module Federation'
},
documentationUrl: 'https://docs.zephyr-cloud.io/bundlers/repack'
};
}
const commands = [
changeDirectory
];
if (!alreadyInstalled) commands.push(`${options.packageManager} install`);
if (!options.alreadyBuilt) commands.push(`${options.packageManager} run build`);
const bundlerDocumentation = options.template ? getTemplate(options.template)?.bundlerDocumentation : void 0;
return {
commands: commands.join('\n'),
commandsTitle: options.alreadyBuilt ? 'Project built successfully!' : 'Run the application!',
documentationUrl: bundlerDocumentation ? `https://docs.zephyr-cloud.io/bundlers/${bundlerDocumentation}` : 'https://docs.zephyr-cloud.io/getting-started/quick-start'
};
}
function formatScaffoldFailure(error) {
const lastFailure = error.receipt.failures[error.receipt.failures.length - 1];
const stderr = lastFailure?.stderr?.trim();
return stderr ? `${error.message}\n\n${stderr}` : error.message;
}
export { createNextSteps, formatScaffoldFailure };
//# sourceMappingURL=presentation.js.map