apify-cli 0.19.3-beta.5 → 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 +73 -52
- 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 -84
- 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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/actor/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAE1D,qBAAa,iBAAkB,SAAQ,YAAY,CAAC,OAAO,iBAAiB,CAAC;IACzE,OAAgB,WAAW,SAA6H;IAClJ,GAAG;CAGZ"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ApifyCommand } from '../../lib/apify_command.js';
|
|
2
|
+
export class ActorIndexCommand extends ApifyCommand {
|
|
3
|
+
async run() {
|
|
4
|
+
await this.printHelp();
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
Object.defineProperty(ActorIndexCommand, "description", {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
configurable: true,
|
|
10
|
+
writable: true,
|
|
11
|
+
value: 'Commands are designed to be used in Actor runs. All commands are in PoC state, do not use in production environments.\n'
|
|
12
|
+
});
|
|
13
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/actor/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAE1D,MAAM,OAAO,iBAAkB,SAAQ,YAAsC;IAEzE,KAAK,CAAC,GAAG;QACL,MAAM,IAAI,CAAC,SAAS,EAAE,CAAC;IAC3B,CAAC;;AAHe;;;;WAAc,yHAAyH;GAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ApifyCommand } from '../../lib/apify_command.js';
|
|
2
|
+
export declare class PushDataCommand extends ApifyCommand<typeof PushDataCommand> {
|
|
3
|
+
static description: string;
|
|
4
|
+
static args: {
|
|
5
|
+
item: import("@oclif/core/lib/interfaces/parser.js").Arg<string | undefined, Record<string, unknown>>;
|
|
6
|
+
};
|
|
7
|
+
private stdin?;
|
|
8
|
+
init(): Promise<void>;
|
|
9
|
+
run(): Promise<void>;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=push-data.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"push-data.d.ts","sourceRoot":"","sources":["../../../src/commands/actor/push-data.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAE1D,qBAAa,eAAgB,SAAQ,YAAY,CAAC,OAAO,eAAe,CAAC;IACrE,OAAgB,WAAW,SAKyB;IAEpD,OAAgB,IAAI;;MAKlB;IAEF,OAAO,CAAC,KAAK,CAAC,CAAS;IAER,IAAI;IAMb,GAAG;CAgBZ"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { Args } from '@oclif/core';
|
|
2
|
+
import { APIFY_STORAGE_TYPES, getApifyStorageClient, getDefaultStorageId } from '../../lib/actor.js';
|
|
3
|
+
import { ApifyCommand } from '../../lib/apify_command.js';
|
|
4
|
+
export class PushDataCommand extends ApifyCommand {
|
|
5
|
+
constructor() {
|
|
6
|
+
super(...arguments);
|
|
7
|
+
Object.defineProperty(this, "stdin", {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
configurable: true,
|
|
10
|
+
writable: true,
|
|
11
|
+
value: void 0
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
async init() {
|
|
15
|
+
await super.init();
|
|
16
|
+
// Read data from stdin of the command
|
|
17
|
+
this.stdin = await this.readStdin(process.stdin);
|
|
18
|
+
}
|
|
19
|
+
async run() {
|
|
20
|
+
const { item } = this.args;
|
|
21
|
+
const apifyClient = await getApifyStorageClient();
|
|
22
|
+
const defaultStoreId = getDefaultStorageId(APIFY_STORAGE_TYPES.DATASET);
|
|
23
|
+
const data = item || this.stdin;
|
|
24
|
+
let parsedData;
|
|
25
|
+
try {
|
|
26
|
+
parsedData = JSON.parse(data);
|
|
27
|
+
}
|
|
28
|
+
catch (err) {
|
|
29
|
+
throw new Error(`Failed to parse data as JSON string: ${err.message}`);
|
|
30
|
+
}
|
|
31
|
+
await apifyClient.dataset(defaultStoreId).pushItems(parsedData);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
Object.defineProperty(PushDataCommand, "description", {
|
|
35
|
+
enumerable: true,
|
|
36
|
+
configurable: true,
|
|
37
|
+
writable: true,
|
|
38
|
+
value: 'Stores an object or an array of objects to the default dataset of the Actor run.\n'
|
|
39
|
+
+ 'It is possible to pass data using item argument or stdin.\n'
|
|
40
|
+
+ 'Passing data using argument:\n'
|
|
41
|
+
+ '$ apify actor:push-data {"foo": "bar"}\n'
|
|
42
|
+
+ 'Passing data using stdin with pipe:\n'
|
|
43
|
+
+ '$ cat ./test.json | apify actor:push-data\n'
|
|
44
|
+
});
|
|
45
|
+
Object.defineProperty(PushDataCommand, "args", {
|
|
46
|
+
enumerable: true,
|
|
47
|
+
configurable: true,
|
|
48
|
+
writable: true,
|
|
49
|
+
value: {
|
|
50
|
+
item: Args.string({
|
|
51
|
+
required: false,
|
|
52
|
+
description: 'JSON string with one object or array of objects containing data to be stored in the default dataset.',
|
|
53
|
+
}),
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
//# sourceMappingURL=push-data.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"push-data.js","sourceRoot":"","sources":["../../../src/commands/actor/push-data.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAEnC,OAAO,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AACrG,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAE1D,MAAM,OAAO,eAAgB,SAAQ,YAAoC;IAAzE;;QAeY;;;;;WAAe;IAwB3B,CAAC;IAtBY,KAAK,CAAC,IAAI;QACf,MAAM,KAAK,CAAC,IAAI,EAAE,CAAC;QACnB,sCAAsC;QACtC,IAAI,CAAC,KAAK,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IACrD,CAAC;IAED,KAAK,CAAC,GAAG;QACL,MAAM,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC,IAAI,CAAC;QAE3B,MAAM,WAAW,GAAG,MAAM,qBAAqB,EAAE,CAAC;QAClD,MAAM,cAAc,GAAG,mBAAmB,CAAC,mBAAmB,CAAC,OAAO,CAAC,CAAC;QACxE,MAAM,IAAI,GAAG,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC;QAEhC,IAAI,UAA+D,CAAC;QACpE,IAAI,CAAC;YACD,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,IAAK,CAAC,CAAC;QACnC,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACX,MAAM,IAAI,KAAK,CAAC,wCAAyC,GAAa,CAAC,OAAO,EAAE,CAAC,CAAC;QACtF,CAAC;QAED,MAAM,WAAW,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;IACpE,CAAC;;AArCe;;;;WAAc,oFAAoF;UAC5G,6DAA6D;UAC7D,gCAAgC;UAChC,0CAA0C;UAC1C,uCAAuC;UACvC,6CAA6C;EALxB,CAKyB;AAEpC;;;;WAAO;QACnB,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC;YACd,QAAQ,EAAE,KAAK;YACf,WAAW,EAAE,sGAAsG;SACtH,CAAC;KACL;EALmB,CAKlB"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ApifyCommand } from '../../lib/apify_command.js';
|
|
2
|
+
export declare class SetValueCommand extends ApifyCommand<typeof SetValueCommand> {
|
|
3
|
+
static description: string;
|
|
4
|
+
static args: {
|
|
5
|
+
key: import("@oclif/core/lib/interfaces/parser.js").Arg<string, Record<string, unknown>>;
|
|
6
|
+
value: import("@oclif/core/lib/interfaces/parser.js").Arg<string | undefined, Record<string, unknown>>;
|
|
7
|
+
};
|
|
8
|
+
static flags: {
|
|
9
|
+
contentType: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
10
|
+
};
|
|
11
|
+
private stdin?;
|
|
12
|
+
init(): Promise<void>;
|
|
13
|
+
run(): Promise<void>;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=set-value.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"set-value.d.ts","sourceRoot":"","sources":["../../../src/commands/actor/set-value.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAE1D,qBAAa,eAAgB,SAAQ,YAAY,CAAC,OAAO,eAAe,CAAC;IACrE,OAAgB,WAAW,SAK6D;IAExF,OAAgB,IAAI;;;MAYlB;IAEF,OAAgB,KAAK;;MAMnB;IAEF,OAAO,CAAC,KAAK,CAAC,CAAuB;IAEtB,IAAI;IAMb,GAAG;CAgBZ"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { Args, Flags } from '@oclif/core';
|
|
2
|
+
import { APIFY_STORAGE_TYPES, getApifyStorageClient, getDefaultStorageId } from '../../lib/actor.js';
|
|
3
|
+
import { ApifyCommand } from '../../lib/apify_command.js';
|
|
4
|
+
export class SetValueCommand extends ApifyCommand {
|
|
5
|
+
constructor() {
|
|
6
|
+
super(...arguments);
|
|
7
|
+
Object.defineProperty(this, "stdin", {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
configurable: true,
|
|
10
|
+
writable: true,
|
|
11
|
+
value: void 0
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
async init() {
|
|
15
|
+
await super.init();
|
|
16
|
+
// Read data from stdin of the command
|
|
17
|
+
this.stdin = process.stdin;
|
|
18
|
+
}
|
|
19
|
+
async run() {
|
|
20
|
+
const { stdin } = this;
|
|
21
|
+
const { key, value } = this.args;
|
|
22
|
+
const { contentType = 'application/json; charset=utf-8' } = this.flags;
|
|
23
|
+
// NOTE: If user pass value as argument and data on stdin same time. We use the value from argument.
|
|
24
|
+
const recordValue = value || stdin;
|
|
25
|
+
const apifyClient = await getApifyStorageClient();
|
|
26
|
+
const storeClient = apifyClient.keyValueStore(getDefaultStorageId(APIFY_STORAGE_TYPES.KEY_VALUE_STORE));
|
|
27
|
+
if (recordValue === undefined || recordValue === null) {
|
|
28
|
+
await storeClient.deleteRecord(key);
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
await storeClient.setRecord({ key, value: recordValue, contentType });
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
Object.defineProperty(SetValueCommand, "description", {
|
|
36
|
+
enumerable: true,
|
|
37
|
+
configurable: true,
|
|
38
|
+
writable: true,
|
|
39
|
+
value: 'Sets or removes record into the default KeyValueStore associated with the Actor run.\n'
|
|
40
|
+
+ 'It is possible to pass data using argument or stdin.\n'
|
|
41
|
+
+ 'Passing data using argument:\n'
|
|
42
|
+
+ '$ apify actor:set-value KEY my-value\n'
|
|
43
|
+
+ 'Passing data using stdin with pipe:\n'
|
|
44
|
+
+ '$ cat ./my-text-file.txt | apify actor:set-value KEY --contentType text/plain\n'
|
|
45
|
+
});
|
|
46
|
+
Object.defineProperty(SetValueCommand, "args", {
|
|
47
|
+
enumerable: true,
|
|
48
|
+
configurable: true,
|
|
49
|
+
writable: true,
|
|
50
|
+
value: {
|
|
51
|
+
key: Args.string({
|
|
52
|
+
required: true,
|
|
53
|
+
description: 'Key of the record in key-value store.',
|
|
54
|
+
}),
|
|
55
|
+
value: Args.string({
|
|
56
|
+
required: false,
|
|
57
|
+
description: 'Record data, which can be one of the following values:\n'
|
|
58
|
+
+ '- If empty, the record in the key-value store is deleted.\n'
|
|
59
|
+
+ '- If no `contentType` flag is specified, value is expected to be any JSON string value.\n'
|
|
60
|
+
+ '- If options.contentType is set, value is taken as is.',
|
|
61
|
+
}),
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
Object.defineProperty(SetValueCommand, "flags", {
|
|
65
|
+
enumerable: true,
|
|
66
|
+
configurable: true,
|
|
67
|
+
writable: true,
|
|
68
|
+
value: {
|
|
69
|
+
contentType: Flags.string({
|
|
70
|
+
char: 'c',
|
|
71
|
+
description: 'Specifies a custom MIME content type of the record. By default "application/json" is used.',
|
|
72
|
+
required: false,
|
|
73
|
+
}),
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
//# sourceMappingURL=set-value.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"set-value.js","sourceRoot":"","sources":["../../../src/commands/actor/set-value.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAE1C,OAAO,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AACrG,OAAO,EAAE,YAAY,EAAE,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AAQ,EAAE,KAAK;YACf,WAAW,EAAE,0DAA0D;kBACrE,6DAA6D;kBAC7D,2FAA2F;kBAC3F,wDAAwD;SAC7D,CAAC;KACL;EAZmB,CAYlB;AAEc;;;;WAAQ;QACpB,WAAW,EAAE,KAAK,CAAC,MAAM,CAAC;YACtB,IAAI,EAAE,GAAG;YACT,WAAW,EAAE,4FAA4F;YACzG,QAAQ,EAAE,KAAK;SAClB,CAAC;KACL;EANoB,CAMnB"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ApifyCommand } from '../lib/apify_command.js';
|
|
2
|
+
export declare class CallCommand extends ApifyCommand<typeof CallCommand> {
|
|
3
|
+
static description: string;
|
|
4
|
+
static flags: {
|
|
5
|
+
build: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
6
|
+
timeout: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<number | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
7
|
+
memory: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<number | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
8
|
+
'wait-for-finish': import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
9
|
+
};
|
|
10
|
+
static args: {
|
|
11
|
+
actorId: import("@oclif/core/lib/interfaces/parser.js").Arg<string | undefined, Record<string, unknown>>;
|
|
12
|
+
};
|
|
13
|
+
run(): Promise<void>;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=call.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"call.d.ts","sourceRoot":"","sources":["../../src/commands/call.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAKvD,qBAAa,WAAY,SAAQ,YAAY,CAAC,OAAO,WAAW,CAAC;IAC7D,OAAgB,WAAW,SAEyD;IAEpF,OAAgB,KAAK;;;;;MAqBnB;IAEF,OAAgB,IAAI;;MAMlB;IAEI,GAAG;CAoFZ"}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
// TODO: Show full error messages and HTTP codes, this is not great:
|
|
2
|
+
// jan:testx$ apify call help
|
|
3
|
+
// Run: Calling act help...
|
|
4
|
+
// Error: [record-not-found]
|
|
5
|
+
import process from 'node:process';
|
|
6
|
+
import { ACTOR_JOB_STATUSES } from '@apify/consts';
|
|
7
|
+
import { Args, Flags } from '@oclif/core';
|
|
8
|
+
import mime from 'mime';
|
|
9
|
+
import { ApifyCommand } from '../lib/apify_command.js';
|
|
10
|
+
import { LOCAL_CONFIG_PATH } from '../lib/consts.js';
|
|
11
|
+
import { error, link, run as runLog, success, warning } from '../lib/outputs.js';
|
|
12
|
+
import { getLocalConfig, getLocalInput, getLocalUserInfo, getLoggedClientOrThrow, outputJobLog } from '../lib/utils.js';
|
|
13
|
+
export class CallCommand extends ApifyCommand {
|
|
14
|
+
async run() {
|
|
15
|
+
const cwd = process.cwd();
|
|
16
|
+
const localConfig = getLocalConfig(cwd) || {};
|
|
17
|
+
const apifyClient = await getLoggedClientOrThrow();
|
|
18
|
+
const userInfo = await getLocalUserInfo();
|
|
19
|
+
const usernameOrId = userInfo.username || userInfo.id;
|
|
20
|
+
const forceActorId = this.args.actorId;
|
|
21
|
+
let actorId;
|
|
22
|
+
if (forceActorId) {
|
|
23
|
+
const actor = await apifyClient.actor(forceActorId).get();
|
|
24
|
+
if (!actor)
|
|
25
|
+
throw new Error(`Cannot find Actor with ID '${forceActorId}' in your account.`);
|
|
26
|
+
actorId = actor.username ? `${actor.username}/${actor.name}` : actor.id;
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
actorId = `${usernameOrId}/${localConfig.name}`;
|
|
30
|
+
const actor = await apifyClient.actor(actorId).get();
|
|
31
|
+
if (!actor) {
|
|
32
|
+
throw new Error(`Cannot find Actor with ID '${actorId}' `
|
|
33
|
+
+ 'in your account. Call "apify push" to push this Actor to Apify platform.');
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
const runOpts = {
|
|
37
|
+
waitForFinish: 2, // NOTE: We need to wait some time to Apify open stream and we can create connection
|
|
38
|
+
};
|
|
39
|
+
const waitForFinishMillis = Number.isNaN(this.flags.waitForFinish)
|
|
40
|
+
? undefined
|
|
41
|
+
: Number.parseInt(this.flags.waitForFinish, 10) * 1000;
|
|
42
|
+
if (this.flags.build) {
|
|
43
|
+
runOpts.build = this.flags.build;
|
|
44
|
+
}
|
|
45
|
+
if (this.flags.timeout) {
|
|
46
|
+
runOpts.timeout = this.flags.timeout;
|
|
47
|
+
}
|
|
48
|
+
if (this.flags.memory) {
|
|
49
|
+
runOpts.memory = this.flags.memory;
|
|
50
|
+
}
|
|
51
|
+
// Get input for act
|
|
52
|
+
const localInput = getLocalInput(cwd);
|
|
53
|
+
runLog(`Calling Actor ${actorId}`);
|
|
54
|
+
let run;
|
|
55
|
+
try {
|
|
56
|
+
if (localInput) {
|
|
57
|
+
// TODO: For some reason we cannot pass json as buffer with right contentType into apify-client.
|
|
58
|
+
// It will save malformed JSON which looks like buffer as INPUT.
|
|
59
|
+
// We need to fix this in v1 during removing call under actor namespace.
|
|
60
|
+
const input = mime.getExtension(localInput.contentType) === 'json' ? JSON.parse(localInput.body.toString('utf-8')) : localInput.body;
|
|
61
|
+
run = await apifyClient.actor(actorId).start(input, { ...runOpts, contentType: localInput.contentType });
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
run = await apifyClient.actor(actorId).start(null, runOpts);
|
|
65
|
+
}
|
|
66
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
67
|
+
}
|
|
68
|
+
catch (err) {
|
|
69
|
+
// TODO: Better error message in apify-client-js
|
|
70
|
+
if (err.type === 'record-not-found')
|
|
71
|
+
throw new Error(`Actor ${actorId} not found!`);
|
|
72
|
+
else
|
|
73
|
+
throw err;
|
|
74
|
+
}
|
|
75
|
+
try {
|
|
76
|
+
await outputJobLog(run, waitForFinishMillis);
|
|
77
|
+
}
|
|
78
|
+
catch (err) {
|
|
79
|
+
warning('Can not get log:');
|
|
80
|
+
console.error(err);
|
|
81
|
+
}
|
|
82
|
+
run = (await apifyClient.run(run.id).get());
|
|
83
|
+
link('Actor run detail', `https://console.apify.com/actors/${run.actId}#/runs/${run.id}`);
|
|
84
|
+
if (run.status === ACTOR_JOB_STATUSES.SUCCEEDED) {
|
|
85
|
+
success('Actor finished.');
|
|
86
|
+
}
|
|
87
|
+
else if (run.status === ACTOR_JOB_STATUSES.RUNNING) {
|
|
88
|
+
warning('Actor is still running!');
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
error('Actor failed!');
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
Object.defineProperty(CallCommand, "description", {
|
|
96
|
+
enumerable: true,
|
|
97
|
+
configurable: true,
|
|
98
|
+
writable: true,
|
|
99
|
+
value: 'Runs a specific Actor remotely on the Apify cloud platform.\n'
|
|
100
|
+
+ 'The Actor is run under your current Apify account. Therefore you need to be logged in by calling "apify login". '
|
|
101
|
+
+ 'It takes input for the Actor from the default local key-value store by default.'
|
|
102
|
+
});
|
|
103
|
+
Object.defineProperty(CallCommand, "flags", {
|
|
104
|
+
enumerable: true,
|
|
105
|
+
configurable: true,
|
|
106
|
+
writable: true,
|
|
107
|
+
value: {
|
|
108
|
+
build: Flags.string({
|
|
109
|
+
char: 'b',
|
|
110
|
+
description: 'Tag or number of the build to run (e.g. "latest" or "1.2.34").',
|
|
111
|
+
required: false,
|
|
112
|
+
}),
|
|
113
|
+
timeout: Flags.integer({
|
|
114
|
+
char: 't',
|
|
115
|
+
description: 'Timeout for the Actor run in seconds. Zero value means there is no timeout.',
|
|
116
|
+
required: false,
|
|
117
|
+
}),
|
|
118
|
+
memory: Flags.integer({
|
|
119
|
+
char: 'm',
|
|
120
|
+
description: 'Amount of memory allocated for the Actor run, in megabytes.',
|
|
121
|
+
required: false,
|
|
122
|
+
}),
|
|
123
|
+
'wait-for-finish': Flags.string({
|
|
124
|
+
char: 'w',
|
|
125
|
+
description: 'Seconds for waiting to run to finish, if no value passed, it waits forever.',
|
|
126
|
+
required: false,
|
|
127
|
+
}),
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
Object.defineProperty(CallCommand, "args", {
|
|
131
|
+
enumerable: true,
|
|
132
|
+
configurable: true,
|
|
133
|
+
writable: true,
|
|
134
|
+
value: {
|
|
135
|
+
actorId: Args.string({
|
|
136
|
+
required: false,
|
|
137
|
+
description: 'Name or ID of the Actor to run (e.g. "apify/hello-world" or "E2jjCZBezvAZnX8Rb"). '
|
|
138
|
+
+ `If not provided, the command runs the remote Actor specified in the "${LOCAL_CONFIG_PATH}" file.`,
|
|
139
|
+
}),
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
//# sourceMappingURL=call.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"call.js","sourceRoot":"","sources":["../../src/commands/call.ts"],"names":[],"mappings":"AAAA,oEAAoE;AACpE,6BAA6B;AAC7B,2BAA2B;AAC3B,4BAA4B;AAE5B,OAAO,OAAO,MAAM,cAAc,CAAC;AAEnC,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAE1C,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,IAAI,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AACjF,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,gBAAgB,EAAE,sBAAsB,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,CAAC,MAAM,CAAC;YAChB,IAAI,EAAE,GAAG;YACT,WAAW,EAAE,gEAAgE;YAC7E,QAAQ,EAAE,KAAK;SAClB,CAAC;QACF,OAAO,EAAE,KAAK,CAAC,OAAO,CAAC;YACnB,IAAI,EAAE,GAAG;YACT,WAAW,EAAE,6EAA6E;YAC1F,QAAQ,EAAE,KAAK;SAClB,CAAC;QACF,MAAM,EAAE,KAAK,CAAC,OAAO,CAAC;YAClB,IAAI,EAAE,GAAG;YACT,WAAW,EAAE,6DAA6D;YAC1E,QAAQ,EAAE,KAAK;SAClB,CAAC;QACF,iBAAiB,EAAE,KAAK,CAAC,MAAM,CAAC;YAC5B,IAAI,EAAE,GAAG;YACT,WAAW,EAAE,6EAA6E;YAC1F,QAAQ,EAAE,KAAK;SAClB,CAAC;KACL;GAAC;AAEc;;;;WAAO;QACnB,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC;YACjB,QAAQ,EAAE,KAAK;YACf,WAAW,EAAE,oFAAoF;kBAC/F,wEAAwE,iBAAiB,SAAS;SACvG,CAAC;KACL;GAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ApifyCommand } from '../lib/apify_command.js';
|
|
2
|
+
export declare class CheckVersionCommand extends ApifyCommand<typeof CheckVersionCommand> {
|
|
3
|
+
static description: string;
|
|
4
|
+
static flags: {
|
|
5
|
+
'enforce-update': import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
|
|
6
|
+
};
|
|
7
|
+
static hidden: boolean;
|
|
8
|
+
static hiddenAliases: string[];
|
|
9
|
+
run(): Promise<void>;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=check-version.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"check-version.d.ts","sourceRoot":"","sources":["../../src/commands/check-version.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAGvD,qBAAa,mBAAoB,SAAQ,YAAY,CAAC,OAAO,mBAAmB,CAAC;IAC7E,OAAgB,WAAW,SAA4D;IAEvF,OAAgB,KAAK;;MAMnB;IAEF,OAAgB,MAAM,UAAQ;IAE9B,OAAgB,aAAa,WAAU;IAEjC,GAAG;CAGZ"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { Flags } from '@oclif/core';
|
|
2
|
+
import { ApifyCommand } from '../lib/apify_command.js';
|
|
3
|
+
import { checkLatestVersion } from '../lib/version_check.js';
|
|
4
|
+
export class CheckVersionCommand extends ApifyCommand {
|
|
5
|
+
async run() {
|
|
6
|
+
await checkLatestVersion(this.flags.enforceUpdate);
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(CheckVersionCommand, "description", {
|
|
10
|
+
enumerable: true,
|
|
11
|
+
configurable: true,
|
|
12
|
+
writable: true,
|
|
13
|
+
value: 'Checks that installed Apify CLI version is up to date.'
|
|
14
|
+
});
|
|
15
|
+
Object.defineProperty(CheckVersionCommand, "flags", {
|
|
16
|
+
enumerable: true,
|
|
17
|
+
configurable: true,
|
|
18
|
+
writable: true,
|
|
19
|
+
value: {
|
|
20
|
+
'enforce-update': Flags.boolean({
|
|
21
|
+
char: 'e',
|
|
22
|
+
description: '[Optional] Enforce version update from NPM',
|
|
23
|
+
required: false,
|
|
24
|
+
}),
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
Object.defineProperty(CheckVersionCommand, "hidden", {
|
|
28
|
+
enumerable: true,
|
|
29
|
+
configurable: true,
|
|
30
|
+
writable: true,
|
|
31
|
+
value: true
|
|
32
|
+
});
|
|
33
|
+
Object.defineProperty(CheckVersionCommand, "hiddenAliases", {
|
|
34
|
+
enumerable: true,
|
|
35
|
+
configurable: true,
|
|
36
|
+
writable: true,
|
|
37
|
+
value: ['cv']
|
|
38
|
+
});
|
|
39
|
+
//# sourceMappingURL=check-version.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"check-version.js","sourceRoot":"","sources":["../../src/commands/check-version.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAEpC,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAE7D,MAAM,OAAO,mBAAoB,SAAQ,YAAwC;IAe7E,KAAK,CAAC,GAAG;QACL,MAAM,kBAAkB,CAAC,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;IACvD,CAAC;;AAhBe;;;;WAAc,wDAAwD;GAAC;AAEvE;;;;WAAQ;QACpB,gBAAgB,EAAE,KAAK,CAAC,OAAO,CAAC;YAC5B,IAAI,EAAE,GAAG;YACT,WAAW,EAAE,4CAA4C;YACzD,QAAQ,EAAE,KAAK;SAClB,CAAC;KACL;GAAC;AAEc;;;;WAAS,IAAI;GAAC;AAEd;;;;WAAgB,CAAC,IAAI,CAAC;GAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ApifyCommand } from '../lib/apify_command.js';
|
|
2
|
+
export declare class CreateCommand extends ApifyCommand<typeof CreateCommand> {
|
|
3
|
+
static description: string;
|
|
4
|
+
static flags: {
|
|
5
|
+
template: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
6
|
+
'skip-dependency-install': import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
|
|
7
|
+
'template-archive-url': import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
8
|
+
};
|
|
9
|
+
static args: {
|
|
10
|
+
actorName: import("@oclif/core/lib/interfaces/parser.js").Arg<string | undefined, Record<string, unknown>>;
|
|
11
|
+
};
|
|
12
|
+
run(): Promise<void>;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=create.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../src/commands/create.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAqBvD,qBAAa,aAAc,SAAQ,YAAY,CAAC,OAAO,aAAa,CAAC;IACjE,OAAgB,WAAW,SAAiF;IAE5G,OAAgB,KAAK;;;;MAgBnB;IAEF,OAAgB,IAAI;;MAKlB;IAEI,GAAG;CAgJZ"}
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
import { existsSync, mkdirSync } from 'node:fs';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import process from 'node:process';
|
|
4
|
+
import { fetchManifest, manifestUrl } from '@apify/actor-templates';
|
|
5
|
+
import { Args, Flags } from '@oclif/core';
|
|
6
|
+
import { gte, minVersion } from 'semver';
|
|
7
|
+
import { ApifyCommand } from '../lib/apify_command.js';
|
|
8
|
+
import { EMPTY_LOCAL_CONFIG, LOCAL_CONFIG_PATH, PYTHON_VENV_PATH, SUPPORTED_NODEJS_VERSION } from '../lib/consts.js';
|
|
9
|
+
import { enhanceReadmeWithLocalSuffix, ensureValidActorName, getTemplateDefinition } from '../lib/create-utils.js';
|
|
10
|
+
import { execWithLog } from '../lib/exec.js';
|
|
11
|
+
import { updateLocalJson } from '../lib/files.js';
|
|
12
|
+
import { createPrefilledInputFileFromInputSchema } from '../lib/input_schema.js';
|
|
13
|
+
import { error, info, success, warning } from '../lib/outputs.js';
|
|
14
|
+
import { detectNodeVersion, detectNpmVersion, detectPythonVersion, downloadAndUnzip, getJsonFileContent, getNpmCmd, getPythonCommand, isNodeVersionSupported, isPythonVersionSupported, setLocalConfig, setLocalEnv, } from '../lib/utils.js';
|
|
15
|
+
export class CreateCommand extends ApifyCommand {
|
|
16
|
+
async run() {
|
|
17
|
+
let { actorName } = this.args;
|
|
18
|
+
const { template: templateName, skipDependencyInstall, } = this.flags;
|
|
19
|
+
// --template-archive-url is an internal, undocumented flag that's used
|
|
20
|
+
// for testing of templates that are not yet published in the manifest
|
|
21
|
+
let { templateArchiveUrl } = this.flags;
|
|
22
|
+
let skipOptionalDeps = false;
|
|
23
|
+
// Start fetching manifest immediately to prevent
|
|
24
|
+
// annoying delays that sometimes happen on CLI startup.
|
|
25
|
+
const manifestPromise = fetchManifest().catch((err) => {
|
|
26
|
+
return new Error(`Could not fetch template list from server. Cause: ${err?.message}`);
|
|
27
|
+
});
|
|
28
|
+
actorName = await ensureValidActorName(actorName);
|
|
29
|
+
let messages = null;
|
|
30
|
+
this.telemetryData.fromArchiveUrl = !!templateArchiveUrl;
|
|
31
|
+
if (!templateArchiveUrl) {
|
|
32
|
+
const templateDefinition = await getTemplateDefinition(templateName, manifestPromise);
|
|
33
|
+
({ archiveUrl: templateArchiveUrl, messages } = templateDefinition);
|
|
34
|
+
this.telemetryData.templateId = templateDefinition.id;
|
|
35
|
+
this.telemetryData.templateName = templateDefinition.name;
|
|
36
|
+
this.telemetryData.templateLanguage = templateDefinition.category;
|
|
37
|
+
// This "exists"
|
|
38
|
+
if ('skipOptionalDeps' in templateDefinition) {
|
|
39
|
+
skipOptionalDeps = templateDefinition.skipOptionalDeps;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
const cwd = process.cwd();
|
|
43
|
+
const actFolderDir = join(cwd, actorName);
|
|
44
|
+
// Create actor directory structure
|
|
45
|
+
try {
|
|
46
|
+
mkdirSync(actFolderDir);
|
|
47
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
48
|
+
}
|
|
49
|
+
catch (err) {
|
|
50
|
+
if (err?.code === 'EEXIST') {
|
|
51
|
+
error(`Cannot create new Actor, directory '${actorName}' already exists. `
|
|
52
|
+
+ 'You can use "apify init" to create a local Actor environment inside an existing directory.');
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
throw err;
|
|
56
|
+
}
|
|
57
|
+
await downloadAndUnzip({ url: templateArchiveUrl, pathTo: actFolderDir });
|
|
58
|
+
// There may be .actor/actor.json file in used template - let's try to load it and change the name prop value to actorName
|
|
59
|
+
const localConfig = getJsonFileContent(join(actFolderDir, LOCAL_CONFIG_PATH));
|
|
60
|
+
await setLocalConfig(Object.assign(localConfig || EMPTY_LOCAL_CONFIG, { name: actorName }), actFolderDir);
|
|
61
|
+
await setLocalEnv(actFolderDir);
|
|
62
|
+
// Create prefilled INPUT.json file from the input schema prefills
|
|
63
|
+
await createPrefilledInputFileFromInputSchema(actFolderDir);
|
|
64
|
+
const packageJsonPath = join(actFolderDir, 'package.json');
|
|
65
|
+
const requirementsTxtPath = join(actFolderDir, 'requirements.txt');
|
|
66
|
+
const readmePath = join(actFolderDir, 'README.md');
|
|
67
|
+
// Add localReadmeSuffix which is fetched from manifest to README.md
|
|
68
|
+
// The suffix contains local development instructions
|
|
69
|
+
await enhanceReadmeWithLocalSuffix(readmePath, manifestPromise);
|
|
70
|
+
let dependenciesInstalled = false;
|
|
71
|
+
if (!skipDependencyInstall) {
|
|
72
|
+
if (existsSync(packageJsonPath)) {
|
|
73
|
+
const currentNodeVersion = detectNodeVersion();
|
|
74
|
+
const minimumSupportedNodeVersion = minVersion(SUPPORTED_NODEJS_VERSION);
|
|
75
|
+
if (currentNodeVersion) {
|
|
76
|
+
if (!isNodeVersionSupported(currentNodeVersion)) {
|
|
77
|
+
warning(`You are running Node.js version ${currentNodeVersion}, which is no longer supported. `
|
|
78
|
+
+ `Please upgrade to Node.js version ${minimumSupportedNodeVersion} or later.`);
|
|
79
|
+
}
|
|
80
|
+
// If the actor is a Node.js actor (has package.json), run `npm install`
|
|
81
|
+
await updateLocalJson(packageJsonPath, { name: actorName });
|
|
82
|
+
// Run npm install in actor dir.
|
|
83
|
+
// For efficiency, don't install Puppeteer for templates that don't use it
|
|
84
|
+
const cmdArgs = ['install'];
|
|
85
|
+
if (skipOptionalDeps) {
|
|
86
|
+
const currentNpmVersion = detectNpmVersion();
|
|
87
|
+
if (gte(currentNpmVersion, '7.0.0')) {
|
|
88
|
+
cmdArgs.push('--omit=optional');
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
cmdArgs.push('--no-optional');
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
await execWithLog(getNpmCmd(), cmdArgs, { cwd: actFolderDir });
|
|
95
|
+
dependenciesInstalled = true;
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
error(`No Node.js detected! Please install Node.js ${minimumSupportedNodeVersion} or higher`
|
|
99
|
+
+ ' to be able to run Node.js Actors locally.');
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
else if (existsSync(requirementsTxtPath)) {
|
|
103
|
+
const pythonVersion = detectPythonVersion(actFolderDir);
|
|
104
|
+
if (pythonVersion) {
|
|
105
|
+
if (isPythonVersionSupported(pythonVersion)) {
|
|
106
|
+
const venvPath = join(actFolderDir, '.venv');
|
|
107
|
+
info(`Python version ${pythonVersion} detected.`);
|
|
108
|
+
info(`Creating a virtual environment in "${venvPath}" and installing dependencies from "requirements.txt"...`);
|
|
109
|
+
let pythonCommand = getPythonCommand(actFolderDir);
|
|
110
|
+
if (!process.env.VIRTUAL_ENV) {
|
|
111
|
+
// If Python is not running in a virtual environment, create a new one
|
|
112
|
+
await execWithLog(pythonCommand, ['-m', 'venv', '--prompt', '.', PYTHON_VENV_PATH], { cwd: actFolderDir });
|
|
113
|
+
// regenerate the `pythonCommand` after we create the virtual environment
|
|
114
|
+
pythonCommand = getPythonCommand(actFolderDir);
|
|
115
|
+
}
|
|
116
|
+
await execWithLog(pythonCommand, ['-m', 'pip', 'install', '--no-cache-dir', '--no-warn-script-location', '--upgrade', 'pip', 'setuptools', 'wheel'], { cwd: actFolderDir });
|
|
117
|
+
await execWithLog(pythonCommand, ['-m', 'pip', 'install', '--no-cache-dir', '--no-warn-script-location', '-r', 'requirements.txt'], { cwd: actFolderDir });
|
|
118
|
+
dependenciesInstalled = true;
|
|
119
|
+
}
|
|
120
|
+
else {
|
|
121
|
+
warning(`Python Actors require Python 3.8 or higher, but you have Python ${pythonVersion}!`);
|
|
122
|
+
warning('Please install Python 3.8 or higher to be able to run Python Actors locally.');
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
warning('No Python detected! Please install Python 3.8 or higher to be able to run Python Actors locally.');
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
if (dependenciesInstalled) {
|
|
131
|
+
success(`Actor '${actorName}' was created. To run it, run "cd ${actorName}" and "apify run".`);
|
|
132
|
+
success('To run your code in the cloud, run "apify push" and deploy your code to Apify Console.');
|
|
133
|
+
if (messages?.postCreate) {
|
|
134
|
+
info(messages?.postCreate);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
else {
|
|
138
|
+
success(`Actor '${actorName}' was created. Please install its dependencies to be able to run it using "apify run".`);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
Object.defineProperty(CreateCommand, "description", {
|
|
143
|
+
enumerable: true,
|
|
144
|
+
configurable: true,
|
|
145
|
+
writable: true,
|
|
146
|
+
value: 'Creates a new Actor project directory from a selected boilerplate template.'
|
|
147
|
+
});
|
|
148
|
+
Object.defineProperty(CreateCommand, "flags", {
|
|
149
|
+
enumerable: true,
|
|
150
|
+
configurable: true,
|
|
151
|
+
writable: true,
|
|
152
|
+
value: {
|
|
153
|
+
template: Flags.string({
|
|
154
|
+
char: 't',
|
|
155
|
+
description: 'Template for the Actor. If not provided, the command will prompt for it.\n'
|
|
156
|
+
+ `Visit ${manifestUrl} to find available template names.`,
|
|
157
|
+
required: false,
|
|
158
|
+
}),
|
|
159
|
+
'skip-dependency-install': Flags.boolean({
|
|
160
|
+
description: 'Skip installing Actor dependencies.',
|
|
161
|
+
required: false,
|
|
162
|
+
}),
|
|
163
|
+
'template-archive-url': Flags.string({
|
|
164
|
+
description: 'Actor template archive url. Useful for developing new templates.',
|
|
165
|
+
required: false,
|
|
166
|
+
hidden: true,
|
|
167
|
+
}),
|
|
168
|
+
}
|
|
169
|
+
});
|
|
170
|
+
Object.defineProperty(CreateCommand, "args", {
|
|
171
|
+
enumerable: true,
|
|
172
|
+
configurable: true,
|
|
173
|
+
writable: true,
|
|
174
|
+
value: {
|
|
175
|
+
actorName: Args.string({
|
|
176
|
+
required: false,
|
|
177
|
+
description: 'Name of the Actor and its directory',
|
|
178
|
+
}),
|
|
179
|
+
}
|
|
180
|
+
});
|
|
181
|
+
//# sourceMappingURL=create.js.map
|