@asterai/cli 0.1.0 → 0.1.2
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 +8 -7
- package/asterai-init-plugin/package.json +20 -0
- package/asterai-init-plugin/plugin.asterai.yaml +9 -0
- package/asterai-init-plugin/plugin.ts +7 -0
- package/bin/dev.js +0 -0
- package/dist/commands/codegen.js +4 -1
- package/dist/commands/deploy.d.ts +1 -0
- package/dist/commands/deploy.js +18 -6
- package/oclif.manifest.json +7 -1
- package/package.json +13 -15
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.
|
|
23
|
+
@asterai/cli/0.1.2 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.
|
|
56
|
+
_See code: [src/commands/auth.ts](https://github.com/asterai-io/asterai-sdk/blob/v0.1.2/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.
|
|
76
|
+
_See code: [src/commands/build.ts](https://github.com/asterai-io/asterai-sdk/blob/v0.1.2/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.
|
|
97
|
+
_See code: [src/commands/codegen.ts](https://github.com/asterai-io/asterai-sdk/blob/v0.1.2/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.
|
|
120
|
+
_See code: [src/commands/deploy.ts](https://github.com/asterai-io/asterai-sdk/blob/v0.1.2/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.
|
|
157
|
+
_See code: [src/commands/init.ts](https://github.com/asterai-io/asterai-sdk/blob/v0.1.2/src/commands/init.ts)_
|
|
157
158
|
<!-- commandsstop -->
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "plugin",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "",
|
|
5
|
+
"author": "asterai",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"auth": "asterai auth",
|
|
9
|
+
"codegen": "asterai codegen",
|
|
10
|
+
"build": "asterai build",
|
|
11
|
+
"deploy": "asterai deploy"
|
|
12
|
+
},
|
|
13
|
+
"type": "module",
|
|
14
|
+
"devDependencies": {
|
|
15
|
+
"@asterai/sdk": "0.1.0"
|
|
16
|
+
},
|
|
17
|
+
"peerDependencies": {
|
|
18
|
+
"assemblyscript": "0.27.27"
|
|
19
|
+
}
|
|
20
|
+
}
|
package/bin/dev.js
CHANGED
|
File without changes
|
package/dist/commands/codegen.js
CHANGED
|
@@ -31,7 +31,7 @@ const ManifestFunctionSchema = z.object({
|
|
|
31
31
|
});
|
|
32
32
|
const ManifestSchema = z.object({
|
|
33
33
|
name: z.string(),
|
|
34
|
-
functions: z.array(ManifestFunctionSchema),
|
|
34
|
+
functions: z.array(ManifestFunctionSchema).optional(),
|
|
35
35
|
});
|
|
36
36
|
export default class Codegen extends Command {
|
|
37
37
|
static args = {};
|
|
@@ -55,6 +55,9 @@ export default class Codegen extends Command {
|
|
|
55
55
|
const baseDir = path.dirname(manifestPath);
|
|
56
56
|
const outDir = path.join(baseDir, flags.outputDir);
|
|
57
57
|
const manifest = ManifestSchema.parse(YAML.parse(fs.readFileSync(manifestPath, "utf8")));
|
|
58
|
+
if (!manifest.functions) {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
58
61
|
if (!fs.existsSync(outDir)) {
|
|
59
62
|
fs.mkdirSync(outDir, { recursive: true });
|
|
60
63
|
}
|
|
@@ -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
|
}
|
package/dist/commands/deploy.js
CHANGED
|
@@ -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:
|
|
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.
|
|
59
|
-
form.append("manifest", fs.
|
|
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
|
|
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
|
-
|
|
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
|
+
};
|
package/oclif.manifest.json
CHANGED
|
@@ -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.
|
|
201
|
+
"version": "0.1.2"
|
|
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.
|
|
4
|
+
"version": "0.1.2",
|
|
5
5
|
"author": "asterai <support@asterai.io>",
|
|
6
6
|
"repository": "asterai-io/asterai-sdk",
|
|
7
7
|
"homepage": "https://github.com/asterai-io/asterai-sdk",
|
|
@@ -13,18 +13,6 @@
|
|
|
13
13
|
"license": "UNLICENSED",
|
|
14
14
|
"main": "dist/index.js",
|
|
15
15
|
"type": "module",
|
|
16
|
-
"scripts": {
|
|
17
|
-
"prepare": "cd .. && husky cli/.husky",
|
|
18
|
-
"build": "shx rm -rf dist && tsc -b",
|
|
19
|
-
"lint": "eslint . --ext .ts",
|
|
20
|
-
"postpack": "shx rm -f oclif.manifest.json",
|
|
21
|
-
"posttest": "pnpm run lint",
|
|
22
|
-
"prepack": "oclif manifest && oclif readme",
|
|
23
|
-
"test": "mocha --forbid-only \"test/**/*.test.ts\"",
|
|
24
|
-
"version": "oclif readme && git add README.md",
|
|
25
|
-
"format": "prettier --write .",
|
|
26
|
-
"format-staged": "pretty-quick --staged"
|
|
27
|
-
},
|
|
28
16
|
"bin": {
|
|
29
17
|
"asterai": "./bin/run.js"
|
|
30
18
|
},
|
|
@@ -35,7 +23,8 @@
|
|
|
35
23
|
"files": [
|
|
36
24
|
"/bin",
|
|
37
25
|
"/dist",
|
|
38
|
-
"/oclif.manifest.json"
|
|
26
|
+
"/oclif.manifest.json",
|
|
27
|
+
"/asterai-init-plugin"
|
|
39
28
|
],
|
|
40
29
|
"oclif": {
|
|
41
30
|
"bin": "asterai",
|
|
@@ -77,5 +66,14 @@
|
|
|
77
66
|
"shx": "^0.3.3",
|
|
78
67
|
"ts-node": "^10",
|
|
79
68
|
"typescript": "^5"
|
|
69
|
+
},
|
|
70
|
+
"scripts": {
|
|
71
|
+
"build": "shx rm -rf dist && tsc -b",
|
|
72
|
+
"lint": "eslint . --ext .ts",
|
|
73
|
+
"posttest": "pnpm run lint",
|
|
74
|
+
"test": "mocha --forbid-only \"test/**/*.test.ts\"",
|
|
75
|
+
"version": "oclif readme && git add README.md",
|
|
76
|
+
"format": "prettier --write .",
|
|
77
|
+
"format-staged": "pretty-quick --staged"
|
|
80
78
|
}
|
|
81
|
-
}
|
|
79
|
+
}
|