Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(create): merge local development instructions into README #372

Merged
merged 10 commits into from
Jun 21, 2023
11 changes: 10 additions & 1 deletion src/commands/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class CreateCommand extends ApifyCommand {
// for testing of templates that are not yet published in the manifest
let { templateArchiveUrl } = flags;
let skipOptionalDeps = false;
let localReadmeSuffix = '';

// Start fetching manifest immediately to prevent
// annoying delays that sometimes happen on CLI startup.
Expand All @@ -50,7 +51,7 @@ class CreateCommand extends ApifyCommand {
actorName = await ensureValidActorName(actorName);
let messages = null;
if (manifestPromise) {
({ archiveUrl: templateArchiveUrl, skipOptionalDeps, messages } = await getTemplateDefinition(templateName, manifestPromise));
({ archiveUrl: templateArchiveUrl, skipOptionalDeps, messages, localReadmeSuffix } = await getTemplateDefinition(templateName, manifestPromise));
monkey-denky marked this conversation as resolved.
Show resolved Hide resolved
}

const cwd = process.cwd();
Expand Down Expand Up @@ -82,6 +83,14 @@ class CreateCommand extends ApifyCommand {

const packageJsonPath = path.join(actFolderDir, 'package.json');
const requirementsTxtPath = path.join(actFolderDir, 'requirements.txt');
const readmePath = path.join(actFolderDir, 'README.md');

// Add localReadmeSuffix which is fetched from manifest to README.md
// The suffix contains local development instructions
if (fs.existsSync(readmePath)) {
monkey-denky marked this conversation as resolved.
Show resolved Hide resolved
const readmeContent = fs.readFileSync(readmePath, 'utf8');
fs.writeFileSync(readmePath, `${readmeContent}\n\n${localReadmeSuffix}`);
}

let dependenciesInstalled = false;
if (!skipDependencyInstall) {
Expand Down