apify-cli 1.0.0-beta.8 → 1.0.0-beta.81
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +200 -0
- package/README.md +87 -77
- package/bin/dev.js +7 -2
- package/bin/dev.sh +4 -0
- package/bin/run.js +7 -0
- package/dist/.tsbuildinfo +1 -1
- package/dist/commands/actor/push-data.js +2 -2
- package/dist/commands/actor/set-value.js +3 -3
- package/dist/commands/actor/set-value.js.map +1 -1
- package/dist/commands/call.d.ts +1 -0
- package/dist/commands/call.d.ts.map +1 -1
- package/dist/commands/call.js +49 -20
- package/dist/commands/call.js.map +1 -1
- package/dist/commands/create.d.ts +1 -0
- package/dist/commands/create.d.ts.map +1 -1
- package/dist/commands/create.js +13 -4
- package/dist/commands/create.js.map +1 -1
- package/dist/commands/login.d.ts +1 -0
- package/dist/commands/login.d.ts.map +1 -1
- package/dist/commands/login.js +143 -12
- package/dist/commands/login.js.map +1 -1
- package/dist/commands/push.d.ts +2 -0
- package/dist/commands/push.d.ts.map +1 -1
- package/dist/commands/push.js +64 -10
- package/dist/commands/push.js.map +1 -1
- package/dist/commands/run.d.ts +1 -0
- package/dist/commands/run.d.ts.map +1 -1
- package/dist/commands/run.js +76 -20
- package/dist/commands/run.js.map +1 -1
- package/dist/commands/secrets/index.js +1 -1
- package/dist/commands/{vis.d.ts → validate-schema.d.ts} +2 -1
- package/dist/commands/validate-schema.d.ts.map +1 -0
- package/dist/commands/{vis.js → validate-schema.js} +7 -1
- package/dist/commands/validate-schema.js.map +1 -0
- package/dist/hooks/deprecations.d.ts +4 -0
- package/dist/hooks/deprecations.d.ts.map +1 -0
- package/dist/hooks/deprecations.js +18 -0
- package/dist/hooks/deprecations.js.map +1 -0
- package/dist/lib/actor.d.ts +1 -1
- package/dist/lib/actor.js +2 -2
- package/dist/lib/actor.js.map +1 -1
- package/dist/lib/consts.d.ts +8 -0
- package/dist/lib/consts.d.ts.map +1 -1
- package/dist/lib/consts.js +10 -0
- package/dist/lib/consts.js.map +1 -1
- package/dist/lib/exec.d.ts.map +1 -1
- package/dist/lib/exec.js +6 -1
- package/dist/lib/exec.js.map +1 -1
- package/dist/lib/input_schema.d.ts +1 -1
- package/dist/lib/input_schema.d.ts.map +1 -1
- package/dist/lib/secrets.js +3 -3
- package/dist/lib/telemetry.d.ts.map +1 -1
- package/dist/lib/utils.d.ts +6 -7
- package/dist/lib/utils.d.ts.map +1 -1
- package/dist/lib/utils.js +29 -9
- package/dist/lib/utils.js.map +1 -1
- package/oclif.manifest.json +48 -38
- package/package.json +148 -141
- package/dist/commands/login-new.d.ts +0 -10
- package/dist/commands/login-new.d.ts.map +0 -1
- package/dist/commands/login-new.js +0 -166
- package/dist/commands/login-new.js.map +0 -1
- package/dist/commands/vis.d.ts.map +0 -1
- package/dist/commands/vis.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,146 +1,153 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
2
|
+
"name": "apify-cli",
|
|
3
|
+
"version": "1.0.0-beta.81",
|
|
4
|
+
"description": "Apify command-line interface (CLI) helps you manage the Apify cloud platform and develop, build, and deploy Apify Actors.",
|
|
5
|
+
"exports": "./dist/index.js",
|
|
6
|
+
"types": "./dist/index.d.ts",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"scripts": {
|
|
9
|
+
"dev": "tsx ./bin/dev.js",
|
|
10
|
+
"test": "vitest run",
|
|
11
|
+
"test-python": "vitest run -t '.*\\[python\\]'",
|
|
12
|
+
"lint": "eslint src test .yarn/plugins --ext .ts,.cjs,.mjs",
|
|
13
|
+
"lint:fix": "eslint src test .yarn/plugins --fix --ext .ts,.cjs,.mjs",
|
|
14
|
+
"clean": "rimraf dist",
|
|
15
|
+
"build": "yarn clean && tsc",
|
|
16
|
+
"postpack": "rimraf oclif.manifest.json",
|
|
17
|
+
"prepack": "yarn build && oclif manifest && oclif readme && oclif readme --readme-path=docs/reference.md",
|
|
18
|
+
"postinstallDev": "yarn build && node ./bin/run.js check-version && node ./dist/lib/community.js"
|
|
19
|
+
},
|
|
20
|
+
"files": [
|
|
21
|
+
"dist",
|
|
22
|
+
"oclif.manifest.json",
|
|
23
|
+
"bin"
|
|
24
|
+
],
|
|
25
|
+
"bin": {
|
|
26
|
+
"apify": "./bin/run.js"
|
|
27
|
+
},
|
|
28
|
+
"contributors": [
|
|
29
|
+
"Jakub Drobník <jakub.drobnik@apify.com>",
|
|
30
|
+
"Jan Curn <jan@apify.com>"
|
|
31
|
+
],
|
|
32
|
+
"repository": {
|
|
33
|
+
"type": "git",
|
|
34
|
+
"url": "git+https://github.com/apify/apify-cli.git"
|
|
35
|
+
},
|
|
36
|
+
"keywords": [
|
|
37
|
+
"apify",
|
|
38
|
+
"client",
|
|
39
|
+
"node",
|
|
40
|
+
"command",
|
|
41
|
+
"line",
|
|
42
|
+
"bash"
|
|
43
|
+
],
|
|
44
|
+
"author": {
|
|
45
|
+
"name": "Apify",
|
|
46
|
+
"email": "support@apify.com",
|
|
47
|
+
"url": "https://www.apify.com"
|
|
48
|
+
},
|
|
49
|
+
"license": "Apache-2.0",
|
|
50
|
+
"bugs": {
|
|
51
|
+
"url": "https://github.com/apify/apify-cli/issues"
|
|
52
|
+
},
|
|
53
|
+
"homepage": "https://github.com/apify/apify-cli#readme",
|
|
54
|
+
"engines": {
|
|
55
|
+
"node": ">=18"
|
|
56
|
+
},
|
|
57
|
+
"dependencies": {
|
|
58
|
+
"@apify/actor-templates": "~0.1.5",
|
|
59
|
+
"@apify/consts": "~2.27.0",
|
|
60
|
+
"@apify/input_schema": "~3.5.15",
|
|
61
|
+
"@apify/utilities": "~2.10.0",
|
|
62
|
+
"@crawlee/memory-storage": "~3.10.0",
|
|
63
|
+
"@oclif/core": "~3.26.0",
|
|
64
|
+
"@oclif/plugin-help": "~6.0.14",
|
|
65
|
+
"@root/walk": "~1.1.0",
|
|
66
|
+
"adm-zip": "~0.5.10",
|
|
67
|
+
"ajv": "~8.14.0",
|
|
68
|
+
"apify-client": "~2.9.3",
|
|
69
|
+
"archiver": "~7.0.0",
|
|
70
|
+
"axios": "~1.7.0",
|
|
71
|
+
"chalk": "~5.3.0",
|
|
72
|
+
"computer-name": "~0.1.0",
|
|
73
|
+
"configparser": "~0.3.10",
|
|
74
|
+
"cors": "~2.8.5",
|
|
75
|
+
"detect-indent": "~7.0.1",
|
|
76
|
+
"escape-string-regexp": "~5.0.0",
|
|
77
|
+
"express": "~4.19.0",
|
|
78
|
+
"globby": "~14.0.1",
|
|
79
|
+
"handlebars": "~4.7.8",
|
|
80
|
+
"inquirer": "~9.2.15",
|
|
81
|
+
"is-ci": "~3.0.1",
|
|
82
|
+
"is-online": "~10.0.0",
|
|
83
|
+
"istextorbinary": "~9.5.0",
|
|
84
|
+
"jju": "~1.4.0",
|
|
85
|
+
"load-json-file": "~7.0.1",
|
|
86
|
+
"mime": "~4.0.1",
|
|
87
|
+
"mixpanel": "~0.18.0",
|
|
88
|
+
"open": "~10.1.0",
|
|
89
|
+
"ow": "~2.0.0",
|
|
90
|
+
"rimraf": "~5.0.5",
|
|
91
|
+
"semver": "~7.6.0",
|
|
92
|
+
"tiged": "~2.12.7",
|
|
93
|
+
"underscore": "~1.13.6",
|
|
94
|
+
"write-json-file": "~5.0.0"
|
|
95
|
+
},
|
|
96
|
+
"devDependencies": {
|
|
97
|
+
"@apify/eslint-config": "^0.4.0",
|
|
98
|
+
"@apify/eslint-config-ts": "^0.4.1",
|
|
99
|
+
"@apify/tsconfig": "^0.1.0",
|
|
100
|
+
"@crawlee/types": "^3.8.1",
|
|
101
|
+
"@oclif/test": "^3.2.1",
|
|
102
|
+
"@types/adm-zip": "^0.5.5",
|
|
103
|
+
"@types/archiver": "^6.0.2",
|
|
104
|
+
"@types/chai": "^4.3.12",
|
|
105
|
+
"@types/cors": "^2.8.17",
|
|
106
|
+
"@types/express": "^4.17.21",
|
|
107
|
+
"@types/inquirer": "^9.0.7",
|
|
108
|
+
"@types/is-ci": "^3.0.4",
|
|
109
|
+
"@types/jju": "^1.4.5",
|
|
110
|
+
"@types/mime": "^4.0.0",
|
|
111
|
+
"@types/node": "^20.11.20",
|
|
112
|
+
"@types/semver": "^7.5.8",
|
|
113
|
+
"@types/underscore": "^1.11.15",
|
|
114
|
+
"@typescript-eslint/eslint-plugin": "^7.0.2",
|
|
115
|
+
"@typescript-eslint/parser": "^7.0.2",
|
|
116
|
+
"@yarnpkg/core": "^4.0.3",
|
|
117
|
+
"chai": "^4.4.1",
|
|
118
|
+
"eslint": "^8.57.0",
|
|
119
|
+
"oclif": "^4.4.18",
|
|
120
|
+
"tsx": "^4.7.1",
|
|
121
|
+
"typescript": "^5.3.3",
|
|
122
|
+
"vitest": "^1.3.1"
|
|
123
|
+
},
|
|
124
|
+
"oclif": {
|
|
125
|
+
"bin": "apify",
|
|
126
|
+
"dirname": "apify",
|
|
127
|
+
"commands": "./dist/commands",
|
|
128
|
+
"plugins": [
|
|
129
|
+
"@oclif/plugin-help"
|
|
23
130
|
],
|
|
24
|
-
"
|
|
25
|
-
|
|
131
|
+
"hooks": {
|
|
132
|
+
"init": [
|
|
133
|
+
"./dist/hooks/init"
|
|
134
|
+
],
|
|
135
|
+
"prerun": [
|
|
136
|
+
"./dist/hooks/deprecations"
|
|
137
|
+
]
|
|
26
138
|
},
|
|
27
|
-
"
|
|
28
|
-
|
|
29
|
-
|
|
139
|
+
"helpClass": "./dist/lib/apify-oclif-help",
|
|
140
|
+
"additionalHelpFlags": [
|
|
141
|
+
"-h"
|
|
30
142
|
],
|
|
31
|
-
"
|
|
32
|
-
|
|
33
|
-
"url": "git+https://github.com/apify/apify-cli.git"
|
|
34
|
-
},
|
|
35
|
-
"keywords": [
|
|
36
|
-
"apify",
|
|
37
|
-
"client",
|
|
38
|
-
"node",
|
|
39
|
-
"command",
|
|
40
|
-
"line",
|
|
41
|
-
"bash"
|
|
143
|
+
"additionalVersionFlags": [
|
|
144
|
+
"-v"
|
|
42
145
|
],
|
|
43
|
-
"
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
},
|
|
52
|
-
"homepage": "https://github.com/apify/apify-cli#readme",
|
|
53
|
-
"engines": {
|
|
54
|
-
"node": ">=16.0.0"
|
|
55
|
-
},
|
|
56
|
-
"dependencies": {
|
|
57
|
-
"@apify/actor-templates": "~0.1.5",
|
|
58
|
-
"@apify/consts": "~2.26.0",
|
|
59
|
-
"@apify/input_schema": "~3.5.15",
|
|
60
|
-
"@apify/utilities": "~2.10.0",
|
|
61
|
-
"@crawlee/memory-storage": "~3.8.1",
|
|
62
|
-
"@oclif/core": "~3.23.0",
|
|
63
|
-
"@oclif/plugin-help": "~6.0.14",
|
|
64
|
-
"@root/walk": "~1.1.0",
|
|
65
|
-
"adm-zip": "~0.5.10",
|
|
66
|
-
"ajv": "~8.12.0",
|
|
67
|
-
"apify-client": "~2.9.3",
|
|
68
|
-
"archiver": "~7.0.0",
|
|
69
|
-
"axios": "~1.6.7",
|
|
70
|
-
"chalk": "~5.3.0",
|
|
71
|
-
"computer-name": "~0.1.0",
|
|
72
|
-
"configparser": "~0.3.10",
|
|
73
|
-
"cors": "~2.8.5",
|
|
74
|
-
"detect-indent": "~7.0.1",
|
|
75
|
-
"escape-string-regexp": "~5.0.0",
|
|
76
|
-
"express": "~4.18.2",
|
|
77
|
-
"globby": "~14.0.1",
|
|
78
|
-
"handlebars": "~4.7.8",
|
|
79
|
-
"inquirer": "~9.2.15",
|
|
80
|
-
"is-ci": "~3.0.1",
|
|
81
|
-
"is-online": "~10.0.0",
|
|
82
|
-
"istextorbinary": "~9.5.0",
|
|
83
|
-
"jju": "~1.4.0",
|
|
84
|
-
"load-json-file": "~7.0.1",
|
|
85
|
-
"mime": "~4.0.1",
|
|
86
|
-
"mixpanel": "~0.18.0",
|
|
87
|
-
"open": "~10.0.4",
|
|
88
|
-
"ow": "~1.1.1",
|
|
89
|
-
"rimraf": "~5.0.5",
|
|
90
|
-
"semver": "~7.6.0",
|
|
91
|
-
"tiged": "~2.12.7",
|
|
92
|
-
"underscore": "~1.13.6",
|
|
93
|
-
"write-json-file": "~5.0.0"
|
|
94
|
-
},
|
|
95
|
-
"devDependencies": {
|
|
96
|
-
"@apify/eslint-config": "^0.4.0",
|
|
97
|
-
"@apify/eslint-config-ts": "^0.4.1",
|
|
98
|
-
"@apify/tsconfig": "^0.1.0",
|
|
99
|
-
"@crawlee/types": "^3.8.1",
|
|
100
|
-
"@oclif/test": "^3.2.1",
|
|
101
|
-
"@types/adm-zip": "^0.5.5",
|
|
102
|
-
"@types/archiver": "^6.0.2",
|
|
103
|
-
"@types/chai": "^4.3.12",
|
|
104
|
-
"@types/cors": "^2.8.17",
|
|
105
|
-
"@types/express": "^4.17.21",
|
|
106
|
-
"@types/inquirer": "^9.0.7",
|
|
107
|
-
"@types/is-ci": "^3.0.4",
|
|
108
|
-
"@types/jju": "^1.4.5",
|
|
109
|
-
"@types/mime": "^3.0.4",
|
|
110
|
-
"@types/node": "^20.11.20",
|
|
111
|
-
"@types/semver": "^7.5.8",
|
|
112
|
-
"@types/underscore": "^1.11.15",
|
|
113
|
-
"@typescript-eslint/eslint-plugin": "^7.0.2",
|
|
114
|
-
"@typescript-eslint/parser": "^7.0.2",
|
|
115
|
-
"chai": "^4.4.1",
|
|
116
|
-
"eslint": "^8.57.0",
|
|
117
|
-
"oclif": "^4.4.18",
|
|
118
|
-
"tsx": "^4.7.1",
|
|
119
|
-
"typescript": "^5.3.3",
|
|
120
|
-
"vitest": "^1.3.1"
|
|
121
|
-
},
|
|
122
|
-
"oclif": {
|
|
123
|
-
"bin": "apify",
|
|
124
|
-
"dirname": "apify",
|
|
125
|
-
"commands": "./dist/commands",
|
|
126
|
-
"plugins": [
|
|
127
|
-
"@oclif/plugin-help"
|
|
128
|
-
],
|
|
129
|
-
"hooks": {
|
|
130
|
-
"init": [
|
|
131
|
-
"./dist/hooks/init"
|
|
132
|
-
]
|
|
133
|
-
},
|
|
134
|
-
"helpClass": "./dist/lib/apify-oclif-help",
|
|
135
|
-
"additionalHelpFlags": [
|
|
136
|
-
"-h"
|
|
137
|
-
],
|
|
138
|
-
"additionalVersionFlags": [
|
|
139
|
-
"-v"
|
|
140
|
-
]
|
|
141
|
-
},
|
|
142
|
-
"volta": {
|
|
143
|
-
"node": "20.11.1",
|
|
144
|
-
"npm": "10.5.0"
|
|
145
|
-
}
|
|
146
|
-
}
|
|
146
|
+
"topicSeparator": " "
|
|
147
|
+
},
|
|
148
|
+
"volta": {
|
|
149
|
+
"node": "20.14.0",
|
|
150
|
+
"yarn": "4.2.2"
|
|
151
|
+
},
|
|
152
|
+
"packageManager": "yarn@4.2.2"
|
|
153
|
+
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { ApifyCommand } from '../lib/apify_command.js';
|
|
2
|
-
export declare class LoginNewCommand extends ApifyCommand<typeof LoginNewCommand> {
|
|
3
|
-
static description: string;
|
|
4
|
-
static flags: {
|
|
5
|
-
token: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
6
|
-
};
|
|
7
|
-
static hidden: boolean;
|
|
8
|
-
run(): Promise<void>;
|
|
9
|
-
}
|
|
10
|
-
//# sourceMappingURL=login-new.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"login-new.d.ts","sourceRoot":"","sources":["../../src/commands/login-new.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AA0BvD,qBAAa,eAAgB,SAAQ,YAAY,CAAC,OAAO,eAAe,CAAC;IACrE,OAAgB,WAAW,SAEU;IAErC,OAAgB,KAAK;;MAMnB;IAEF,OAAgB,MAAM,UAAQ;IAExB,GAAG;CAoHZ"}
|
|
@@ -1,166 +0,0 @@
|
|
|
1
|
-
import { cryptoRandomObjectId } from '@apify/utilities';
|
|
2
|
-
import { Flags } from '@oclif/core';
|
|
3
|
-
import computerName from 'computer-name';
|
|
4
|
-
import cors from 'cors';
|
|
5
|
-
import express from 'express';
|
|
6
|
-
import inquirer from 'inquirer';
|
|
7
|
-
import open from 'open';
|
|
8
|
-
import { ApifyCommand } from '../lib/apify_command.js';
|
|
9
|
-
import { error, info, success, warning } from '../lib/outputs.js';
|
|
10
|
-
import { useApifyIdentity } from '../lib/telemetry.js';
|
|
11
|
-
import { getLocalUserInfo, getLoggedClient } from '../lib/utils.js';
|
|
12
|
-
const CONSOLE_BASE_URL = 'https://console.apify.com/account?tab=integrations';
|
|
13
|
-
// const CONSOLE_BASE_URL = 'http://localhost:3000/account?tab=integrations';
|
|
14
|
-
const CONSOLE_URL_ORIGIN = new URL(CONSOLE_BASE_URL).origin;
|
|
15
|
-
const API_BASE_URL = CONSOLE_BASE_URL.includes('localhost') ? 'http://localhost:3333' : undefined;
|
|
16
|
-
// Not really checked right now, but it might come useful if we ever need to do some breaking changes
|
|
17
|
-
const API_VERSION = 'v1';
|
|
18
|
-
const tryToLogin = async (token) => {
|
|
19
|
-
const isUserLogged = await getLoggedClient(token, API_BASE_URL);
|
|
20
|
-
const userInfo = await getLocalUserInfo();
|
|
21
|
-
if (isUserLogged) {
|
|
22
|
-
await useApifyIdentity(userInfo.id);
|
|
23
|
-
success(`You are logged in to Apify as ${userInfo.username || userInfo.id}!`);
|
|
24
|
-
}
|
|
25
|
-
else {
|
|
26
|
-
error('Login to Apify failed, the provided API token is not valid.');
|
|
27
|
-
}
|
|
28
|
-
return isUserLogged;
|
|
29
|
-
};
|
|
30
|
-
export class LoginNewCommand extends ApifyCommand {
|
|
31
|
-
async run() {
|
|
32
|
-
warning('This command is still experimental and might break at any time. Use at your own risk.\n');
|
|
33
|
-
const { token } = this.flags;
|
|
34
|
-
if (token) {
|
|
35
|
-
await tryToLogin(token);
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
|
-
const answer = await inquirer.prompt([{
|
|
39
|
-
type: 'list',
|
|
40
|
-
name: 'loginMethod',
|
|
41
|
-
message: 'Choose how you want to log in to Apify',
|
|
42
|
-
choices: [
|
|
43
|
-
{ value: 'console', name: 'Through Apify Console in your default browser', short: 'Through Apify Console' },
|
|
44
|
-
{ value: 'manual', name: 'Enter API token manually', short: 'Manually' },
|
|
45
|
-
],
|
|
46
|
-
loop: false,
|
|
47
|
-
}]);
|
|
48
|
-
if (answer.loginMethod === 'console') {
|
|
49
|
-
let server;
|
|
50
|
-
const app = express();
|
|
51
|
-
// To send requests from browser to localhost, CORS has to be configured properly
|
|
52
|
-
app.use(cors({
|
|
53
|
-
origin: CONSOLE_URL_ORIGIN,
|
|
54
|
-
allowedHeaders: ['Content-Type', 'Authorization'],
|
|
55
|
-
}));
|
|
56
|
-
// Turn off keepalive, otherwise closing the server when command is finished is lagging
|
|
57
|
-
app.use((_, res, next) => {
|
|
58
|
-
res.set('Connection', 'close');
|
|
59
|
-
next();
|
|
60
|
-
});
|
|
61
|
-
app.use(express.json());
|
|
62
|
-
// Basic authorization via a random token, which is passed to the Apify Console,
|
|
63
|
-
// and that sends it back via the `token` query param, or `Authorization` header
|
|
64
|
-
const authToken = cryptoRandomObjectId();
|
|
65
|
-
app.use((req, res, next) => {
|
|
66
|
-
let { token: serverToken } = req.query;
|
|
67
|
-
if (!serverToken) {
|
|
68
|
-
const authorizationHeader = req.get('Authorization');
|
|
69
|
-
if (authorizationHeader) {
|
|
70
|
-
const [schema, tokenFromHeader, ...extra] = authorizationHeader.trim().split(/\s+/);
|
|
71
|
-
if (schema.toLowerCase() === 'bearer' && tokenFromHeader && extra.length === 0) {
|
|
72
|
-
serverToken = tokenFromHeader;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
if (serverToken !== authToken) {
|
|
77
|
-
res.status(401);
|
|
78
|
-
res.send('Authorization failed');
|
|
79
|
-
}
|
|
80
|
-
else {
|
|
81
|
-
next();
|
|
82
|
-
}
|
|
83
|
-
});
|
|
84
|
-
const apiRouter = express.Router();
|
|
85
|
-
app.use(`/api/${API_VERSION}`, apiRouter);
|
|
86
|
-
apiRouter.post('/login-token', async (req, res) => {
|
|
87
|
-
try {
|
|
88
|
-
if (req.body.apiToken) {
|
|
89
|
-
await tryToLogin(req.body.apiToken);
|
|
90
|
-
}
|
|
91
|
-
else {
|
|
92
|
-
throw new Error('Request did not contain API token');
|
|
93
|
-
}
|
|
94
|
-
res.end();
|
|
95
|
-
}
|
|
96
|
-
catch (err) {
|
|
97
|
-
const errorMessage = `Login to Apify failed with error: ${err.message}`;
|
|
98
|
-
error(errorMessage);
|
|
99
|
-
res.status(500);
|
|
100
|
-
res.send(errorMessage);
|
|
101
|
-
}
|
|
102
|
-
server.close();
|
|
103
|
-
});
|
|
104
|
-
apiRouter.post('/exit', (req, res) => {
|
|
105
|
-
if (req.body.isWindowClosed) {
|
|
106
|
-
error('Login to Apify failed, the console window was closed.');
|
|
107
|
-
}
|
|
108
|
-
else if (req.body.actionCanceled) {
|
|
109
|
-
error('Login to Apify failed, the action was canceled in the Apify Console.');
|
|
110
|
-
}
|
|
111
|
-
else {
|
|
112
|
-
error('Login to Apify failed.');
|
|
113
|
-
}
|
|
114
|
-
res.end();
|
|
115
|
-
server.close();
|
|
116
|
-
});
|
|
117
|
-
// Listening on port 0 will assign a random available port
|
|
118
|
-
server = app.listen(0);
|
|
119
|
-
const { port } = server.address();
|
|
120
|
-
const consoleUrl = new URL(CONSOLE_BASE_URL);
|
|
121
|
-
consoleUrl.searchParams.set('localCliCommand', 'login');
|
|
122
|
-
consoleUrl.searchParams.set('localCliPort', `${port}`);
|
|
123
|
-
consoleUrl.searchParams.set('localCliToken', authToken);
|
|
124
|
-
consoleUrl.searchParams.set('localCliApiVersion', API_VERSION);
|
|
125
|
-
try {
|
|
126
|
-
consoleUrl.searchParams.set('localCliComputerName', encodeURIComponent(computerName()));
|
|
127
|
-
}
|
|
128
|
-
catch {
|
|
129
|
-
// Ignore errors from fetching computer name as it's not critical
|
|
130
|
-
}
|
|
131
|
-
info(`Opening Apify Console at "${consoleUrl.href}"...`);
|
|
132
|
-
await open(consoleUrl.href);
|
|
133
|
-
}
|
|
134
|
-
else {
|
|
135
|
-
const tokenAnswer = await inquirer.prompt([{ name: 'token', message: 'Insert your Apify API token', type: 'password' }]);
|
|
136
|
-
await tryToLogin(tokenAnswer.token);
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
Object.defineProperty(LoginNewCommand, "description", {
|
|
141
|
-
enumerable: true,
|
|
142
|
-
configurable: true,
|
|
143
|
-
writable: true,
|
|
144
|
-
value: 'Logs in to your Apify account using your API token.\nThe API token and other account '
|
|
145
|
-
+ 'information is stored in the ~/.apify directory, from where it is read by all other "apify" commands. '
|
|
146
|
-
+ 'To log out, call "apify logout".'
|
|
147
|
-
});
|
|
148
|
-
Object.defineProperty(LoginNewCommand, "flags", {
|
|
149
|
-
enumerable: true,
|
|
150
|
-
configurable: true,
|
|
151
|
-
writable: true,
|
|
152
|
-
value: {
|
|
153
|
-
token: Flags.string({
|
|
154
|
-
char: 't',
|
|
155
|
-
description: '[Optional] Apify API token',
|
|
156
|
-
required: false,
|
|
157
|
-
}),
|
|
158
|
-
}
|
|
159
|
-
});
|
|
160
|
-
Object.defineProperty(LoginNewCommand, "hidden", {
|
|
161
|
-
enumerable: true,
|
|
162
|
-
configurable: true,
|
|
163
|
-
writable: true,
|
|
164
|
-
value: true
|
|
165
|
-
});
|
|
166
|
-
//# sourceMappingURL=login-new.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"login-new.js","sour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