apify-cli 0.17.0-beta.0 → 0.17.0

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.
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "apify-cli",
3
- "version": "0.16.2",
3
+ "version": "0.17.0",
4
4
  "lockfileVersion": 2,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "apify-cli",
9
- "version": "0.16.2",
9
+ "version": "0.17.0",
10
10
  "hasInstallScript": true,
11
11
  "license": "Apache-2.0",
12
12
  "dependencies": {
package/package.json CHANGED
@@ -1,114 +1,114 @@
1
1
  {
2
- "name": "apify-cli",
3
- "version": "0.17.0-beta.0",
4
- "description": "Apify command-line interface helps you create, develop, build and run Apify actors, and manage the Apify cloud platform.",
5
- "main": "index.js",
6
- "scripts": {
7
- "test": "cross-env APIFY_CLI_SKIP_UPDATE_CHECK=1 mocha --timeout 180000 --recursive",
8
- "test-python": "npm run test -- --grep '\\[python\\]'",
9
- "lint": "eslint src test",
10
- "lint:fix": "eslint src test --fix",
11
- "commands-md": "npm run manifest && oclif-dev readme",
12
- "prepare-release": "npm run commands-md && npm run prod-shrinkwrap",
13
- "prod-shrinkwrap": "rm -rf node_modules && npm install --production && npm shrinkwrap",
14
- "manifest": "rm -f oclif.manifest.json && oclif-dev manifest",
15
- "postinstall": "node \"./src/bin/run\" check-version && node ./src/lib/community"
16
- },
17
- "files": [
18
- "src",
19
- "oclif.manifest.json",
20
- "index.js",
21
- "package.json"
22
- ],
23
- "bin": {
24
- "apify": "./src/bin/run"
25
- },
26
- "contributors": [
27
- "Jakub Drobník <jakub.drobnik@apify.com>",
28
- "Jan Curn <jan@apify.com>"
29
- ],
30
- "repository": {
31
- "type": "git",
32
- "url": "git+https://github.com/apify/apify-cli.git"
33
- },
34
- "keywords": [
35
- "apify",
36
- "client",
37
- "node",
38
- "command",
39
- "line",
40
- "bash"
41
- ],
42
- "author": {
43
- "name": "Apify",
44
- "email": "support@apify.com",
45
- "url": "https://www.apify.com"
46
- },
47
- "license": "Apache-2.0",
48
- "bugs": {
49
- "url": "https://github.com/apify/apify-cli/issues"
50
- },
51
- "homepage": "https://github.com/apify/apify-cli#readme",
52
- "engines": {
53
- "node": ">=16.0.0"
54
- },
55
- "dependencies": {
56
- "@apify/actor-templates": "^0.1.3",
57
- "@apify/consts": "^2.7.0",
58
- "@apify/input_schema": "^3.3.0",
59
- "@apify/utilities": "^2.2.3",
60
- "@crawlee/memory-storage": "^3.0.3",
61
- "@oclif/command": "^1.8.16",
62
- "@oclif/config": "^1.18.3",
63
- "@oclif/errors": "^1.3.5",
64
- "@oclif/plugin-commands": "^2.1.0",
65
- "@oclif/plugin-help": "^5.1.12",
66
- "adm-zip": "^0.5.10",
67
- "ajv": "^8.10.0",
68
- "apify-client": "^2.2.0",
69
- "archiver-promise": "^1.0.0",
70
- "axios": "^0.21.1",
71
- "chalk": "^4.1.2",
72
- "computer-name": "^0.1.0",
73
- "cors": "^2.8.5",
74
- "detect-indent": "^6.1.0",
75
- "escape-string-regexp": "^4.0.0",
76
- "express": "^4.18.2",
77
- "globby": "^11.1.0",
78
- "inquirer": "^7.3.3",
79
- "is-ci": "^3.0.1",
80
- "is-online": "^10.0.0",
81
- "istextorbinary": "^6.0.0",
82
- "jju": "^1.4.0",
83
- "load-json-file": "^6.2.0",
84
- "mime": "^2.6.0",
85
- "mixpanel": "^0.17.0",
86
- "open": "^8.4.0",
87
- "ow": "^0.28.1",
88
- "rimraf": "^3.0.2",
89
- "semver": "^7.3.5",
90
- "tiged": "^2.12.4",
91
- "underscore": "^1.13.2",
92
- "write-json-file": "^4.3.0"
93
- },
94
- "devDependencies": {
95
- "@apify/eslint-config": "^0.2.3",
96
- "@oclif/dev-cli": "^1.26.0",
97
- "@oclif/test": "^2.1.0",
98
- "chai": "^4.3.4",
99
- "chai-match": "^1.1.1",
100
- "cross-env": "^7.0.3",
101
- "eslint": "^8.11.0",
102
- "mocha": "^10.0.0",
103
- "sinon": "^9.2.4"
104
- },
105
- "oclif": {
106
- "bin": "apify",
107
- "commands": "./src/commands",
108
- "hooks": {
109
- "init": [
110
- "./src/hooks/init"
111
- ]
2
+ "name": "apify-cli",
3
+ "version": "0.17.0",
4
+ "description": "Apify command-line interface helps you create, develop, build and run Apify actors, and manage the Apify cloud platform.",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "test": "cross-env APIFY_CLI_SKIP_UPDATE_CHECK=1 mocha --timeout 180000 --recursive",
8
+ "test-python": "npm run test -- --grep '\\[python\\]'",
9
+ "lint": "eslint src test",
10
+ "lint:fix": "eslint src test --fix",
11
+ "commands-md": "npm run manifest && oclif-dev readme",
12
+ "prepare-release": "npm run commands-md && npm run prod-shrinkwrap",
13
+ "prod-shrinkwrap": "rm -rf node_modules && npm install --production && npm shrinkwrap",
14
+ "manifest": "rm -f oclif.manifest.json && oclif-dev manifest",
15
+ "postinstall": "node \"./src/bin/run\" check-version && node ./src/lib/community"
16
+ },
17
+ "files": [
18
+ "src",
19
+ "oclif.manifest.json",
20
+ "index.js",
21
+ "package.json"
22
+ ],
23
+ "bin": {
24
+ "apify": "./src/bin/run"
25
+ },
26
+ "contributors": [
27
+ "Jakub Drobník <jakub.drobnik@apify.com>",
28
+ "Jan Curn <jan@apify.com>"
29
+ ],
30
+ "repository": {
31
+ "type": "git",
32
+ "url": "git+https://github.com/apify/apify-cli.git"
33
+ },
34
+ "keywords": [
35
+ "apify",
36
+ "client",
37
+ "node",
38
+ "command",
39
+ "line",
40
+ "bash"
41
+ ],
42
+ "author": {
43
+ "name": "Apify",
44
+ "email": "support@apify.com",
45
+ "url": "https://www.apify.com"
46
+ },
47
+ "license": "Apache-2.0",
48
+ "bugs": {
49
+ "url": "https://github.com/apify/apify-cli/issues"
50
+ },
51
+ "homepage": "https://github.com/apify/apify-cli#readme",
52
+ "engines": {
53
+ "node": ">=16.0.0"
54
+ },
55
+ "dependencies": {
56
+ "@apify/actor-templates": "^0.1.3",
57
+ "@apify/consts": "^2.7.0",
58
+ "@apify/input_schema": "^3.3.0",
59
+ "@apify/utilities": "^2.2.3",
60
+ "@crawlee/memory-storage": "^3.0.3",
61
+ "@oclif/command": "^1.8.16",
62
+ "@oclif/config": "^1.18.3",
63
+ "@oclif/errors": "^1.3.5",
64
+ "@oclif/plugin-commands": "^2.1.0",
65
+ "@oclif/plugin-help": "^5.1.12",
66
+ "adm-zip": "^0.5.10",
67
+ "ajv": "^8.10.0",
68
+ "apify-client": "^2.2.0",
69
+ "archiver-promise": "^1.0.0",
70
+ "axios": "^0.21.1",
71
+ "chalk": "^4.1.2",
72
+ "computer-name": "^0.1.0",
73
+ "cors": "^2.8.5",
74
+ "detect-indent": "^6.1.0",
75
+ "escape-string-regexp": "^4.0.0",
76
+ "express": "^4.18.2",
77
+ "globby": "^11.1.0",
78
+ "inquirer": "^7.3.3",
79
+ "is-ci": "^3.0.1",
80
+ "is-online": "^10.0.0",
81
+ "istextorbinary": "^6.0.0",
82
+ "jju": "^1.4.0",
83
+ "load-json-file": "^6.2.0",
84
+ "mime": "^2.6.0",
85
+ "mixpanel": "^0.17.0",
86
+ "open": "^8.4.0",
87
+ "ow": "^0.28.1",
88
+ "rimraf": "^3.0.2",
89
+ "semver": "^7.3.5",
90
+ "tiged": "^2.12.4",
91
+ "underscore": "^1.13.2",
92
+ "write-json-file": "^4.3.0"
93
+ },
94
+ "devDependencies": {
95
+ "@apify/eslint-config": "^0.2.3",
96
+ "@oclif/dev-cli": "^1.26.0",
97
+ "@oclif/test": "^2.1.0",
98
+ "chai": "^4.3.4",
99
+ "chai-match": "^1.1.1",
100
+ "cross-env": "^7.0.3",
101
+ "eslint": "^8.11.0",
102
+ "mocha": "^10.0.0",
103
+ "sinon": "^9.2.4"
104
+ },
105
+ "oclif": {
106
+ "bin": "apify",
107
+ "commands": "./src/commands",
108
+ "hooks": {
109
+ "init": [
110
+ "./src/hooks/init"
111
+ ]
112
+ }
112
113
  }
113
- }
114
114
  }
@@ -23,7 +23,7 @@ const {
23
23
  detectNpmVersion,
24
24
  } = require('../lib/utils');
25
25
  const { EMPTY_LOCAL_CONFIG, LOCAL_CONFIG_PATH, PYTHON_VENV_PATH, SUPPORTED_NODEJS_VERSION } = require('../lib/consts');
26
- const { httpsGet, ensureValidActorName, getTemplateDefinition } = require('../lib/create-utils');
26
+ const { httpsGet, ensureValidActorName, getTemplateDefinition, enhanceReadmeWithLocalSuffix } = require('../lib/create-utils');
27
27
 
28
28
  class CreateCommand extends ApifyCommand {
29
29
  async run() {
@@ -41,16 +41,16 @@ class CreateCommand extends ApifyCommand {
41
41
 
42
42
  // Start fetching manifest immediately to prevent
43
43
  // annoying delays that sometimes happen on CLI startup.
44
- const manifestPromise = templateArchiveUrl
45
- ? undefined // not fetching manifest when we have direct template URL
46
- : actorTemplates.fetchManifest().catch((err) => {
47
- return new Error(`Could not fetch template list from server. Cause: ${err?.message}`);
48
- });
44
+ const manifestPromise = actorTemplates.fetchManifest().catch((err) => {
45
+ return new Error(`Could not fetch template list from server. Cause: ${err?.message}`);
46
+ });
49
47
 
50
48
  actorName = await ensureValidActorName(actorName);
51
49
  let messages = null;
50
+
52
51
  this.telemetryData.fromArchiveUrl = !!templateArchiveUrl;
53
- if (manifestPromise) {
52
+
53
+ if (!templateArchiveUrl) {
54
54
  const templateDefinition = await getTemplateDefinition(templateName, manifestPromise);
55
55
  ({ archiveUrl: templateArchiveUrl, skipOptionalDeps, messages } = templateDefinition);
56
56
  this.telemetryData.templateId = templateDefinition.id;
@@ -87,6 +87,11 @@ class CreateCommand extends ApifyCommand {
87
87
 
88
88
  const packageJsonPath = path.join(actFolderDir, 'package.json');
89
89
  const requirementsTxtPath = path.join(actFolderDir, 'requirements.txt');
90
+ const readmePath = path.join(actFolderDir, 'README.md');
91
+
92
+ // Add localReadmeSuffix which is fetched from manifest to README.md
93
+ // The suffix contains local development instructions
94
+ await enhanceReadmeWithLocalSuffix(readmePath, manifestPromise);
90
95
 
91
96
  let dependenciesInstalled = false;
92
97
  if (!skipDependencyInstall) {
@@ -1,7 +1,13 @@
1
1
  const chalk = require('chalk');
2
2
  const inquirer = require('inquirer');
3
3
  const https = require('https');
4
+ const { pipeline } = require('stream');
5
+ const { promisify } = require('util');
6
+ const fs = require('fs');
4
7
  const { validateActorName } = require('./utils');
8
+ const {
9
+ warning,
10
+ } = require('./outputs');
5
11
 
6
12
  const PROGRAMMING_LANGUAGES = ['JavaScript', 'TypeScript', 'Python'];
7
13
 
@@ -58,6 +64,27 @@ exports.getTemplateDefinition = async (maybeTemplateName, manifestPromise) => {
58
64
  return executePrompts(manifest);
59
65
  };
60
66
 
67
+ /**
68
+ * Fetch local readme suffix from the manifest and append it to the readme.
69
+ * @param {string} readmePath
70
+ * @param {Promise<object>} manifestPromise
71
+ */
72
+ exports.enhanceReadmeWithLocalSuffix = async (readmePath, manifestPromise) => {
73
+ const manifest = await manifestPromise;
74
+ // If the fetch failed earlier, the resolve value of
75
+ // the promise will be the error from fetching the manifest.
76
+ if (manifest instanceof Error) throw manifest;
77
+
78
+ try {
79
+ const suffixStream = await this.httpsGet(manifest.localReadmeSuffixUrl);
80
+ const readmeStream = fs.createWriteStream(readmePath, { flags: 'a' });
81
+ readmeStream.write('\n\n');
82
+ await promisify(pipeline)(suffixStream, readmeStream);
83
+ } catch (err) {
84
+ warning(`Could not append local development instructions to README.md. Cause: ${err.message}`);
85
+ }
86
+ };
87
+
61
88
  /**
62
89
  * Inquirer does not have a native way to "go back" between prompts.
63
90
  * @param {object} manifest