@asterai/cli 0.1.0 → 0.1.1

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 CHANGED
@@ -20,7 +20,7 @@ $ npm install -g @asterai/cli
20
20
  $ asterai COMMAND
21
21
  running command...
22
22
  $ asterai (--version)
23
- @asterai/cli/0.1.0 linux-x64 node-v20.12.2
23
+ @asterai/cli/0.1.1 linux-x64 node-v20.12.2
24
24
  $ asterai --help [COMMAND]
25
25
  USAGE
26
26
  $ asterai COMMAND
@@ -53,7 +53,7 @@ EXAMPLES
53
53
  $ asterai auth
54
54
  ```
55
55
 
56
- _See code: [src/commands/auth.ts](https://github.com/asterai-io/asterai-sdk/blob/v0.1.0/src/commands/auth.ts)_
56
+ _See code: [src/commands/auth.ts](https://github.com/asterai-io/asterai-sdk/blob/v0.1.1/src/commands/auth.ts)_
57
57
 
58
58
  ## `asterai build [INPUT]`
59
59
 
@@ -73,7 +73,7 @@ EXAMPLES
73
73
  $ asterai build
74
74
  ```
75
75
 
76
- _See code: [src/commands/build.ts](https://github.com/asterai-io/asterai-sdk/blob/v0.1.0/src/commands/build.ts)_
76
+ _See code: [src/commands/build.ts](https://github.com/asterai-io/asterai-sdk/blob/v0.1.1/src/commands/build.ts)_
77
77
 
78
78
  ## `asterai codegen`
79
79
 
@@ -94,7 +94,7 @@ EXAMPLES
94
94
  $ asterai codegen
95
95
  ```
96
96
 
97
- _See code: [src/commands/codegen.ts](https://github.com/asterai-io/asterai-sdk/blob/v0.1.0/src/commands/codegen.ts)_
97
+ _See code: [src/commands/codegen.ts](https://github.com/asterai-io/asterai-sdk/blob/v0.1.1/src/commands/codegen.ts)_
98
98
 
99
99
  ## `asterai deploy [INPUT]`
100
100
 
@@ -102,12 +102,13 @@ compiles and uploads the plugin to asterai
102
102
 
103
103
  ```
104
104
  USAGE
105
- $ asterai deploy [INPUT] -a <value> [-m <value>] [-e <value>]
105
+ $ asterai deploy [INPUT] -a <value> [-m <value>] [-e <value>] [-s]
106
106
 
107
107
  FLAGS
108
108
  -a, --app=<value> (required) app ID to immediately configure this plugin with
109
109
  -e, --endpoint=<value> [default: https://api.asterai.io/app/plugin]
110
110
  -m, --manifest=<value> [default: plugin.asterai.yaml] manifest path
111
+ -s, --staging
111
112
 
112
113
  DESCRIPTION
113
114
  compiles and uploads the plugin to asterai
@@ -116,7 +117,7 @@ EXAMPLES
116
117
  $ asterai deploy --app 66a46b12-b1a7-4b72-a64a-0e4fe21902b6
117
118
  ```
118
119
 
119
- _See code: [src/commands/deploy.ts](https://github.com/asterai-io/asterai-sdk/blob/v0.1.0/src/commands/deploy.ts)_
120
+ _See code: [src/commands/deploy.ts](https://github.com/asterai-io/asterai-sdk/blob/v0.1.1/src/commands/deploy.ts)_
120
121
 
121
122
  ## `asterai help [COMMAND]`
122
123
 
@@ -153,5 +154,5 @@ EXAMPLES
153
154
  $ asterai init project-name
154
155
  ```
155
156
 
156
- _See code: [src/commands/init.ts](https://github.com/asterai-io/asterai-sdk/blob/v0.1.0/src/commands/init.ts)_
157
+ _See code: [src/commands/init.ts](https://github.com/asterai-io/asterai-sdk/blob/v0.1.1/src/commands/init.ts)_
157
158
  <!-- commandsstop -->
@@ -9,6 +9,7 @@ export default class Deploy extends Command {
9
9
  app: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
10
10
  manifest: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
11
11
  endpoint: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
12
+ staging: import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
12
13
  };
13
14
  run(): Promise<void>;
14
15
  }
@@ -5,6 +5,8 @@ import { compile } from "../compile.js";
5
5
  import FormData from "form-data";
6
6
  import axios from "axios";
7
7
  import { getConfigValue } from "../config.js";
8
+ const PRODUCTION_ENDPOINT = "https://api.asterai.io/app/plugin";
9
+ const STAGING_ENDPOINT = "https://staging.api.asterai.io/app/plugin";
8
10
  export default class Deploy extends Command {
9
11
  static args = {
10
12
  input: Args.string({
@@ -28,7 +30,10 @@ export default class Deploy extends Command {
28
30
  }),
29
31
  endpoint: Flags.string({
30
32
  char: "e",
31
- default: "https://api.asterai.io/app/plugin",
33
+ default: PRODUCTION_ENDPOINT,
34
+ }),
35
+ staging: Flags.boolean({
36
+ char: "s",
32
37
  }),
33
38
  };
34
39
  async run() {
@@ -55,16 +60,23 @@ export default class Deploy extends Command {
55
60
  await compile(options);
56
61
  const form = new FormData();
57
62
  form.append("app_id", flags.app);
58
- form.append("module", fs.createReadStream(outputFile));
59
- form.append("manifest", fs.createReadStream(manifestPath));
63
+ form.append("module", fs.readFileSync(outputFile));
64
+ form.append("manifest", fs.readFileSync(manifestPath));
65
+ const url = flags.staging ? STAGING_ENDPOINT : flags.endpoint;
60
66
  await axios({
61
- url: flags.endpoint,
67
+ url,
62
68
  method: "put",
63
69
  data: form,
64
70
  headers: {
65
71
  Authorization: getConfigValue("key"),
72
+ ...form.getHeaders(),
66
73
  },
67
- });
68
- console.log("done");
74
+ })
75
+ .then(() => console.log("done"))
76
+ .catch(logRequestError);
69
77
  }
70
78
  }
79
+ const logRequestError = (e) => {
80
+ const info = e.response?.data ?? e;
81
+ console.log("request error:", info);
82
+ };
@@ -146,6 +146,12 @@
146
146
  "hasDynamicHelp": false,
147
147
  "multiple": false,
148
148
  "type": "option"
149
+ },
150
+ "staging": {
151
+ "char": "s",
152
+ "name": "staging",
153
+ "allowNo": false,
154
+ "type": "boolean"
149
155
  }
150
156
  },
151
157
  "hasDynamicHelp": false,
@@ -192,5 +198,5 @@
192
198
  ]
193
199
  }
194
200
  },
195
- "version": "0.1.0"
201
+ "version": "0.1.1"
196
202
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@asterai/cli",
3
3
  "description": "CLI for building and deploying AsterAI plugins",
4
- "version": "0.1.0",
4
+ "version": "0.1.1",
5
5
  "author": "asterai <support@asterai.io>",
6
6
  "repository": "asterai-io/asterai-sdk",
7
7
  "homepage": "https://github.com/asterai-io/asterai-sdk",