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
8 changes: 8 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ end_of_line = lf
# editorconfig-tools is unable to ignore longs strings or urls
max_line_length = null

[*.ts]
indent_style = tab
indent_size = 4

[*.js]
indent_style = tab
indent_size = 4

[*.md]
indent_size = 2

Expand Down
10 changes: 0 additions & 10 deletions .eslintrc.json

This file was deleted.

27 changes: 27 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"[javascript]": {
"editor.defaultFormatter": "biomejs.biome"
},
"[javascriptreact]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[json]": {
"editor.defaultFormatter": "biomejs.biome"
},
"[typescript]": {
"editor.defaultFormatter": "biomejs.biome"
},
"[typescriptreact]": {
"editor.defaultFormatter": "biomejs.biome"
},
"[jsonc]": {
"editor.defaultFormatter": "biomejs.biome"
},
"[yaml]": {
"editor.defaultFormatter": "biomejs.biome"
},
"[markdown]": {
"editor.defaultFormatter": "esbenp.prettier-vscode",
"files.trimTrailingWhitespace": false
}
}
77 changes: 77 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import prettier from 'eslint-config-prettier';
import tsEslint from 'typescript-eslint';

// eslint-disable-next-line import/extensions -- todo: the import/extensions rule should be replaced with something that can handle exports in a package.json
import apify from '@apify/eslint-config/ts';

export default [
{
ignores: [
'**/dist',
'node_modules',
'coverage',
'website/{build,.docusaurus}',
'**/*.d.ts',
'test/tmp/**/*',
'.yarn/**/*',
],
},
...apify,
prettier,
{
languageOptions: {
parser: tsEslint.parser,
parserOptions: {
project: 'tsconfig.eslint.json',
},
},
},
{
plugins: {
'@typescript-eslint': tsEslint.plugin,
},
rules: {
'no-use-before-define': 'off',
'@typescript-eslint/no-use-before-define': ['error', { functions: false }],

'no-console': 'off',

'no-param-reassign': 'off',
// We have env variables with _ in their name
'no-underscore-dangle': 'off',

// we do default exports
// TODO: remove once moved to yargs
'import/no-default-export': 'off',

'@typescript-eslint/consistent-type-imports': [
'error',
{
disallowTypeAnnotations: false,
},
],
'@typescript-eslint/consistent-type-definitions': ['error', 'interface'],

// Not ideal, but we still use any for simplicity
'@typescript-eslint/no-explicit-any': 'off',

// '@typescript-eslint/array-type': 'error',
// '@typescript-eslint/no-empty-object-type': 'off',
},
},
{
files: ['website/**/*'],
rules: {
'@typescript-eslint/no-shadow': 'off',
'no-console': 'off',
'no-undef': 'off',
},
},
{
files: ['src/**/*'],
rules: {
'no-console': 'off',
'consistent-return': 'off',
},
},
];
24 changes: 11 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
"test": "vitest run",
"test-python": "vitest run -t '.*\\[python\\]'",
"test:cucumber": "cross-env NODE_OPTIONS=\"--import tsx\" cucumber-js",
"lint": "eslint src test .yarn/plugins --ext .ts,.cjs,.mjs",
"lint:fix": "eslint src test .yarn/plugins --fix --ext .ts,.cjs,.mjs",
"lint": "eslint src test --ext .ts,.cjs,.mjs",
"lint:fix": "eslint src test --fix --ext .ts,.cjs,.mjs",
"format": "biome format . && prettier --check \"**/*.{md,yml,yaml}\"",
"format:fix": "biome format --write . && prettier --write \"**/*.{md,yml,yaml}\"",
"clean": "rimraf dist",
Expand Down Expand Up @@ -102,10 +102,9 @@
"which": "^5.0.0"
},
"devDependencies": {
"@apify/eslint-config": "^0.4.0",
"@apify/eslint-config-ts": "^0.4.1",
"@apify/tsconfig": "^0.1.0",
"@biomejs/biome": "^1.8.3",
"@apify/eslint-config": "^1.0.0",
"@apify/tsconfig": "^0.1.1",
"@biomejs/biome": "^1.9.4",
"@crawlee/types": "^3.11.1",
"@cucumber/cucumber": "^11.0.0",
"@oclif/test": "^4.0.8",
Expand All @@ -124,21 +123,20 @@
"@types/node": "^22.0.0",
"@types/semver": "^7.5.8",
"@types/which": "^3.0.4",
"@typescript-eslint/eslint-plugin": "^7.0.2",
"@typescript-eslint/parser": "^7.0.2",
"@yarnpkg/core": "^4.1.2",
"apify": "^3.2.4",
"chai": "^4.4.1",
"cross-env": "^7.0.3",
"eslint": "^8.57.0",
"eslint-config-prettier": "^10.0.0",
"lint-staged": "^15.2.8",
"eslint": "^9.25.1",
"eslint-config-prettier": "^10.1.2",
"lint-staged": "^15.5.1",
"mdast-util-from-markdown": "^2.0.2",
"mock-stdin": "^1.0.0",
"oclif": "^4.14.15",
"prettier": "^3.3.3",
"prettier": "^3.5.3",
"tsx": "^4.16.5",
"typescript": "^5.5.4",
"typescript": "^5.8.3",
"typescript-eslint": "^8.31.0",
"vitest": "^3.0.0"
},
"oclif": {
Expand Down
6 changes: 6 additions & 0 deletions renovate.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@
"groupSlug": "all-non-major",
"automerge": true,
"automergeType": "branch"
},
{
"groupName": "eslint/prettier/biome",
"automerge": true,
"groupSlug": "formatting-linting-dependencies",
"matchPackageNames": ["/eslint/", "/prettier/", "/biome/"]
}
],
"schedule": ["every weekday"]
Expand Down
3 changes: 2 additions & 1 deletion src/commands/actor/charge.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { APIFY_ENV_VARS } from '@apify/consts';
import { Args, Flags } from '@oclif/core';

