@coze/cli 0.0.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/LICENSE.md ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 Spring (SG) Pte. Ltd.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,40 @@
1
+ # coze-cli
2
+
3
+ > command-line tool for coze component development
4
+
5
+ **Currently, it only supports the `cn` region.**
6
+
7
+ # Installation
8
+
9
+ ```bash
10
+ npm install -g @coze/cli
11
+ ```
12
+
13
+
14
+ # Usage
15
+
16
+ ## Login
17
+
18
+ The `login` command will open a browser page for you to authorize. After authorization, you can use other commands.
19
+
20
+ ```bash
21
+ coze login
22
+ ```
23
+
24
+ The command will save the token and related registry info to `~/.npmrc` automatically. You can check it in the file.
25
+
26
+ ## Logout
27
+
28
+ The `logout` command will clear the login status.
29
+
30
+ ```bash
31
+ coze logout
32
+ ```
33
+
34
+ ## Install
35
+
36
+ you can install the component by `npm`, `pnpm` or `yarn` directly.
37
+
38
+ ```bash
39
+ npm install @coze-kit/xxx
40
+ ```
package/bin.mjs ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ import './dist/cli.mjs';
package/dist/cli.d.ts ADDED
@@ -0,0 +1 @@
1
+ export {};
package/dist/cli.js ADDED
@@ -0,0 +1,36 @@
1
+ import { Command } from 'commander';
2
+ import { OauthClient } from './oauth';
3
+ import { NpmConfig } from './npm';
4
+ import { logoutSpec } from './commands/logout';
5
+ import { loginSpec } from './commands/login';
6
+ import { addCommand } from './commands/base';
7
+ const program = new Command();
8
+ program
9
+ .name('coze')
10
+ .version(process.env.PACKAGE_VERSION)
11
+ .description('A command-line tool for component development');
12
+ let DEV_COMMANDS = [];
13
+ if (import.meta.env.PUBLIC_INHOUSE) {
14
+ const uiCommands = await import('./commands/ui');
15
+ DEV_COMMANDS = [uiCommands.uiSpec];
16
+ }
17
+ [loginSpec, logoutSpec, ...DEV_COMMANDS].forEach(spec => {
18
+ const runAuth = async () => {
19
+ // refresh token
20
+ const npmConfig = new NpmConfig();
21
+ const { region, registryUrl, scope } = await npmConfig.loadConfig();
22
+ const oauthClient = new OauthClient(region);
23
+ await oauthClient.activate(npmConfig);
24
+ // add env
25
+ process.env.REGION = region;
26
+ process.env.REGISTRY = registryUrl;
27
+ process.env.SCOPE = scope;
28
+ };
29
+ addCommand({
30
+ spec,
31
+ program,
32
+ runAuth,
33
+ });
34
+ });
35
+ program.parse(process.argv);
36
+ //# sourceMappingURL=cli.js.map