Skip to content
Merged
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
18 changes: 16 additions & 2 deletions src/commands/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { useYesNoConfirm } from '../lib/hooks/user-confirmations/useYesNoConfirm
import { createPrefilledInputFileFromInputSchema } from '../lib/input_schema.js';
import { error, info, success, warning } from '../lib/outputs.js';
import { wrapScrapyProject } from '../lib/projects/scrapy/wrapScrapyProject.js';
import { setLocalConfig, setLocalEnv, validateActorName } from '../lib/utils.js';
import { sanitizeActorName, setLocalConfig, setLocalEnv, validateActorName } from '../lib/utils.js';

export class InitCommand extends ApifyCommand<typeof InitCommand> {
static override name = 'init' as const;
Expand Down Expand Up @@ -57,6 +57,20 @@ export class InitCommand extends ApifyCommand<typeof InitCommand> {

const project = projectResult.unwrap();

if (project.warnings?.length) {
for (const w of project.warnings) {
warning({ message: w });
}
}

let defaultActorName = basename(cwd);
if (project.type === ProjectLanguage.Python && project.entrypoint?.path) {
const entryPath = project.entrypoint.path;
// Extract the actual package name (last segment of dotted path)
const packageName = entryPath.includes('.') ? entryPath.split('.').pop()! : entryPath;
defaultActorName = sanitizeActorName(packageName);
}

if (project.type === ProjectLanguage.Scrapy) {
info({ message: 'The current directory looks like a Scrapy project. Using automatic project wrapping.' });
this.telemetryData.actorWrapper = 'scrapy';
Expand Down Expand Up @@ -100,7 +114,7 @@ export class InitCommand extends ApifyCommand<typeof InitCommand> {
try {
const answer = await useUserInput({
message: 'Actor name:',
default: basename(cwd),
default: defaultActorName,
});

validateActorName(answer);
Expand Down
6 changes: 6 additions & 0 deletions src/commands/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,12 @@ export class RunCommand extends ApifyCommand<typeof RunCommand> {
const project = projectRuntimeResult.unwrap();
const { type, entrypoint: cwdEntrypoint, runtime } = project;

if (project.warnings?.length) {
for (const w of project.warnings) {
warning({ message: w });
}
}

if (type === ProjectLanguage.Unknown) {
throw new Error(
'Actor is of an unknown format.' +
Expand Down
Loading