import { APIFY_ENV_VARS } from '@apify/consts';

import { getApifyTokenFromEnvOrAuthFile } from '../../lib/actor.js';
import { ApifyCommand } from '../../lib/apify_command.js';
import { info } from '../../lib/outputs.js';
Expand Down
3 changes: 2 additions & 1 deletion src/commands/actor/get-public-url.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Args } from '@oclif/core';

import { ACTOR_ENV_VARS, APIFY_ENV_VARS } from '@apify/consts';
import { createHmacSignature } from '@apify/utilities';
import { Args } from '@oclif/core';

import { getApifyStorageClient } from '../../lib/actor.js';
import { ApifyCommand } from '../../lib/apify_command.js';
Expand Down
6 changes: 4 additions & 2 deletions src/commands/actors/call.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import chalk from 'chalk';

import { ApifyCommand } from '../../lib/apify_command.js';
import { getInputOverride } from '../../lib/commands/resolve-input.js';
import { SharedRunOnCloudFlags, runActorOrTaskOnCloud } from '../../lib/commands/run-on-cloud.js';
import { runActorOrTaskOnCloud, SharedRunOnCloudFlags } from '../../lib/commands/run-on-cloud.js';
import { CommandExitCodes, LOCAL_CONFIG_PATH } from '../../lib/consts.js';
import { error, simpleLog } from '../../lib/outputs.js';
import { getLocalConfig, getLocalUserInfo, getLoggedClientOrThrow, TimestampFormatter } from '../../lib/utils.js';
Expand Down Expand Up @@ -222,7 +222,9 @@ export class ActorsCallCommand extends ApifyCommand<typeof ActorsCallCommand> {
break;
}

await new Promise((resolve) => setTimeout(resolve, 250));
await new Promise((resolve) => {
setTimeout(resolve, 250);
});
} while (retries--);

