apify-cli 0.19.3-beta.4 → 1.0.0-beta.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.
- package/README.md +87 -63
- package/bin/dev.cmd +3 -0
- package/bin/dev.js +16 -0
- package/bin/run.js +16 -0
- package/dist/.tsbuildinfo +1 -0
- package/dist/commands/actor/get-input.d.ts +6 -0
- package/dist/commands/actor/get-input.d.ts.map +1 -0
- package/dist/commands/actor/get-input.js +14 -0
- package/dist/commands/actor/get-input.js.map +1 -0
- package/dist/commands/actor/get-value.d.ts +9 -0
- package/dist/commands/actor/get-value.d.ts.map +1 -0
- package/dist/commands/actor/get-value.js +27 -0
- package/dist/commands/actor/get-value.js.map +1 -0
- package/dist/commands/actor/index.d.ts +6 -0
- package/dist/commands/actor/index.d.ts.map +1 -0
- package/dist/commands/actor/index.js +13 -0
- package/dist/commands/actor/index.js.map +1 -0
- package/dist/commands/actor/push-data.d.ts +11 -0
- package/dist/commands/actor/push-data.d.ts.map +1 -0
- package/dist/commands/actor/push-data.js +56 -0
- package/dist/commands/actor/push-data.js.map +1 -0
- package/dist/commands/actor/set-value.d.ts +15 -0
- package/dist/commands/actor/set-value.d.ts.map +1 -0
- package/dist/commands/actor/set-value.js +76 -0
- package/dist/commands/actor/set-value.js.map +1 -0
- package/dist/commands/call.d.ts +15 -0
- package/dist/commands/call.d.ts.map +1 -0
- package/dist/commands/call.js +142 -0
- package/dist/commands/call.js.map +1 -0
- package/dist/commands/check-version.d.ts +11 -0
- package/dist/commands/check-version.d.ts.map +1 -0
- package/dist/commands/check-version.js +39 -0
- package/dist/commands/check-version.js.map +1 -0
- package/dist/commands/create.d.ts +14 -0
- package/dist/commands/create.d.ts.map +1 -0
- package/dist/commands/create.js +181 -0
- package/dist/commands/create.js.map +1 -0
- package/dist/commands/edit-input-schema.d.ts +11 -0
- package/dist/commands/edit-input-schema.d.ts.map +1 -0
- package/{src → dist}/commands/edit-input-schema.js +81 -85
- package/dist/commands/edit-input-schema.js.map +1 -0
- package/dist/commands/info.d.ts +6 -0
- package/dist/commands/info.d.ts.map +1 -0
- package/dist/commands/info.js +26 -0
- package/dist/commands/info.js.map +1 -0
- package/dist/commands/init-wrap-scrapy.d.ts +10 -0
- package/dist/commands/init-wrap-scrapy.d.ts.map +1 -0
- package/dist/commands/init-wrap-scrapy.js +41 -0
- package/dist/commands/init-wrap-scrapy.js.map +1 -0
- package/dist/commands/init.d.ts +12 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +88 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/login-new.d.ts +10 -0
- package/dist/commands/login-new.d.ts.map +1 -0
- package/{src → dist}/commands/login-new.js +79 -82
- package/dist/commands/login-new.js.map +1 -0
- package/dist/commands/login.d.ts +9 -0
- package/dist/commands/login.d.ts.map +1 -0
- package/dist/commands/login.js +43 -0
- package/dist/commands/login.js.map +1 -0
- package/dist/commands/logout.d.ts +6 -0
- package/dist/commands/logout.d.ts.map +1 -0
- package/dist/commands/logout.js +20 -0
- package/dist/commands/logout.js.map +1 -0
- package/dist/commands/pull.d.ts +12 -0
- package/dist/commands/pull.d.ts.map +1 -0
- package/dist/commands/pull.js +148 -0
- package/dist/commands/pull.js.map +1 -0
- package/dist/commands/push.d.ts +16 -0
- package/dist/commands/push.d.ts.map +1 -0
- package/dist/commands/push.js +242 -0
- package/dist/commands/push.js.map +1 -0
- package/dist/commands/run.d.ts +12 -0
- package/dist/commands/run.d.ts.map +1 -0
- package/{src → dist}/commands/run.js +96 -109
- package/dist/commands/run.js.map +1 -0
- package/dist/commands/secrets/add.d.ts +10 -0
- package/dist/commands/secrets/add.d.ts.map +1 -0
- package/dist/commands/secrets/add.js +31 -0
- package/dist/commands/secrets/add.js.map +1 -0
- package/dist/commands/secrets/index.d.ts +6 -0
- package/dist/commands/secrets/index.d.ts.map +1 -0
- package/dist/commands/secrets/index.js +24 -0
- package/dist/commands/secrets/index.js.map +1 -0
- package/dist/commands/secrets/rm.d.ts +9 -0
- package/dist/commands/secrets/rm.d.ts.map +1 -0
- package/dist/commands/secrets/rm.js +27 -0
- package/dist/commands/secrets/rm.js.map +1 -0
- package/dist/commands/vis.d.ts +9 -0
- package/dist/commands/vis.d.ts.map +1 -0
- package/dist/commands/vis.js +52 -0
- package/dist/commands/vis.js.map +1 -0
- package/dist/hooks/init.d.ts +7 -0
- package/dist/hooks/init.d.ts.map +1 -0
- package/dist/hooks/init.js +17 -0
- package/dist/hooks/init.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/actor.d.ts +27 -0
- package/dist/lib/actor.d.ts.map +1 -0
- package/{src → dist}/lib/actor.js +21 -44
- package/dist/lib/actor.js.map +1 -0
- package/dist/lib/apify-oclif-help.d.ts +15 -0
- package/dist/lib/apify-oclif-help.d.ts.map +1 -0
- package/dist/lib/apify-oclif-help.js +19 -0
- package/dist/lib/apify-oclif-help.js.map +1 -0
- package/dist/lib/apify_command.d.ts +22 -0
- package/dist/lib/apify_command.d.ts.map +1 -0
- package/dist/lib/apify_command.js +103 -0
- package/dist/lib/apify_command.js.map +1 -0
- package/dist/lib/community.d.ts +2 -0
- package/dist/lib/community.d.ts.map +1 -0
- package/dist/lib/community.js +4 -0
- package/dist/lib/community.js.map +1 -0
- package/dist/lib/consts.d.ts +45 -0
- package/dist/lib/consts.d.ts.map +1 -0
- package/dist/lib/consts.js +54 -0
- package/dist/lib/consts.js.map +1 -0
- package/dist/lib/create-utils.d.ts +8 -0
- package/dist/lib/create-utils.d.ts.map +1 -0
- package/{src → dist}/lib/create-utils.js +74 -113
- package/dist/lib/create-utils.js.map +1 -0
- package/dist/lib/exec.d.ts +4 -0
- package/dist/lib/exec.d.ts.map +1 -0
- package/{src → dist}/lib/exec.js +15 -16
- package/dist/lib/exec.js.map +1 -0
- package/dist/lib/files.d.ts +14 -0
- package/dist/lib/files.d.ts.map +1 -0
- package/dist/lib/files.js +58 -0
- package/dist/lib/files.js.map +1 -0
- package/dist/lib/input_schema.d.ts +26 -0
- package/dist/lib/input_schema.d.ts.map +1 -0
- package/{src → dist}/lib/input_schema.js +34 -55
- package/dist/lib/input_schema.js.map +1 -0
- package/dist/lib/local_state.d.ts +11 -0
- package/dist/lib/local_state.d.ts.map +1 -0
- package/dist/lib/local_state.js +27 -0
- package/dist/lib/local_state.js.map +1 -0
- package/dist/lib/outputs.d.ts +7 -0
- package/dist/lib/outputs.d.ts.map +1 -0
- package/{src → dist}/lib/outputs.js +8 -15
- package/dist/lib/outputs.js.map +1 -0
- package/dist/lib/project_analyzer.d.ts +4 -0
- package/dist/lib/project_analyzer.d.ts.map +1 -0
- package/{src → dist}/lib/project_analyzer.js +6 -11
- package/dist/lib/project_analyzer.js.map +1 -0
- package/dist/lib/projects/CrawleeAnalyzer.d.ts +4 -0
- package/dist/lib/projects/CrawleeAnalyzer.d.ts.map +1 -0
- package/{src → dist}/lib/projects/CrawleeAnalyzer.js +7 -24
- package/dist/lib/projects/CrawleeAnalyzer.js.map +1 -0
- package/dist/lib/projects/OldApifySDKAnalyzer.d.ts +4 -0
- package/dist/lib/projects/OldApifySDKAnalyzer.d.ts.map +1 -0
- package/{src → dist}/lib/projects/OldApifySDKAnalyzer.js +9 -32
- package/dist/lib/projects/OldApifySDKAnalyzer.js.map +1 -0
- package/dist/lib/projects/scrapy/ScrapyProjectAnalyzer.d.ts +17 -0
- package/dist/lib/projects/scrapy/ScrapyProjectAnalyzer.d.ts.map +1 -0
- package/{src/lib/scrapy-wrapper → dist/lib/projects/scrapy}/ScrapyProjectAnalyzer.js +33 -36
- package/dist/lib/projects/scrapy/ScrapyProjectAnalyzer.js.map +1 -0
- package/dist/lib/projects/scrapy/Spider.d.ts +14 -0
- package/dist/lib/projects/scrapy/Spider.d.ts.map +1 -0
- package/dist/lib/projects/scrapy/Spider.js +33 -0
- package/dist/lib/projects/scrapy/Spider.js.map +1 -0
- package/dist/lib/projects/scrapy/SpiderFileAnalyzer.d.ts +7 -0
- package/dist/lib/projects/scrapy/SpiderFileAnalyzer.d.ts.map +1 -0
- package/dist/lib/projects/scrapy/SpiderFileAnalyzer.js +25 -0
- package/dist/lib/projects/scrapy/SpiderFileAnalyzer.js.map +1 -0
- package/dist/lib/projects/scrapy/wrapScrapyProject.d.ts +4 -0
- package/dist/lib/projects/scrapy/wrapScrapyProject.d.ts.map +1 -0
- package/{src/lib/scrapy-wrapper/index.js → dist/lib/projects/scrapy/wrapScrapyProject.js} +43 -73
- package/dist/lib/projects/scrapy/wrapScrapyProject.js.map +1 -0
- package/dist/lib/projects/shared.d.ts +2 -0
- package/dist/lib/projects/shared.d.ts.map +1 -0
- package/dist/lib/projects/shared.js +13 -0
- package/dist/lib/projects/shared.js.map +1 -0
- package/dist/lib/secrets.d.ts +22 -0
- package/dist/lib/secrets.d.ts.map +1 -0
- package/{src → dist}/lib/secrets.js +32 -40
- package/dist/lib/secrets.js.map +1 -0
- package/dist/lib/telemetry.d.ts +21 -0
- package/dist/lib/telemetry.d.ts.map +1 -0
- package/dist/lib/telemetry.js +87 -0
- package/dist/lib/telemetry.js.map +1 -0
- package/dist/lib/types.d.ts +11 -0
- package/dist/lib/types.d.ts.map +1 -0
- package/dist/lib/types.js +2 -0
- package/dist/lib/types.js.map +1 -0
- package/dist/lib/utils.d.ts +106 -0
- package/dist/lib/utils.d.ts.map +1 -0
- package/{src → dist}/lib/utils.js +235 -347
- package/dist/lib/utils.js.map +1 -0
- package/dist/lib/version_check.d.ts +14 -0
- package/dist/lib/version_check.d.ts.map +1 -0
- package/{src → dist}/lib/version_check.js +25 -54
- package/dist/lib/version_check.js.map +1 -0
- package/oclif.manifest.json +722 -1
- package/package.json +137 -113
- package/index.js +0 -1
- package/src/bin/run +0 -16
- package/src/commands/actor/get-input.js +0 -12
- package/src/commands/actor/get-value.js +0 -23
- package/src/commands/actor/index.js +0 -13
- package/src/commands/actor/push-data.js +0 -44
- package/src/commands/actor/set-value.js +0 -63
- package/src/commands/call.js +0 -131
- package/src/commands/check-version.js +0 -28
- package/src/commands/create.js +0 -203
- package/src/commands/info.js +0 -24
- package/src/commands/init-wrap-scrapy.js +0 -34
- package/src/commands/init.js +0 -83
- package/src/commands/login.js +0 -40
- package/src/commands/logout.js +0 -18
- package/src/commands/pull.js +0 -154
- package/src/commands/push.js +0 -234
- package/src/commands/secrets/add.js +0 -28
- package/src/commands/secrets/index.js +0 -24
- package/src/commands/secrets/rm.js +0 -23
- package/src/commands/vis.js +0 -50
- package/src/hooks/init.js +0 -16
- package/src/lib/apify-oclif-help.js +0 -23
- package/src/lib/apify_command.js +0 -82
- package/src/lib/community.js +0 -3
- package/src/lib/consts.js +0 -69
- package/src/lib/files.js +0 -76
- package/src/lib/local_state.js +0 -39
- package/src/lib/scrapy-wrapper/Spider.js +0 -10
- package/src/lib/scrapy-wrapper/SpiderFileAnalyzer.js +0 -26
- package/src/lib/telemetry.js +0 -104
- /package/{src/bin → bin}/run.cmd +0 -0
|
@@ -1,89 +1,72 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const { warning } = require('./outputs');
|
|
12
|
-
const { getLocalConfig, getJsonFileContent, getLocalKeyValueStorePath } = require('./utils');
|
|
13
|
-
|
|
1
|
+
import { existsSync } from 'node:fs';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import process from 'node:process';
|
|
4
|
+
import { KEY_VALUE_STORE_KEYS } from '@apify/consts';
|
|
5
|
+
import { validateInputSchema } from '@apify/input_schema';
|
|
6
|
+
import _ from 'underscore';
|
|
7
|
+
import { writeJsonFile } from 'write-json-file';
|
|
8
|
+
import { ACTOR_SPECIFICATION_FOLDER } from './consts.js';
|
|
9
|
+
import { warning } from './outputs.js';
|
|
10
|
+
import { Ajv, getJsonFileContent, getLocalConfig, getLocalKeyValueStorePath } from './utils.js';
|
|
14
11
|
const DEFAULT_INPUT_SCHEMA_PATHS = [
|
|
15
12
|
'.actor/INPUT_SCHEMA.json',
|
|
16
13
|
'./INPUT_SCHEMA.json',
|
|
17
14
|
];
|
|
18
|
-
|
|
19
15
|
/**
|
|
20
16
|
* Return the input schema from the default location.
|
|
21
17
|
*
|
|
22
18
|
* When the input schema does not exist, null is returned for schema.
|
|
23
|
-
* In such a
|
|
19
|
+
* In such a case, path would be set to the location
|
|
24
20
|
* where the input schema would be expected to be found (and e.g. can be created there).
|
|
25
|
-
*
|
|
26
|
-
* @param {string} forcePath
|
|
27
|
-
* @returns {{inputSchema: object, inputSchemaPath: string | null}}
|
|
28
21
|
*/
|
|
29
|
-
const readInputSchema = async (forcePath) => {
|
|
22
|
+
export const readInputSchema = async ({ forcePath, cwd } = { cwd: process.cwd() }) => {
|
|
30
23
|
if (forcePath) {
|
|
31
24
|
return {
|
|
32
|
-
inputSchema:
|
|
25
|
+
inputSchema: getJsonFileContent(forcePath),
|
|
33
26
|
inputSchemaPath: forcePath,
|
|
34
27
|
};
|
|
35
28
|
}
|
|
36
|
-
|
|
37
|
-
const localConfig = getLocalConfig();
|
|
38
|
-
|
|
29
|
+
const localConfig = getLocalConfig(cwd);
|
|
39
30
|
if (typeof localConfig?.input === 'object') {
|
|
40
31
|
return {
|
|
41
32
|
inputSchema: localConfig.input,
|
|
42
33
|
inputSchemaPath: null,
|
|
43
34
|
};
|
|
44
35
|
}
|
|
45
|
-
|
|
46
36
|
if (typeof localConfig?.input === 'string') {
|
|
47
|
-
const fullPath =
|
|
37
|
+
const fullPath = join(cwd, ACTOR_SPECIFICATION_FOLDER, localConfig.input);
|
|
48
38
|
return {
|
|
49
|
-
inputSchema:
|
|
39
|
+
inputSchema: getJsonFileContent(fullPath),
|
|
50
40
|
inputSchemaPath: fullPath,
|
|
51
41
|
};
|
|
52
42
|
}
|
|
53
|
-
|
|
54
|
-
if (fs.existsSync(DEFAULT_INPUT_SCHEMA_PATHS[0])) {
|
|
43
|
+
if (existsSync(join(cwd, DEFAULT_INPUT_SCHEMA_PATHS[0]))) {
|
|
55
44
|
return {
|
|
56
|
-
inputSchema:
|
|
57
|
-
inputSchemaPath: DEFAULT_INPUT_SCHEMA_PATHS[0],
|
|
45
|
+
inputSchema: getJsonFileContent(join(cwd, DEFAULT_INPUT_SCHEMA_PATHS[0])),
|
|
46
|
+
inputSchemaPath: join(cwd, DEFAULT_INPUT_SCHEMA_PATHS[0]),
|
|
58
47
|
};
|
|
59
48
|
}
|
|
60
|
-
|
|
61
|
-
if (fs.existsSync(DEFAULT_INPUT_SCHEMA_PATHS[1])) {
|
|
49
|
+
if (existsSync(join(cwd, DEFAULT_INPUT_SCHEMA_PATHS[1]))) {
|
|
62
50
|
return {
|
|
63
|
-
inputSchema:
|
|
64
|
-
inputSchemaPath: DEFAULT_INPUT_SCHEMA_PATHS[1],
|
|
51
|
+
inputSchema: getJsonFileContent(join(cwd, DEFAULT_INPUT_SCHEMA_PATHS[1])),
|
|
52
|
+
inputSchemaPath: join(cwd, DEFAULT_INPUT_SCHEMA_PATHS[1]),
|
|
65
53
|
};
|
|
66
54
|
}
|
|
67
|
-
|
|
68
55
|
// If not input schema has been found so far, return the first default path
|
|
69
56
|
// where the input schema would be expected.
|
|
70
57
|
return {
|
|
71
58
|
inputSchema: null,
|
|
72
|
-
inputSchemaPath: DEFAULT_INPUT_SCHEMA_PATHS[0],
|
|
59
|
+
inputSchemaPath: join(cwd, DEFAULT_INPUT_SCHEMA_PATHS[0]),
|
|
73
60
|
};
|
|
74
61
|
};
|
|
75
|
-
|
|
76
62
|
/**
|
|
77
63
|
* Goes to the Actor directory and creates INPUT.json file from the input schema prefills.
|
|
78
|
-
|
|
64
|
+
|
|
79
65
|
*/
|
|
80
|
-
const createPrefilledInputFileFromInputSchema = async (actorFolderDir) => {
|
|
81
|
-
const currentDir = process.cwd();
|
|
66
|
+
export const createPrefilledInputFileFromInputSchema = async (actorFolderDir) => {
|
|
82
67
|
let inputFile = {};
|
|
83
68
|
try {
|
|
84
|
-
|
|
85
|
-
const { inputSchema } = await readInputSchema();
|
|
86
|
-
|
|
69
|
+
const { inputSchema } = await readInputSchema({ cwd: actorFolderDir });
|
|
87
70
|
if (inputSchema) {
|
|
88
71
|
/**
|
|
89
72
|
* TODO: The logic is copied from @apify-packages/actor -> getPrefillFromInputSchema
|
|
@@ -92,23 +75,19 @@ const createPrefilledInputFileFromInputSchema = async (actorFolderDir) => {
|
|
|
92
75
|
*/
|
|
93
76
|
const validator = new Ajv({ strict: false });
|
|
94
77
|
validateInputSchema(validator, inputSchema);
|
|
95
|
-
|
|
78
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
96
79
|
inputFile = _.mapObject(inputSchema.properties, (fieldSchema) => ((fieldSchema.type === 'boolean' || fieldSchema.editor === 'hidden')
|
|
97
80
|
? fieldSchema.default
|
|
98
|
-
: fieldSchema.prefill
|
|
99
|
-
));
|
|
81
|
+
: fieldSchema.prefill));
|
|
100
82
|
}
|
|
101
|
-
}
|
|
83
|
+
}
|
|
84
|
+
catch (err) {
|
|
102
85
|
warning(`Could not create default input based on input schema, creating empty input instead. Cause: ${err.message}`);
|
|
103
|
-
}
|
|
86
|
+
}
|
|
87
|
+
finally {
|
|
104
88
|
const keyValueStorePath = getLocalKeyValueStorePath();
|
|
105
|
-
const inputJsonPath =
|
|
89
|
+
const inputJsonPath = join(actorFolderDir, keyValueStorePath, `${KEY_VALUE_STORE_KEYS.INPUT}.json`);
|
|
106
90
|
await writeJsonFile(inputJsonPath, inputFile);
|
|
107
|
-
process.chdir(currentDir);
|
|
108
91
|
}
|
|
109
92
|
};
|
|
110
|
-
|
|
111
|
-
module.exports = {
|
|
112
|
-
readInputSchema,
|
|
113
|
-
createPrefilledInputFileFromInputSchema,
|
|
114
|
-
};
|
|
93
|
+
//# sourceMappingURL=input_schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"input_schema.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S,GAAG,IAAI,GAAG,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC;YAC7C,mBAAmB,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC;YAE5C,8DAA8D;YAC9D,SAAS,GAAG,CAAC,CAAC,SAAS,CAAC,WAAW,CAAC,UAAiB,EAAE,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,CAAC,IAAI,KAAK,SAAS,IAAI,WAAW,CAAC,MAAM,KAAK,QAAQ,CAAC;gBACxI,CAAC,CAAC,WAAW,CAAC,OAAO;gBACrB,CAAC,CAAC,WAAW,CAAC,OAAO,CACxB,CAAC,CAAC;QACP,CAAC;IACL,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACX,OAAO,CAAC,8FAA+F,GAAa,CAAC,OAAO,EAAE,CAAC,CAAC;IACpI,CAAC;YAAS,CAAC;QACP,MAAM,iBAAiB,GAAG,yBAAyB,EAAE,CAAC;QACtD,MAAM,aAAa,GAAG,IAAI,CAAC,cAAc,EAAE,iBAAiB,EAAE,GAAG,oBAAoB,CAAC,KAAK,OAAO,CAAC,CAAC;QACpG,MAAM,aAAa,CAAC,aAAa,EAAE,SAAS,CAAC,CAAC;IAClD,CAAC;AACL,CAAC,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns state object from auth file or empty object.
|
|
3
|
+
* This method is synchronous/blocking to avoid different race conditions.
|
|
4
|
+
*/
|
|
5
|
+
export declare const getLocalState: () => Record<string, unknown>;
|
|
6
|
+
/**
|
|
7
|
+
* Extends local state by given values.
|
|
8
|
+
* This method is synchronous/blocking to avoid different race conditions.
|
|
9
|
+
*/
|
|
10
|
+
export declare const extendLocalState: (data: Record<string, unknown>) => void;
|
|
11
|
+
//# sourceMappingURL=local_state.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"local_state.d.ts","sourceRoot":"","sources":["../../src/lib/local_state.ts"],"names":[],"mappings":"AAOA;;;GAGG;AACH,eAAO,MAAM,aAAa,+BAMzB,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,gBAAgB,SAAU,OAAO,MAAM,EAAE,OAAO,CAAC,SAM7D,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { loadJsonFileSync } from 'load-json-file';
|
|
2
|
+
import { writeJsonFileSync } from 'write-json-file';
|
|
3
|
+
import { STATE_FILE_PATH, } from './consts.js';
|
|
4
|
+
/**
|
|
5
|
+
* Returns state object from auth file or empty object.
|
|
6
|
+
* This method is synchronous/blocking to avoid different race conditions.
|
|
7
|
+
*/
|
|
8
|
+
export const getLocalState = () => {
|
|
9
|
+
try {
|
|
10
|
+
return loadJsonFileSync(STATE_FILE_PATH()) || {};
|
|
11
|
+
}
|
|
12
|
+
catch (e) {
|
|
13
|
+
return {};
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Extends local state by given values.
|
|
18
|
+
* This method is synchronous/blocking to avoid different race conditions.
|
|
19
|
+
*/
|
|
20
|
+
export const extendLocalState = (data) => {
|
|
21
|
+
const state = getLocalState();
|
|
22
|
+
writeJsonFileSync(STATE_FILE_PATH(), {
|
|
23
|
+
...state,
|
|
24
|
+
...data,
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
//# sourceMappingURL=local_state.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"local_state.js","sourceRoot":"","sources":["../../src/lib/local_state.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEpD,OAAO,EACH,eAAe,GAClB,MAAM,aAAa,CAAC;AAErB;;;GAGG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,GAAG,EAAE;IAC9B,IAAI,CAAC;QACD,OAAO,gBAAgB,CAA0B,eAAe,EAAE,CAAC,IAAI,EAAE,CAAC;IAC9E,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACT,OAAO,EAAE,CAAC;IACd,CAAC;AACL,CAAC,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,IAA6B,EAAE,EAAE;IAC9D,MAAM,KAAK,GAAG,aAAa,EAAE,CAAC;IAC9B,iBAAiB,CAAC,eAAe,EAAE,EAAE;QACjC,GAAG,KAAK;QACR,GAAG,IAAI;KACV,CAAC,CAAC;AACP,CAAC,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const error: (message: string) => void;
|
|
2
|
+
export declare const warning: (message: string) => void;
|
|
3
|
+
export declare const success: (message: string) => void;
|
|
4
|
+
export declare const run: (message: string) => void;
|
|
5
|
+
export declare const info: (message: string) => void;
|
|
6
|
+
export declare const link: (title: string, url: string) => void;
|
|
7
|
+
//# sourceMappingURL=outputs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"outputs.d.ts","sourceRoot":"","sources":["../../src/lib/outputs.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,KAAK,YAAa,MAAM,SAEpC,CAAC;AAEF,eAAO,MAAM,OAAO,YAAa,MAAM,SAEtC,CAAC;AAEF,eAAO,MAAM,OAAO,YAAa,MAAM,SAEtC,CAAC;AAEF,eAAO,MAAM,GAAG,YAAa,MAAM,SAElC,CAAC;AAEF,eAAO,MAAM,IAAI,YAAa,MAAM,SAEnC,CAAC;AAEF,eAAO,MAAM,IAAI,UAAW,MAAM,OAAO,MAAM,SAE9C,CAAC"}
|
|
@@ -1,27 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const error = (message) => {
|
|
1
|
+
import chalk from 'chalk';
|
|
2
|
+
export const error = (message) => {
|
|
4
3
|
console.log(`${chalk.red('Error:')} ${message}`);
|
|
5
4
|
};
|
|
6
|
-
|
|
7
|
-
const warning = (message) => {
|
|
5
|
+
export const warning = (message) => {
|
|
8
6
|
console.log(`${chalk.rgb(254, 90, 29).bold('Warning:')} ${message}`);
|
|
9
7
|
};
|
|
10
|
-
|
|
11
|
-
const success = (message) => {
|
|
8
|
+
export const success = (message) => {
|
|
12
9
|
console.log(`${chalk.green('Success:')} ${message}`);
|
|
13
10
|
};
|
|
14
|
-
|
|
15
|
-
const run = (message) => {
|
|
11
|
+
export const run = (message) => {
|
|
16
12
|
console.log(`${chalk.gray('Run:')} ${message}`);
|
|
17
13
|
};
|
|
18
|
-
|
|
19
|
-
const info = (message) => {
|
|
14
|
+
export const info = (message) => {
|
|
20
15
|
console.log(`${chalk.white('Info:')} ${message}`);
|
|
21
16
|
};
|
|
22
|
-
|
|
23
|
-
const link = (title, url) => {
|
|
17
|
+
export const link = (title, url) => {
|
|
24
18
|
console.log(`${chalk.blue(title)} -> ${url}`);
|
|
25
19
|
};
|
|
26
|
-
|
|
27
|
-
module.exports = { error, success, run, info, warning, link };
|
|
20
|
+
//# sourceMappingURL=outputs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"outputs.js","sourceRoot":"","sources":["../../src/lib/outputs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,OAAe,EAAE,EAAE;IACrC,OAAO,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,OAAO,EAAE,CAAC,CAAC;AACrD,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,OAAe,EAAE,EAAE;IACvC,OAAO,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,OAAO,EAAE,CAAC,CAAC;AACzE,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,OAAe,EAAE,EAAE;IACvC,OAAO,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,UAAU,CAAC,IAAI,OAAO,EAAE,CAAC,CAAC;AACzD,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,GAAG,GAAG,CAAC,OAAe,EAAE,EAAE;IACnC,OAAO,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,OAAO,EAAE,CAAC,CAAC;AACpD,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,IAAI,GAAG,CAAC,OAAe,EAAE,EAAE;IACpC,OAAO,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,OAAO,EAAE,CAAC,CAAC;AACtD,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,IAAI,GAAG,CAAC,KAAa,EAAE,GAAW,EAAE,EAAE;IAC/C,OAAO,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,GAAG,EAAE,CAAC,CAAC;AAClD,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project_analyzer.d.ts","sourceRoot":"","sources":["../../src/lib/project_analyzer.ts"],"names":[],"mappings":"AA4BA,qBAAa,eAAe;IACxB,MAAM,CAAC,cAAc,CAAC,QAAQ,EAAE,MAAM;CAWzC"}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { PROJECT_TYPES } from './consts.js';
|
|
2
|
+
import { CrawleeAnalyzer } from './projects/CrawleeAnalyzer.js';
|
|
3
|
+
import { OldApifySDKAnalyzer } from './projects/OldApifySDKAnalyzer.js';
|
|
4
|
+
import { ScrapyProjectAnalyzer } from './projects/scrapy/ScrapyProjectAnalyzer.js';
|
|
6
5
|
const analyzers = [
|
|
7
6
|
{
|
|
8
7
|
type: PROJECT_TYPES.SCRAPY,
|
|
@@ -17,19 +16,15 @@ const analyzers = [
|
|
|
17
16
|
analyzer: OldApifySDKAnalyzer,
|
|
18
17
|
},
|
|
19
18
|
];
|
|
20
|
-
|
|
21
|
-
class ProjectAnalyzer {
|
|
19
|
+
export class ProjectAnalyzer {
|
|
22
20
|
static getProjectType(pathname) {
|
|
23
21
|
const analyzer = analyzers.find((a) => {
|
|
24
22
|
if (!a.analyzer.isApplicable) {
|
|
25
23
|
throw new Error(`Analyzer ${a.analyzer} does not have isApplicable method.`);
|
|
26
24
|
}
|
|
27
|
-
|
|
28
25
|
return a.analyzer.isApplicable(pathname);
|
|
29
26
|
});
|
|
30
|
-
|
|
31
27
|
return analyzer?.type || PROJECT_TYPES.UNKNOWN;
|
|
32
28
|
}
|
|
33
29
|
}
|
|
34
|
-
|
|
35
|
-
module.exports = { ProjectAnalyzer };
|
|
30
|
+
//# sourceMappingURL=project_analyzer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project_analyzer.js","sourceRoot":"","sources":["../../src/lib/project_analyzer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AACxE,OAAO,EAAE,qBAAqB,EAAE,MAAM,4CAA4C,CAAC;AAUnF,MAAM,SAAS,GAA0B;IACrC;QACI,IAAI,EAAE,aAAa,CAAC,MAAM;QAC1B,QAAQ,EAAE,qBAAqB;KAClC;IACD;QACI,IAAI,EAAE,aAAa,CAAC,OAAO;QAC3B,QAAQ,EAAE,eAAe;KAC5B;IACD;QACI,IAAI,EAAE,aAAa,CAAC,qBAAqB;QACzC,QAAQ,EAAE,mBAAmB;KAChC;CACJ,CAAC;AAEF,MAAM,OAAO,eAAe;IACxB,MAAM,CAAC,cAAc,CAAC,QAAgB;QAClC,MAAM,QAAQ,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE;YAClC,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,YAAY,EAAE,CAAC;gBAC3B,MAAM,IAAI,KAAK,CAAC,YAAY,CAAC,CAAC,QAAQ,qCAAqC,CAAC,CAAC;YACjF,CAAC;YAED,OAAO,CAAC,CAAC,QAAQ,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;QAC7C,CAAC,CAAC,CAAC;QAEH,OAAO,QAAQ,EAAE,IAAI,IAAI,aAAa,CAAC,OAAO,CAAC;IACnD,CAAC;CACJ"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CrawleeAnalyzer.d.ts","sourceRoot":"","sources":["../../../src/lib/projects/CrawleeAnalyzer.ts"],"names":[],"mappings":"AAKA,qBAAa,eAAe;IACxB,MAAM,CAAC,YAAY,CAAC,QAAQ,EAAE,MAAM;CAiBvC"}
|
|
@@ -1,37 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
'crawlee',
|
|
6
|
-
'@crawlee/core',
|
|
7
|
-
'@crawlee/puppeteer',
|
|
8
|
-
'@crawlee/playwright',
|
|
9
|
-
'@crawlee/cheerio',
|
|
10
|
-
'@crawlee/jsdom',
|
|
11
|
-
'@crawlee/linkedom',
|
|
12
|
-
'@crawlee/http',
|
|
13
|
-
'@crawlee/browser',
|
|
14
|
-
'@crawlee/basic',
|
|
15
|
-
];
|
|
16
|
-
|
|
17
|
-
class CrawleeAnalyzer {
|
|
1
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import { CRAWLEE_PACKAGES } from './shared.js';
|
|
4
|
+
export class CrawleeAnalyzer {
|
|
18
5
|
static isApplicable(pathname) {
|
|
19
6
|
const hasPackageJson = existsSync(join(pathname, 'package.json'));
|
|
20
|
-
|
|
21
7
|
if (!hasPackageJson) {
|
|
22
8
|
return false;
|
|
23
9
|
}
|
|
24
|
-
|
|
25
10
|
const packageJson = readFileSync(join(pathname, 'package.json'), 'utf8');
|
|
26
|
-
|
|
27
11
|
try {
|
|
28
12
|
const packageJsonParsed = JSON.parse(packageJson);
|
|
29
|
-
|
|
30
13
|
return CRAWLEE_PACKAGES.some((pkg) => packageJsonParsed?.dependencies?.[pkg] !== undefined);
|
|
31
|
-
}
|
|
14
|
+
}
|
|
15
|
+
catch (err) {
|
|
32
16
|
return false;
|
|
33
17
|
}
|
|
34
18
|
}
|
|
35
19
|
}
|
|
36
|
-
|
|
37
|
-
exports.CrawleeAnalyzer = CrawleeAnalyzer;
|
|
20
|
+
//# sourceMappingURL=CrawleeAnalyzer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CrawleeAnalyzer.js","sourceRoot":"","sources":["../../../src/lib/projects/CrawleeAnalyzer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/C,MAAM,OAAO,eAAe;IACxB,MAAM,CAAC,YAAY,CAAC,QAAgB;QAChC,MAAM,cAAc,GAAG,UAAU,CAAC,IAAI,CAAC,QAAQ,EAAE,cAAc,CAAC,CAAC,CAAC;QAElE,IAAI,CAAC,cAAc,EAAE,CAAC;YAClB,OAAO,KAAK,CAAC;QACjB,CAAC;QAED,MAAM,WAAW,GAAG,YAAY,CAAC,IAAI,CAAC,QAAQ,EAAE,cAAc,CAAC,EAAE,MAAM,CAAC,CAAC;QAEzE,IAAI,CAAC;YACD,MAAM,iBAAiB,GAAG,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;YAElD,OAAO,gBAAgB,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,iBAAiB,EAAE,YAAY,EAAE,CAAC,GAAG,CAAC,KAAK,SAAS,CAAC,CAAC;QAChG,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACX,OAAO,KAAK,CAAC;QACjB,CAAC;IACL,CAAC;CACJ"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OldApifySDKAnalyzer.d.ts","sourceRoot":"","sources":["../../../src/lib/projects/OldApifySDKAnalyzer.ts"],"names":[],"mappings":"AASA,qBAAa,mBAAmB;IAC5B,MAAM,CAAC,YAAY,CAAC,QAAQ,EAAE,MAAM;CAsCvC"}
|
|
@@ -1,61 +1,38 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import { lt } from 'semver';
|
|
4
|
+
import { CRAWLEE_PACKAGES } from './shared.js';
|
|
6
5
|
const VERSION_WHEN_APIFY_MOVED_TO_CRAWLEE = '3.0.0';
|
|
7
|
-
|
|
8
|
-
'crawlee',
|
|
9
|
-
'@crawlee/core',
|
|
10
|
-
'@crawlee/puppeteer',
|
|
11
|
-
'@crawlee/playwright',
|
|
12
|
-
'@crawlee/cheerio',
|
|
13
|
-
'@crawlee/jsdom',
|
|
14
|
-
'@crawlee/linkedom',
|
|
15
|
-
'@crawlee/http',
|
|
16
|
-
'@crawlee/browser',
|
|
17
|
-
'@crawlee/basic',
|
|
18
|
-
];
|
|
19
|
-
|
|
20
|
-
class OldApifySDKAnalyzer {
|
|
6
|
+
export class OldApifySDKAnalyzer {
|
|
21
7
|
static isApplicable(pathname) {
|
|
22
8
|
const hasPackageJson = existsSync(join(pathname, 'package.json'));
|
|
23
|
-
|
|
24
9
|
if (!hasPackageJson) {
|
|
25
10
|
return false;
|
|
26
11
|
}
|
|
27
|
-
|
|
28
12
|
const packageJson = readFileSync(join(pathname, 'package.json'), 'utf8');
|
|
29
|
-
|
|
30
13
|
try {
|
|
31
14
|
const packageJsonParsed = JSON.parse(packageJson);
|
|
32
|
-
|
|
33
15
|
// If they have crawlee as a dependency, likely to use crawlee
|
|
34
16
|
if (CRAWLEE_PACKAGES.some((pkg) => packageJsonParsed?.dependencies?.[pkg] !== undefined)) {
|
|
35
17
|
return false;
|
|
36
18
|
}
|
|
37
|
-
|
|
38
19
|
const apifyVersion = packageJsonParsed?.dependencies?.apify;
|
|
39
20
|
if (!apifyVersion) {
|
|
40
21
|
return false;
|
|
41
22
|
}
|
|
42
|
-
|
|
43
|
-
// We cannot infer
|
|
23
|
+
// We cannot infer/crawlee v3
|
|
44
24
|
if (apifyVersion === '*') {
|
|
45
25
|
return false;
|
|
46
26
|
}
|
|
47
|
-
|
|
48
27
|
let actualVersion = apifyVersion;
|
|
49
|
-
|
|
50
28
|
if (apifyVersion.startsWith('~') || apifyVersion.startsWith('^')) {
|
|
51
29
|
actualVersion = apifyVersion.slice(1);
|
|
52
30
|
}
|
|
53
|
-
|
|
54
31
|
return lt(actualVersion, VERSION_WHEN_APIFY_MOVED_TO_CRAWLEE);
|
|
55
|
-
}
|
|
32
|
+
}
|
|
33
|
+
catch (err) {
|
|
56
34
|
return false;
|
|
57
35
|
}
|
|
58
36
|
}
|
|
59
37
|
}
|
|
60
|
-
|
|
61
|
-
exports.OldApifySDKAnalyzer = OldApifySDKAnalyzer;
|
|
38
|
+
//# sourceMappingURL=OldApifySDKAnalyzer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OldApifySDKAnalyzer.js","sourceRoot":"","sources":["../../../src/lib/projects/OldApifySDKAnalyzer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAE5B,OAAO,EA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AAK,CAAC;QACjB,CAAC;IACL,CAAC;CACJ"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import ConfigParser from 'configparser';
|
|
2
|
+
export declare class ScrapyProjectAnalyzer {
|
|
3
|
+
pathname: string;
|
|
4
|
+
configuration: ConfigParser;
|
|
5
|
+
settings: {
|
|
6
|
+
BOT_NAME: string;
|
|
7
|
+
SPIDER_MODULES: string[];
|
|
8
|
+
} | null;
|
|
9
|
+
constructor(pathname: string);
|
|
10
|
+
static isApplicable(pathname: string): boolean;
|
|
11
|
+
init(): Promise<void>;
|
|
12
|
+
loadScrapyCfg(): void;
|
|
13
|
+
loadSettings(): Promise<void>;
|
|
14
|
+
getName(): string | undefined;
|
|
15
|
+
getAvailableSpiders(): import("./Spider.js").Spider[];
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=ScrapyProjectAnalyzer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ScrapyProjectAnalyzer.d.ts","sourceRoot":"","sources":["../../../../src/lib/projects/scrapy/ScrapyProjectAnalyzer.ts"],"names":[],"mappings":"AAGA,OAAO,YAAY,MAAM,cAAc,CAAC;AAKxC,qBAAa,qBAAqB;IAC9B,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,EAAE,YAAY,CAAS;IACpC,QAAQ,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,cAAc,EAAE,MAAM,EAAE,CAAA;KAAE,GAAG,IAAI,CAAQ;gBAE3D,QAAQ,EAAE,MAAM;IAM5B,MAAM,CAAC,YAAY,CAAC,QAAQ,EAAE,MAAM;IAI9B,IAAI;IAIV,aAAa;IAaP,YAAY;IAuBlB,OAAO;IAIP,mBAAmB;CAsBtB"}
|
|
@@ -1,44 +1,50 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const { SpiderFileAnalyzer } = require('./SpiderFileAnalyzer');
|
|
9
|
-
|
|
10
|
-
class ScrapyProjectAnalyzer {
|
|
1
|
+
import { existsSync, readdirSync } from 'node:fs';
|
|
2
|
+
import { join, resolve } from 'node:path';
|
|
3
|
+
import ConfigParser from 'configparser';
|
|
4
|
+
import inquirer from 'inquirer';
|
|
5
|
+
import { SpiderFileAnalyzer } from './SpiderFileAnalyzer.js';
|
|
6
|
+
export class ScrapyProjectAnalyzer {
|
|
11
7
|
constructor(pathname) {
|
|
8
|
+
Object.defineProperty(this, "pathname", {
|
|
9
|
+
enumerable: true,
|
|
10
|
+
configurable: true,
|
|
11
|
+
writable: true,
|
|
12
|
+
value: void 0
|
|
13
|
+
});
|
|
14
|
+
Object.defineProperty(this, "configuration", {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
configurable: true,
|
|
17
|
+
writable: true,
|
|
18
|
+
value: null
|
|
19
|
+
});
|
|
20
|
+
Object.defineProperty(this, "settings", {
|
|
21
|
+
enumerable: true,
|
|
22
|
+
configurable: true,
|
|
23
|
+
writable: true,
|
|
24
|
+
value: null
|
|
25
|
+
});
|
|
12
26
|
this.pathname = pathname;
|
|
13
|
-
this.configuration = null;
|
|
14
27
|
this.settings = null;
|
|
15
28
|
this.loadScrapyCfg();
|
|
16
29
|
}
|
|
17
|
-
|
|
18
30
|
static isApplicable(pathname) {
|
|
19
|
-
return
|
|
31
|
+
return existsSync(join(pathname, 'scrapy.cfg'));
|
|
20
32
|
}
|
|
21
|
-
|
|
22
33
|
async init() {
|
|
23
34
|
await this.loadSettings();
|
|
24
35
|
}
|
|
25
|
-
|
|
26
36
|
loadScrapyCfg() {
|
|
27
37
|
const config = new ConfigParser();
|
|
28
|
-
const scrapyCfgPath =
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
throw new Error(`scrapy.cfg not found in "${scrapyCfgPath}".
|
|
38
|
+
const scrapyCfgPath = resolve(join(this.pathname, 'scrapy.cfg'));
|
|
39
|
+
if (!existsSync(scrapyCfgPath)) {
|
|
40
|
+
throw new Error(`scrapy.cfg not found in "${scrapyCfgPath}".
|
|
32
41
|
Are you sure there is a Scrapy project there?`);
|
|
33
42
|
}
|
|
34
|
-
|
|
35
43
|
config.read(scrapyCfgPath);
|
|
36
44
|
this.configuration = config;
|
|
37
45
|
}
|
|
38
|
-
|
|
39
46
|
async loadSettings() {
|
|
40
47
|
const assumedBotName = this.configuration.get('settings', 'default').split('.')[0];
|
|
41
|
-
|
|
42
48
|
const settings = await inquirer.prompt([
|
|
43
49
|
{
|
|
44
50
|
type: 'input',
|
|
@@ -53,38 +59,29 @@ Are you sure there is a Scrapy project there?`);
|
|
|
53
59
|
default: [`${assumedBotName}.spiders`],
|
|
54
60
|
},
|
|
55
61
|
]);
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
62
|
+
if (typeof settings.SPIDER_MODULES === 'string')
|
|
63
|
+
settings.SPIDER_MODULES = [settings.SPIDER_MODULES];
|
|
59
64
|
this.settings = settings;
|
|
60
65
|
}
|
|
61
|
-
|
|
62
66
|
getName() {
|
|
63
67
|
return this.settings?.BOT_NAME;
|
|
64
68
|
}
|
|
65
|
-
|
|
66
69
|
getAvailableSpiders() {
|
|
67
70
|
const spiderPaths = this.settings?.SPIDER_MODULES;
|
|
68
|
-
|
|
69
71
|
if (!spiderPaths) {
|
|
70
72
|
throw new Error('SPIDER_MODULES path not found in settings.');
|
|
71
73
|
}
|
|
72
|
-
|
|
73
74
|
const spiders = [];
|
|
74
|
-
|
|
75
75
|
for (const spiderPath of spiderPaths) {
|
|
76
|
-
const spidersDir =
|
|
77
|
-
|
|
76
|
+
const spidersDir = join(this.pathname, spiderPath.replaceAll('.', '/'));
|
|
78
77
|
const files = readdirSync(spidersDir, { withFileTypes: true });
|
|
79
78
|
for (const file of files) {
|
|
80
79
|
if (file.isFile() && file.name.endsWith('.py') && file.name !== '__init__.py') {
|
|
81
|
-
spiders.push(...(new SpiderFileAnalyzer(
|
|
80
|
+
spiders.push(...(new SpiderFileAnalyzer(join(spidersDir, file.name)).getSpiders()));
|
|
82
81
|
}
|
|
83
82
|
}
|
|
84
83
|
}
|
|
85
|
-
|
|
86
84
|
return spiders;
|
|
87
85
|
}
|
|
88
86
|
}
|
|
89
|
-
|
|
90
|
-
module.exports = { ScrapyProjectAnalyzer };
|
|
87
|
+
//# sourceMappingURL=ScrapyProjectAnalyzer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ScrapyProjectAnalyzer.js","sourceRoot":"","sources":["../../../../src/lib/projects/scrapy/ScrapyProjectAnalyzer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAClD,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAE1C,OAAO,YAAY,MAAM,cAAc,CAAC;AACxC,OAAO,QAAQ,MAAM,UAAU,CAAC;AAEhC,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAE7D,MAAM,OAAO,qBAAqB;IAK9B,YAAY,QAAgB;QAJ5B;;;;;WAAiB;QACjB;;;;mBAA8B,IAAK;WAAC;QACpC;;;;mBAAkE,IAAI;WAAC;QAGnE,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;QACrB,IAAI,CAAC,aAAa,EAAE,CAAC;IACzB,CAAC;IAED,MAAM,CAAC,YAAY,CAAC,QAAgB;QAChC,OAAO,UAAU,CAAC,IAAI,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC,CAAC;IACpD,CAAC;IAED,KAAK,CAAC,IAAI;QACN,MAAM,IAAI,CAAC,YAAY,EAAE,CAAC;IAC9B,CAAC;IAED,aAAa;QACT,MAAM,MAAM,GAAG,IAAI,YAAY,EAAE,CAAC;QAClC,MAAM,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC,CA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ACnC,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,UAAU,CAAC,UAAU,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;YAExE,MAAM,KAAK,GAAG,WAAW,CAAC,UAAU,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAC;YAC/D,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;gBACvB,IAAI,IAAI,CAAC,MAAM,EAAE,IAAI,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,IAAI,CAAC,IAAI,KAAK,aAAa,EAAE,CAAC;oBAC5E,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,kBAAkB,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC;gBACxF,CAAC;YACL,CAAC;QACL,CAAC;QAED,OAAO,OAAO,CAAC;IACnB,CAAC;CACJ"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare class Spider {
|
|
2
|
+
name?: string;
|
|
3
|
+
class_name: string;
|
|
4
|
+
start_urls?: string;
|
|
5
|
+
pathname: string;
|
|
6
|
+
constructor(data: SpiderData);
|
|
7
|
+
}
|
|
8
|
+
export interface SpiderData {
|
|
9
|
+
name?: string;
|
|
10
|
+
class_name: string;
|
|
11
|
+
start_urls?: string;
|
|
12
|
+
pathname: string;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=Spider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Spider.d.ts","sourceRoot":"","sources":["../../../../src/lib/projects/scrapy/Spider.ts"],"names":[],"mappings":"AAAA,qBAAa,MAAM;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;gBAEL,IAAI,EAAE,UAAU;CAM/B;AAED,MAAM,WAAW,UAAU;IACvB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;CACpB"}
|