Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 13 additions & 12 deletions src/commands/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,12 @@ import {
PYTHON_VENV_PATH,
SUPPORTED_NODEJS_VERSION,
} from '../lib/consts.js';
import { enhanceReadmeWithLocalSuffix, ensureValidActorName, getTemplateDefinition } from '../lib/create-utils.js';
import {
enhanceReadmeWithLocalSuffix,
ensureValidActorName,
formatCreateSuccessMessage,
getTemplateDefinition,
} from '../lib/create-utils.js';
import { execWithLog } from '../lib/exec.js';
import { updateLocalJson } from '../lib/files.js';
import { usePythonRuntime } from '../lib/hooks/runtimes/python.js';
Expand Down Expand Up @@ -329,17 +334,13 @@ export class CreateCommand extends ApifyCommand<typeof CreateCommand> {
}
}

if (dependenciesInstalled) {
success({ message: `Actor '${actorName}' was created. To run it, run "cd ${actorName}" and "apify run".` });
info({ message: 'To run your code in the cloud, run "apify push" and deploy your code to Apify Console.' });
if (messages?.postCreate) {
info({ message: messages?.postCreate });
}
} else {
success({
message: `Actor '${actorName}' was created. Please install its dependencies to be able to run it using "apify run".`,
});
}
success({
message: formatCreateSuccessMessage({
actorName,
dependenciesInstalled,
postCreate: messages?.postCreate ?? null,
}),
});

// Report git initialization result after actor creation success
if (!skipGitInit && !cwdHasGit) {
Expand Down
27 changes: 25 additions & 2 deletions src/lib/create-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,30 @@ export async function enhanceReadmeWithLocalSuffix(readmePath: string, manifestP
}
}

export function formatCreateSuccessMessage(params: {
actorName: string;
dependenciesInstalled: boolean;
postCreate?: string | null;
}) {
const { actorName, dependenciesInstalled, postCreate } = params;

let message = `✅ Actor '${actorName}' created successfully!`;

if (dependenciesInstalled) {
message += `\n\nNext steps:\n\ncd '${actorName}'\napify run`;
} else {
message += `\n\nNext steps:\n\ncd '${actorName}'\ninstall dependencies\napify run`;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it feels a bit weird that in the middle of two actual bash commands you have install dependencies. can we use npm install or similar, where we can properly detect it? i believe we already have this information somewhere, @vladfrangu will know better

}

message += `\n\n💡 Tip: Use 'apify push' to deploy your Actor to the Apify platform\n📖 Docs: https://docs.apify.com/platform/actors/development`;

if (postCreate) {
message += `\n\n${postCreate}`;
}

return message;
}

/**
* Inquirer does not have a native way to "go back" between prompts.
*/
Expand Down Expand Up @@ -134,8 +158,7 @@ async function promptTemplateDefinition(manifest: Manifest, programmingLanguage:
];

const templateDefinition = await useSelectFromList({
message:
'Choose a template for your new Actor. Detailed information about the template will be shown in the next step.',
message: 'Choose a template for your new Actor. You can check more information at https://apify.com/templates.',
default: choices[0],
choices,
loop: false,
Expand Down
Loading