Skip to content

Commit 318d7ec

Browse files
committed
chore: finish almost everything in oclif->yargs, only help remains
1 parent d15a56a commit 318d7ec

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+327
-194
lines changed

src/commands/_register.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
1+
import { ActorIndexCommand } from './actor/_index.js';
2+
import { ActorsIndexCommand } from './actors/_index.js';
3+
import { BuildsIndexCommand } from './builds/_index.js';
4+
import { TopLevelCallCommand } from './call.js';
15
import { CheckVersionCommand } from './check-version.js';
26
import { CreateCommand } from './create.js';
7+
import { DatasetsIndexCommand } from './datasets/_index.js';
38
import { EditInputSchemaCommand } from './edit-input-schema.js';
49
import { InfoCommand } from './info.js';
510
import { WrapScrapyCommand } from './init-wrap-scrapy.js';
@@ -19,12 +24,17 @@ import type { BuiltApifyCommand } from '../lib/command-framework/apify-command.j
1924

2025
export const apifyCommands: (typeof BuiltApifyCommand)[] = [
2126
// namespaces
27+
ActorIndexCommand,
28+
ActorsIndexCommand,
29+
BuildsIndexCommand,
30+
DatasetsIndexCommand,
2231
KeyValueStoresIndexCommand,
2332
RequestQueuesIndexCommand,
2433
RunsIndexCommand,
2534
SecretsIndexCommand,
2635
TasksIndexCommand,
2736
// top-level
37+
TopLevelCallCommand,
2838
CheckVersionCommand,
2939
CreateCommand,
3040
EditInputSchemaCommand,

src/commands/actor/_index.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { ActorChargeCommand } from './charge.js';
2+
import { ActorGetInputCommand } from './get-input.js';
3+
import { ActorGetPublicUrlCommand } from './get-public-url.js';
4+
import { ActorGetValueCommand } from './get-value.js';
5+
import { ActorPushDataCommand } from './push-data.js';
6+
import { ActorSetValueCommand } from './set-value.js';
7+
import { ApifyCommand } from '../../lib/command-framework/apify-command.js';
8+
9+
export class ActorIndexCommand extends ApifyCommand<typeof ActorIndexCommand> {
10+
static override name = 'actor';
11+
12+
static override description = 'Manages runtime data operations inside of a running Actor.';
13+
14+
static override subcommands = [
15+
//
16+
ActorSetValueCommand,
17+
ActorPushDataCommand,
18+
ActorGetValueCommand,
19+
ActorGetPublicUrlCommand,
20+
ActorGetInputCommand,
21+
ActorChargeCommand,
22+
];
23+
24+
async run() {
25+
await this.printHelp();
26+
}
27+
}

src/commands/actor/charge.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import { APIFY_ENV_VARS } from '@apify/consts';
2-
import { Args, Flags } from '@oclif/core';
32

43
import { getApifyTokenFromEnvOrAuthFile } from '../../lib/actor.js';
5-
import { ApifyCommand } from '../../lib/apify_command.js';
4+
import { ApifyCommand } from '../../lib/command-framework/apify-command.js';
5+
import { Args } from '../../lib/command-framework/args.js';
6+
import { Flags } from '../../lib/command-framework/flags.js';
67
import { info } from '../../lib/outputs.js';
78
import { getLoggedClient } from '../../lib/utils.js';
89

@@ -15,7 +16,9 @@ import { getLoggedClient } from '../../lib/utils.js';
1516
* - Add logic to work with the max charge USD to prevent exceeding the charging limit.
1617
* - Add logic to store events in the log dataset for later inspection to aid local development.
1718
*/
18-
export class ChargeCommand extends ApifyCommand<typeof ChargeCommand> {
19+
export class ActorChargeCommand extends ApifyCommand<typeof ActorChargeCommand> {
20+
static override name = 'charge';
21+
1922
static override description = 'Charge for a specific event in the pay-per-event Actor run.';
2023

2124
static override args = {

src/commands/actor/get-input.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { outputInputFromDefaultStore } from '../../lib/actor.js';
2-
import { ApifyCommand } from '../../lib/apify_command.js';
2+
import { ApifyCommand } from '../../lib/command-framework/apify-command.js';
33

4-
export class GetInputCommand extends ApifyCommand<typeof GetInputCommand> {
4+
export class ActorGetInputCommand extends ApifyCommand<typeof ActorGetInputCommand> {
55
static override description =
66
'Gets the Actor input value from the default key-value store associated with the Actor run.';
77

src/commands/actor/get-public-url.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
import { ACTOR_ENV_VARS, APIFY_ENV_VARS } from '@apify/consts';
2-
import { Args } from '@oclif/core';
32

4-
import { ApifyCommand } from '../../lib/apify_command.js';
3+
import { ApifyCommand } from '../../lib/command-framework/apify-command.js';
4+
import { Args } from '../../lib/command-framework/args.js';
55
import { CommandExitCodes } from '../../lib/consts.js';
66
import { error } from '../../lib/outputs.js';
77

8-
export class GetPublicUrlCommand extends ApifyCommand<typeof GetPublicUrlCommand> {
8+
export class ActorGetPublicUrlCommand extends ApifyCommand<typeof ActorGetPublicUrlCommand> {
9+
static override name = 'get-public-url';
10+
911
static override description = 'Get an HTTP URL that allows public access to a key-value store item.';
1012

1113
static override args = {

src/commands/actor/get-value.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
import { Args } from '@oclif/core';
2-
31
import { outputRecordFromDefaultStore } from '../../lib/actor.js';
4-
import { ApifyCommand } from '../../lib/apify_command.js';
2+
import { ApifyCommand } from '../../lib/command-framework/apify-command.js';
3+
import { Args } from '../../lib/command-framework/args.js';
4+
5+
export class ActorGetValueCommand extends ApifyCommand<typeof ActorGetValueCommand> {
6+
static override name = 'get-value';
57

6-
export class GetValueCommand extends ApifyCommand<typeof GetValueCommand> {
78
static override description = 'Gets a value from the default key-value store associated with the Actor run.';
89

910
static override args = {

src/commands/actor/index.ts

Lines changed: 0 additions & 9 deletions
This file was deleted.

src/commands/actor/push-data.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
import { Args } from '@oclif/core';
2-
31
import { APIFY_STORAGE_TYPES, getApifyStorageClient, getDefaultStorageId } from '../../lib/actor.js';
4-
import { ApifyCommand } from '../../lib/apify_command.js';
2+
import { ApifyCommand } from '../../lib/command-framework/apify-command.js';
3+
import { Args } from '../../lib/command-framework/args.js';
54
import { readStdin } from '../../lib/commands/read-stdin.js';
65
import { error } from '../../lib/outputs.js';
76

8-
export class PushDataCommand extends ApifyCommand<typeof PushDataCommand> {
7+
export class ActorPushDataCommand extends ApifyCommand<typeof ActorPushDataCommand> {
8+
static override name = 'push-data';
9+
910
static override description =
1011
"Saves data to Actor's run default dataset.\n\n" +
1112
'Accept input as:\n' +
@@ -24,7 +25,7 @@ export class PushDataCommand extends ApifyCommand<typeof PushDataCommand> {
2425
async run() {
2526
const { item: _item } = this.args;
2627

27-
const item = _item || (await readStdin(process.stdin));
28+
const item = _item || (await readStdin());
2829

2930
if (!item) {
3031
error({ message: 'No item was provided.' });

src/commands/actor/set-value.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
import { Args, Flags } from '@oclif/core';
2-
31
import { APIFY_STORAGE_TYPES, getApifyStorageClient, getDefaultStorageId } from '../../lib/actor.js';
4-
import { ApifyCommand } from '../../lib/apify_command.js';
2+
import { ApifyCommand } from '../../lib/command-framework/apify-command.js';
3+
import { Args } from '../../lib/command-framework/args.js';
4+
import { Flags } from '../../lib/command-framework/flags.js';
5+
6+
export class ActorSetValueCommand extends ApifyCommand<typeof ActorSetValueCommand> {
7+
static override name = 'set-value';
58

6-
export class SetValueCommand extends ApifyCommand<typeof SetValueCommand> {
79
static override description =
810
'Sets or removes record into the default key-value store associated with the Actor run.\n\n' +
911
'It is possible to pass data using argument or stdin.\n\n' +
@@ -16,7 +18,6 @@ export class SetValueCommand extends ApifyCommand<typeof SetValueCommand> {
1618
key: Args.string({
1719
required: true,
1820
description: 'Key of the record in key-value store.',
19-
ignoreStdin: true,
2021
}),
2122
value: Args.string({
2223
required: false,
@@ -25,7 +26,6 @@ export class SetValueCommand extends ApifyCommand<typeof SetValueCommand> {
2526
'- If empty, the record in the key-value store is deleted.\n' +
2627
'- If no `contentType` flag is specified, value is expected to be any JSON string value.\n' +
2728
'- If options.contentType is set, value is taken as is.',
28-
ignoreStdin: true,
2929
}),
3030
};
3131

src/commands/actors/_index.ts

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,30 @@
1-
import { ApifyCommand } from '../../lib/apify_command.js';
1+
import { ActorsBuildCommand } from './build.js';
2+
import { ActorsCallCommand } from './call.js';
3+
import { ActorsInfoCommand } from './info.js';
4+
import { ActorsLsCommand } from './ls.js';
5+
import { ActorsPullCommand } from './pull.js';
6+
import { ActorsPushCommand } from './push.js';
7+
import { ActorsRmCommand } from './rm.js';
8+
import { ActorsStartCommand } from './start.js';
9+
import { ApifyCommand } from '../../lib/command-framework/apify-command.js';
10+
11+
export class ActorsIndexCommand extends ApifyCommand<typeof ActorsIndexCommand> {
12+
static override name = 'actors';
213

3-
export class ActorIndexCommand extends ApifyCommand<typeof ActorIndexCommand> {
414
static override description = 'Manages Actor creation, deployment, and execution on the Apify platform.';
515

16+
static override subcommands = [
17+
//
18+
ActorsStartCommand,
19+
ActorsRmCommand,
20+
ActorsPushCommand,
21+
ActorsPullCommand,
22+
ActorsLsCommand,
23+
ActorsInfoCommand,
24+
ActorsCallCommand,
25+
ActorsBuildCommand,
26+
];
27+
628
async run() {
729
await this.printHelp();
830
}

0 commit comments

Comments
 (0)