const dataset = await apifyClient.dataset(datasetId).downloadItems(DownloadItemsFormat.JSON, {
Expand Down
3 changes: 2 additions & 1 deletion src/commands/actors/ls.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import type { ACTOR_JOB_STATUSES } from '@apify/consts';
import { Flags } from '@oclif/core';
import { Time } from '@sapphire/duration';
import type { Actor, ActorRunListItem, ActorTaggedBuild, PaginatedList } from 'apify-client';
import chalk from 'chalk';

import type { ACTOR_JOB_STATUSES } from '@apify/consts';

import { ApifyCommand } from '../../lib/apify_command.js';
import { prettyPrintStatus } from '../../lib/commands/pretty-print-status.js';
import { CompactMode, kSkipColumn, ResponsiveTable } from '../../lib/commands/responsive-table.js';
Expand Down
7 changes: 4 additions & 3 deletions src/commands/actors/push.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import { readFileSync, unlinkSync, statSync } from 'node:fs';
import { readFileSync, statSync, unlinkSync } from 'node:fs';
import { join, resolve } from 'node:path';
import process from 'node:process';

import { fetchManifest } from '@apify/actor-templates';
import { ACTOR_JOB_STATUSES, ACTOR_SOURCE_TYPES, MAX_MULTIFILE_BYTES } from '@apify/consts';
import { Args, Flags } from '@oclif/core';
import type { Actor, ActorCollectionCreateOptions, ActorDefaultRunOptions } from 'apify-client';
import inquirer from 'inquirer';
import isCI from 'is-ci';
import open from 'open';

import { fetchManifest } from '@apify/actor-templates';
import { ACTOR_JOB_STATUSES, ACTOR_SOURCE_TYPES, MAX_MULTIFILE_BYTES } from '@apify/consts';

import { ApifyCommand } from '../../lib/apify_command.js';
import { CommandExitCodes, DEPRECATED_LOCAL_CONFIG_NAME, LOCAL_CONFIG_PATH } from '../../lib/consts.js';
import { sumFilesSizeInBytes } from '../../lib/files.js';
Expand Down
2 changes: 1 addition & 1 deletion src/commands/actors/rm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import type { ApifyApiError } from 'apify-client';

import { ApifyCommand } from '../../lib/apify_command.js';
import { error, info, success } from '../../lib/outputs.js';
import { confirmAction } from '../../lib/utils/confirm.js';
import { getLoggedClientOrThrow } from '../../lib/utils.js';
import { confirmAction } from '../../lib/utils/confirm.js';

export class ActorRmCommand extends ApifyCommand<typeof ActorRmCommand> {
static override description = 'Permanently removes an Actor from your account.';
Expand Down
2 changes: 1 addition & 1 deletion src/commands/actors/start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ import { Args, Flags } from '@oclif/core';
import type { ActorRun, ActorStartOptions, ActorTaggedBuild } from 'apify-client';
import chalk from 'chalk';

import { ActorsCallCommand } from './call.js';
import { ApifyCommand } from '../../lib/apify_command.js';
import { getInputOverride } from '../../lib/commands/resolve-input.js';
import { runActorOrTaskOnCloud, SharedRunOnCloudFlags } from '../../lib/commands/run-on-cloud.js';
import { LOCAL_CONFIG_PATH } from '../../lib/consts.js';
import { simpleLog } from '../../lib/outputs.js';
import { getLocalConfig, getLocalUserInfo, getLoggedClientOrThrow, TimestampFormatter } from '../../lib/utils.js';
import { ActorsCallCommand } from './call.js';

export class ActorsStartCommand extends ApifyCommand<typeof ActorsStartCommand> {
static override description =
Expand Down
2 changes: 1 addition & 1 deletion src/commands/builds/rm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import type { ActorTaggedBuild, ApifyApiError } from 'apify-client';

import { ApifyCommand } from '../../lib/apify_command.js';
import { error, info, success } from '../../lib/outputs.js';
import { confirmAction } from '../../lib/utils/confirm.js';
import { getLoggedClientOrThrow } from '../../lib/utils.js';
import { confirmAction } from '../../lib/utils/confirm.js';

export class BuildsRmCommand extends ApifyCommand<typeof BuildsRmCommand> {
static override description = 'Permanently removes an Actor build from the Apify platform.';
Expand Down
7 changes: 3 additions & 4 deletions src/commands/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ import { mkdir, readdir, stat } from 'node:fs/promises';
import { join } from 'node:path';
import process from 'node:process';

import { fetchManifest, manifestUrl } from '@apify/actor-templates';
import { Args, Flags } from '@oclif/core';
import { gte, minVersion } from 'semver';

import { fetchManifest, manifestUrl } from '@apify/actor-templates';

import { ApifyCommand } from '../lib/apify_command.js';
import {
EMPTY_LOCAL_CONFIG,
Expand Down Expand Up @@ -84,7 +85,6 @@ export class CreateCommand extends ApifyCommand<typeof CreateCommand> {
const cwd = process.cwd();
let actFolderDir = join(cwd, actorName);

// eslint-disable-next-line no-constant-condition
while (true) {
const folderExists = await stat(actFolderDir).catch(() => null);
const folderHasFiles =
Expand Down Expand Up @@ -182,8 +182,7 @@ export class CreateCommand extends ApifyCommand<typeof CreateCommand> {
return;
}

// eslint-disable-next-line prefer-destructuring
let runtime = project.runtime;
let { runtime } = project;

switch (project.type) {
case ProjectLanguage.JavaScript: {
Expand Down
2 changes: 1 addition & 1 deletion src/commands/datasets/push-items.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export class DatasetsPushDataCommand extends ApifyCommand<typeof DatasetsPushDat

const { datasetClient, dataset } = existingDataset;

let parsedData: Record<string, unknown> | Array<Record<string, unknown>>;
let parsedData: Record<string, unknown> | Record<string, unknown>[];

const item = _item || (await readStdin(process.stdin));

Expand Down
2 changes: 1 addition & 1 deletion src/commands/datasets/rm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import chalk from 'chalk';
import { ApifyCommand } from '../../lib/apify_command.js';
import { tryToGetDataset } from '../../lib/commands/storages.js';
import { error, info, success } from '../../lib/outputs.js';
import { confirmAction } from '../../lib/utils/confirm.js';
import { getLoggedClientOrThrow } from '../../lib/utils.js';
import { confirmAction } from '../../lib/utils/confirm.js';

export class DatasetsRmCommand extends ApifyCommand<typeof DatasetsRmCommand> {
static override description = 'Permanently removes a dataset.';
Expand Down
11 changes: 6 additions & 5 deletions src/commands/edit-input-schema.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'fs';
import { Server } from 'http';
import { AddressInfo } from 'net';
import { dirname } from 'path';
import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
import type { Server } from 'node:http';
import type { AddressInfo } from 'node:net';
import { dirname } from 'node:path';

import { cryptoRandomObjectId } from '@apify/utilities';
import { Args } from '@oclif/core';
import cors from 'cors';
import detectIndent from 'detect-indent';
import express from 'express';
import open from 'open';

import { cryptoRandomObjectId } from '@apify/utilities';

import { ApifyCommand } from '../lib/apify_command.js';
import { LOCAL_CONFIG_PATH } from '../lib/consts.js';
import { readInputSchema } from '../lib/input_schema.js';
Expand Down
2 changes: 1 addition & 1 deletion src/commands/key-value-stores/delete-value.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import chalk from 'chalk';
import { ApifyCommand } from '../../lib/apify_command.js';
import { tryToGetKeyValueStore } from '../../lib/commands/storages.js';
import { error, info } from '../../lib/outputs.js';
import { confirmAction } from '../../lib/utils/confirm.js';
import { getLoggedClientOrThrow } from '../../lib/utils.js';
import { confirmAction } from '../../lib/utils/confirm.js';

export class KeyValueStoresDeleteValueCommand extends ApifyCommand<typeof KeyValueStoresDeleteValueCommand> {
static override description = 'Delete a value from a key-value store.';
Expand Down
2 changes: 1 addition & 1 deletion src/commands/key-value-stores/rm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import chalk from 'chalk';
import { ApifyCommand } from '../../lib/apify_command.js';
import { tryToGetKeyValueStore } from '../../lib/commands/storages.js';
import { error, info, success } from '../../lib/outputs.js';
import { confirmAction } from '../../lib/utils/confirm.js';
import { getLoggedClientOrThrow } from '../../lib/utils.js';
import { confirmAction } from '../../lib/utils/confirm.js';

export class KeyValueStoresRmCommand extends ApifyCommand<typeof KeyValueStoresRmCommand> {
static override description = 'Permanently removes a key-value store.';
Expand Down
Loading
Loading