Skip to content

Commit c1fb97f

Browse files
authored
docs: enable versioning and add 0.20 snapshot (#703)
1 parent 28d7ede commit c1fb97f

File tree

14 files changed

+2222
-60
lines changed

14 files changed

+2222
-60
lines changed

.github/workflows/docs.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ jobs:
4141
run: |
4242
# install project deps
4343
yarn
44+
# update next docs reference
45+
yarn update-docs
4446
# go to website dir
4547
cd website
4648
# install website deps

docs/reference.md

Lines changed: 809 additions & 46 deletions
Large diffs are not rendered by default.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
"clean": "rimraf dist",
1818
"build": "yarn clean && tsc && tsc -p tsconfig.typechecking.json",
1919
"postpack": "rimraf oclif.manifest.json",
20-
"prepack": "yarn build && oclif manifest && oclif readme && oclif readme --readme-path=docs/reference.md",
20+
"prepack": "yarn build && oclif manifest && oclif readme && yarn update-docs",
21+
"update-docs": "oclif readme --readme-path=docs/reference.md",
2122
"postinstallDev": "yarn build && node ./bin/run.js check-version && node ./dist/lib/community.js"
2223
},
2324
"files": [

website/docusaurus.config.js

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
const { config } = require('@apify/docs-theme');
2+
23
const { externalLinkProcessor } = require('./tools/utils/externalLink');
4+
const versions = require('./versions.json');
35

46
const { absoluteUrl } = config;
57
/** @type {Partial<import('@docusaurus/types').DocusaurusConfig>} */
@@ -23,35 +25,38 @@ module.exports = {
2325
title: 'Apify CLI',
2426
items: [
2527
{
26-
to: 'docs',
28+
type: 'doc',
29+
docId: 'index',
2730
label: 'Docs',
2831
position: 'left',
2932
activeBaseRegex: 'docs(?!/changelog|/reference)',
3033
},
3134
{
32-
to: 'docs/reference',
35+
type: 'doc',
36+
docId: 'reference',
3337
label: 'Reference',
3438
position: 'left',
35-
activeBaseRegex: 'docs/reference',
39+
activeBaseRegex: 'reference',
3640
},
3741
{
38-
to: 'docs/changelog',
42+
type: 'doc',
43+
docId: 'changelog',
3944
label: 'Changelog',
4045
position: 'left',
41-
activeBaseRegex: 'docs/changelog',
46+
activeBaseRegex: 'changelog',
4247
},
4348
{
4449
href: 'https://github.com/apify/apify-cli',
4550
label: 'GitHub',
4651
position: 'left',
4752
},
48-
// {
49-
// type: 'docsVersionDropdown',
50-
// position: 'left',
51-
// className: 'navbar__item', // fixes margin around dropdown - hackish, should be fixed in theme
52-
// dropdownItemsBefore: [],
53-
// dropdownItemsAfter: [],
54-
// },
53+
{
54+
type: 'docsVersionDropdown',
55+
position: 'left',
56+
className: 'navbar__item', // fixes margin around dropdown - hackish, should be fixed in theme
57+
dropdownItemsBefore: [],
58+
dropdownItemsAfter: [],
59+
},
5560
],
5661
},
5762
},
@@ -78,6 +83,6 @@ module.exports = {
7883
plugins: [
7984
...config.plugins,
8085
],
81-
themeConfig: config.themeConfig,
86+
themeConfig: { ...config.themeConfig, versions },
8287
staticDirectories: ['node_modules/@apify/docs-theme/static', 'static'],
8388
};

website/versioned_docs/version-0.20/changelog.md

Lines changed: 318 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
---
2+
title: Apify CLI
3+
---
4+
5+
<a href="https://www.npmjs.com/package/apify-cli"><img src="https://badge.fury.io/js/apify-cli.svg" alt="npm version" loading="lazy" /></a>
6+
<a href="https://travis-ci.com/apify/apify-cli?branch=master"><img src="https://travis-ci.com/apify/apify-cli.svg?branch=master" loading="lazy" alt="Build Status" /></a>
7+
8+
Apify command-line interface (Apify CLI) helps you create, develop, build and run
9+
[Apify Actors](https://apify.com/actors),
10+
and manage the Apify cloud platform from any computer.
11+
12+
Apify Actors are cloud programs that can perform arbitrary web scraping, automation or data processing job.
13+
They accept input, perform their job and generate output.
14+
While you can develop Actors in an online IDE directly in the [Apify web application](https://console.apify.com/),
15+
for complex projects it is more convenient to develop Actors locally on your computer
16+
using <a href="https://github.com/apify/apify-sdk-js">Apify SDK</a>
17+
and only push the Actors to the Apify cloud during deployment.
18+
This is where the Apify CLI comes in.
19+
20+
Note that Actors running on the Apify platform are executed in Docker containers, so with an appropriate `Dockerfile`
21+
you can build your Actors in any programming language.
22+
However, we recommend using JavaScript / Node.js, for which we provide most libraries and support.
Lines changed: 189 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,189 @@
1+
---
2+
title: Installation
3+
description: Learn how to install Apify CLI, and how to create, run, and manage Actors through it.
4+
sidebar_label: Installation
5+
---
6+
7+
## Installation
8+
9+
You can install Apify CLI either using [Homebrew package manager](https://brew.sh) on macOS or Linux or using NPM on all platforms including Windows.
10+
11+
### Via Homebrew
12+
13+
Run the following command:
14+
15+
```bash showLineNumbers
16+
brew install apify-cli
17+
```
18+
19+
### Via NPM
20+
21+
First, make sure you have [Node.js](https://nodejs.org) version 18 or higher with NPM installed on your computer:
22+
23+
```bash showLineNumbers
24+
node --version
25+
npm --version
26+
```
27+
28+
Install or upgrade Apify CLI by running:
29+
30+
```bash showLineNumbers
31+
npm -g install apify-cli
32+
```
33+
34+
If you receive a permission error, read npm's [official guide](https://docs.npmjs.com/resolving-eacces-permissions-errors-when-installing-packages-globally) on installing packages globally.
35+
36+
Alternatively, you can use [Node Version Manager (nvm)](https://github.com/nvm-sh/nvm) and install Apify CLI only into a selected user-level Node version without requiring root privileges:
37+
38+
```bash showLineNumbers
39+
nvm install 18
40+
nvm use 18
41+
npm -g install apify-cli
42+
```
43+
44+
After using either of these methods , verify that Apify CLI was installed correctly by running:
45+
46+
```bash showLineNumbers
47+
apify --version
48+
```
49+
50+
which should print something like:
51+
52+
```bash showLineNumbers
53+
apify-cli/0.19.1 linux-x64 node-v18.17.0
54+
```
55+
56+
## Basic Usage
57+
58+
The following examples demonstrate the basic usage of Apify CLI.
59+
60+
### Create a New Actor from Scratch
61+
62+
```bash showLineNumbers
63+
apify create my-hello-world
64+
```
65+
66+
First, you will be prompted to select a template with the boilerplate for the Actor, to help you get started quickly.
67+
The command will create a directory called `my-hello-world` that contains a Node.js project
68+
for the Actor and a few configuration files.
69+
70+
### Create a New Actor from Existing Project
71+
72+
:::tip Automatic Actor directory initialization
73+
When you create an Actor using the `apify create` command, the directory will already be initialized.
74+
:::
75+
76+
```bash showLineNumbers
77+
cd ./my/awesome/project
78+
apify init
79+
```
80+
81+
This command will only set up local Actor development environment in an existing directory,
82+
i.e. it will create the `.actor/actor.json` file and `apify_storage` directory.
83+
84+
Before you can run your project locally using `apify run`, you have to set up the right start command in `package.json` under scripts.start. For example:
85+
86+
```json showLineNumbers
87+
{
88+
...
89+
"scripts": {
90+
"start": "node your_main_file.js",
91+
},
92+
...
93+
}
94+
```
95+
96+
You can find more information about by running `apify help run`.
97+
98+
### Run the Actor Locally
99+
100+
```bash showLineNumbers
101+
cd my-hello-world
102+
apify run
103+
```
104+
105+
This command runs the Actor on your local machine.
106+
Now's your chance to develop the logic - or magic :smirk:
107+
108+
### Login with your Apify account
109+
110+
```bash showLineNumbers
111+
apify login
112+
```
113+
114+
Before you can interact with the Apify cloud, you need to [create an Apify account](https://console.apify.com/)
115+
and log in to it using the above command. You will be prompted for
116+
your [Apify API token](https://console.apify.com/settings/integrations).
117+
118+
:::note API token save directory
119+
The command will store the API token and other sensitive information to `~/.apify`.
120+
:::
121+
122+
### Push the Actor to the Apify Cloud
123+
124+
```bash showLineNumbers
125+
apify push
126+
```
127+
128+
This command uploads your project to the Apify cloud and builds an Actor from it. On the platform, Actor needs to be built before it can be run.
129+
130+
### Run an Actor on the Apify Cloud
131+
132+
```bash showLineNumbers
133+
apify call
134+
```
135+
136+
Runs the Actor corresponding to the current directory on the Apify Platform.
137+
138+
This command can also be used to run other Actors, for example:
139+
140+
```bash showLineNumbers
141+
apify call apify/hello-world
142+
```
143+
144+
### So what's in this `.actor/actor.json` File?
145+
146+
This file associates your local development project with an Actor on the Apify Platform.
147+
It contains information such as Actor name, version, build tag and environment variables.
148+
Make sure you commit this file to the Git repository.
149+
150+
For example, `.actor/actor.json` file can look as follows:
151+
152+
```json showLineNumbers
153+
{
154+
"actorSpecification": 1,
155+
"name": "name-of-my-scraper",
156+
"version": "0.0",
157+
"buildTag": "latest",
158+
"environmentVariables": {
159+
"MYSQL_USER": "my_username",
160+
"MYSQL_PASSWORD": "@mySecretPassword"
161+
},
162+
"dockerfile": "./Dockerfile",
163+
"readme": "./ACTOR.md",
164+
"input": "./input_schema.json",
165+
"storages": {
166+
"dataset": "./dataset_schema.json"
167+
}
168+
}
169+
```
170+
171+
**`Dockerfile` field**
172+
173+
If you specify the path to your Docker file under the `dockerfile` field, this file will be used for Actor builds on the platform. If not specified, the system will look for Docker files at `.actor/Dockerfile` and `Dockerfile` in this order of preference.
174+
175+
**`Readme` field**
176+
177+
If you specify the path to your readme file under the `readme` field, the readme at this path will be used on the platform. If not specified, readme at `.actor/README.md` and `README.md` will be used in this order of preference.
178+
179+
**`Input` field**
180+
181+
You can embed your [input schema](https://docs.apify.com/actors/development/input-schema#specification-version-1) object directly in `actor.json` under `input` field. Alternatively, you can provide a path to a custom input schema. If not provided, the input schema at `.actor/INPUT_SCHEMA.json` and `INPUT_SCHEMA.json` is used in this order of preference.
182+
183+
**`Storages.dataset` field**
184+
185+
You can define the schema of the items in your dataset under the `storages.dataset` field. This can be either an embedded object or a path to a JSON schema file. You can read more about the schema of your Actor output [here](https://docs.apify.com/actors/development/output-schema#specification-version-1).
186+
187+
:::note Migration from deprecated config "apify.json"
188+
Note that previously, Actor config was stored in the `apify.json` file that has been deprecated. You can find the (very slight) differences and migration info in [migration guidelines](https://github.com/apify/apify-cli/blob/master/MIGRATIONS.md).
189+
:::

0 commit comments

Comments
 (0)