esa-cli 0.0.2-beta.13 → 0.0.2-beta.15

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.
@@ -2,10 +2,12 @@
2
2
  "react": {
3
3
  "label": "React",
4
4
  "command": "npm create vite@latest",
5
- "templates": {
5
+ "useGit": true,
6
+ "language": {
6
7
  "typescript": "-- --template react-ts",
7
8
  "javascript": "-- --template react"
8
9
  },
10
+ "interactive": false,
9
11
  "assets": {
10
12
  "directory": "./dist",
11
13
  "notFoundStrategy": "singlePageApplication"
@@ -14,10 +16,12 @@
14
16
  "vue": {
15
17
  "label": "Vue",
16
18
  "command": "npm create vite@latest",
17
- "templates": {
19
+ "useGit": true,
20
+ "language": {
18
21
  "typescript": "-- --template vue-ts -- --use-npm",
19
22
  "javascript": "-- --template vue"
20
23
  },
24
+ "interactive": false,
21
25
  "assets": {
22
26
  "directory": "./dist",
23
27
  "notFoundStrategy": "singlePageApplication"
@@ -25,10 +29,56 @@
25
29
  },
26
30
  "nextjs": {
27
31
  "label": "Next.js",
32
+ "useGit": false,
28
33
  "command": "npx create-next-app@latest",
34
+ "hint": "Only support static export",
29
35
  "assets": {
30
- "directory": "./out",
31
- "notFoundStrategy": "singlePageApplication"
36
+ "directory": "./out"
37
+ },
38
+ "fileEdits": [
39
+ {
40
+ "match": "next.config.ts",
41
+ "matchType": "exact",
42
+ "action": "overwrite",
43
+ "fromFile": "snippets/nextjs/next.config.ts",
44
+ "createIfMissing": true
45
+ },
46
+ {
47
+ "match": "next.config.mjs",
48
+ "matchType": "exact",
49
+ "action": "overwrite",
50
+ "fromFile": "snippets/nextjs/next.config.mjs",
51
+ "createIfMissing": true
52
+ }
53
+ ]
54
+ },
55
+ "astro": {
56
+ "label": "Astro",
57
+ "useGit": false,
58
+ "command": "npm create-astro@4.13.1",
59
+ "params": "--no-install",
60
+ "assets": {
61
+ "directory": "./dist"
32
62
  }
63
+ },
64
+ "react-router": {
65
+ "label": "React Router",
66
+ "useGit": false,
67
+ "command": "npx create-react-router",
68
+ "hint": "SPA mode",
69
+ "interactive": true,
70
+ "assets": {
71
+ "directory": "./build/client",
72
+ "notFoundStrategy": "singlePageApplication"
73
+ },
74
+ "fileEdits": [
75
+ {
76
+ "match": "react-router.config.ts",
77
+ "matchType": "exact",
78
+ "action": "overwrite",
79
+ "fromFile": "snippets/react-router/react-router.config.ts",
80
+ "createIfMissing": true
81
+ }
82
+ ]
33
83
  }
34
84
  }
@@ -0,0 +1 @@
1
+ export {};
@@ -7,8 +7,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
8
  });
9
9
  };
10
+ import { isCancel, select as clackSelect, text as clackText } from '@clack/prompts';
10
11
  import chalk from 'chalk';
11
- import inquirer from 'inquirer';
12
12
  import t from '../../i18n/index.js';
13
13
  import { ApiService } from '../../libs/apiService.js';
14
14
  import logger from '../../libs/logger.js';
@@ -60,18 +60,17 @@ export function handleLogin(argv) {
60
60
  const loginStatus = yield service.checkLogin();
61
61
  if (loginStatus.success) {
62
62
  logger.warn(t('login_already').d('You are already logged in.'));
63
- const action = yield inquirer.prompt([
64
- {
65
- type: 'list',
66
- name: 'action',
67
- message: t('login_existing_credentials_message').d('Existing credentials found. What do you want to do?'),
68
- choices: [
69
- t('login_existing_credentials_action_overwrite').d('Overwrite existing credentials'),
70
- t('common_exit').d('Exit')
71
- ]
72
- }
73
- ]);
74
- if (action.action === t('common_exit').d('Exit')) {
63
+ const selected = (yield clackSelect({
64
+ message: t('login_existing_credentials_message').d('Existing credentials found. What do you want to do?'),
65
+ options: [
66
+ {
67
+ label: t('login_existing_credentials_action_overwrite').d('Overwrite existing credentials'),
68
+ value: 'overwrite'
69
+ },
70
+ { label: t('common_exit').d('Exit'), value: 'exit' }
71
+ ]
72
+ }));
73
+ if (isCancel(selected) || selected === 'exit') {
75
74
  return;
76
75
  }
77
76
  yield getUserInputAuthInfo();
@@ -119,23 +118,14 @@ export function getUserInputAuthInfo() {
119
118
  const styledUrl = chalk.underline.blue('https://ram.console.aliyun.com/manage/ak');
120
119
  logger.log(`🔑 ${chalk.underline(t('login_get_ak_sk').d(`Please go to the following link to get your account's AccessKey ID and AccessKey Secret`))}`);
121
120
  logger.log(`👉 ${styledUrl}`);
122
- const answers = yield inquirer.prompt([
123
- {
124
- type: 'input',
125
- name: 'accessKeyId',
126
- message: 'AccessKey ID:'
127
- },
128
- {
129
- type: 'password',
130
- name: 'accessKeySecret',
131
- message: 'AccessKey Secret:',
132
- mask: '*'
133
- }
134
- ]);
121
+ const accessKeyId = (yield clackText({ message: 'AccessKey ID:' }));
122
+ const accessKeySecret = (yield clackText({
123
+ message: 'AccessKey Secret:'
124
+ }));
135
125
  let apiConfig = getApiConfig();
136
126
  apiConfig.auth = {
137
- accessKeyId: answers.accessKeyId,
138
- accessKeySecret: answers.accessKeySecret
127
+ accessKeyId,
128
+ accessKeySecret
139
129
  };
140
130
  try {
141
131
  yield updateCliConfigFile({
@@ -17,7 +17,7 @@ import { isInstalledGit } from '../libs/git/index.js';
17
17
  import logger from '../libs/logger.js';
18
18
  import { getRoot } from '../utils/fileUtils/base.js';
19
19
  import { getCliConfig, projectConfigPath } from '../utils/fileUtils/index.js';
20
- import { getRoutineDetails } from './common/routineUtils.js';
20
+ import { getRoutineDetails } from './common/utils.js';
21
21
  export const checkDirectory = (isCheckGit = false) => {
22
22
  const root = getRoot();
23
23
  if (fs.existsSync(projectConfigPath)) {
@@ -7,7 +7,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
8
  });
9
9
  };
10
- import inquirer from 'inquirer';
10
+ import { isCancel, select as clackSelect } from '@clack/prompts';
11
11
  import logger from '../libs/logger.js';
12
12
  /**
13
13
  * Perform multi-level selection and return the final selected template path
@@ -21,36 +21,34 @@ export default function multiLevelSelect(items_1) {
21
21
  const stack = []; // Stack to store previous level options for back navigation
22
22
  let selectedPath = null;
23
23
  while (selectedPath === null) {
24
- const { choice } = yield inquirer.prompt([
25
- {
26
- type: 'list',
27
- name: 'choice',
28
- message,
29
- pageSize: 10,
30
- choices: [
31
- ...currentItems.map((item) => ({ name: item.label, value: item })),
32
- ...(stack.length > 0 ? [{ name: 'Back', value: 'back' }] : []), // Show "Back" if there’s a previous level
33
- { name: 'Exit', value: 'exit' }
34
- ]
35
- }
36
- ]);
37
- if (choice === 'exit') {
24
+ const choice = (yield clackSelect({
25
+ message,
26
+ options: [
27
+ ...currentItems.map((item) => ({
28
+ label: item.label,
29
+ value: item.value
30
+ })),
31
+ ...(stack.length > 0 ? [{ label: 'Back', value: '__back__' }] : [])
32
+ ]
33
+ }));
34
+ if (isCancel(choice)) {
38
35
  logger.log('User canceled the operation.');
39
36
  return null;
40
37
  }
41
- if (choice === 'back') {
38
+ if (choice === '__back__') {
42
39
  currentItems = stack.pop(); // Return to the previous level
43
40
  continue;
44
41
  }
45
42
  // If a category with children is selected
46
- if (choice.children && choice.children.length > 0) {
43
+ const selected = currentItems.find((i) => i.value === choice);
44
+ if (selected && selected.children && selected.children.length > 0) {
47
45
  stack.push(currentItems); // Save the current level
48
- currentItems = choice.children; // Move to the next level
49
- message = `Select a template under ${choice.label}:`;
46
+ currentItems = selected.children; // Move to the next level
47
+ message = `Select a template under ${selected.label}:`;
50
48
  }
51
49
  else {
52
50
  // A leaf node (no children) is selected, end the selection
53
- selectedPath = choice.value;
51
+ selectedPath = choice;
54
52
  }
55
53
  }
56
54
  return selectedPath;
@@ -1,234 +1,202 @@
1
- # Commands
1
+ ## Commands
2
2
 
3
- ### init
3
+ ### esa init [name]
4
4
 
5
- Initialize a project using a framework or a template.
5
+ Initialize a routine with a template or a framework.
6
6
 
7
7
  ```bash
8
- $ esa init [OPTIONS]
8
+ esa init [name]
9
9
  ```
10
10
 
11
- - -f, --framework `string` `optional`
12
- - Choose a frontend framework: `react` | `vue` | `next`.
11
+ - Positionals:
12
+ - name: Project name
13
13
 
14
- - -t, --template `string` `optional`
15
- - Use an ESA template by name.
14
+ - Options:
15
+ - -f, --framework string: Choose a frontend framework (react/vue/nextjs...)
16
+ - -l, --language string: Choose programming language (typescript/javascript). Choices: typescript | javascript
17
+ - -t, --template string: Template name to use
18
+ - -y, --yes boolean: Answer "Yes" to all prompts (default: false)
19
+ - --git boolean: Initialize git repository
20
+ - --deploy boolean: Deploy after initialization
16
21
 
17
- - -c, --config `boolean` `optional`
18
- - Generate an `esa.toml` config file in your project.
22
+ ---
19
23
 
20
- Notes:
21
- - If neither `--framework` nor `--template` is provided and `--yes` is not used, you will be prompted to choose between “Framework” or “Template”.
22
- - When a framework is chosen, the official scaffolding tool will be used to create the project, and `esa.toml` will be auto-generated in the project root. The entry file is auto-detected among: `src/index.js`, `src/index.jsx`, `src/index.tsx`, `src/main.js`, `src/main.ts`, `src/main.tsx`, `pages/index.js`, `pages/index.tsx`, `app/page.js`, `app/page.tsx`. The static assets directory is set to the framework’s common build output if available: CRA `build/`, Vite usually `dist/`, Next static export `out/`.
24
+ ### esa dev [entry]
23
25
 
24
- ### routine [script]
25
-
26
- Manage your routine.
27
-
28
- #### delete <routineName>
29
-
30
- Delete a routine.
26
+ Start a local server for developing your routine.
31
27
 
32
28
  ```bash
33
- $ esa routine delete <routineName>
29
+ esa dev [entry]
34
30
  ```
35
31
 
36
- - routineName `string` `required`
37
- - The name of the routine to delete.
32
+ - Positionals:
33
+ - entry: Entry file of the Routine
38
34
 
39
- #### list
35
+ - Options:
36
+ - -p, --port number: Port to listen on
37
+ - -m, --minify boolean: Minify code during development (default: false)
38
+ - --refresh-command string: Command to run before auto-refresh on save
39
+ - --local-upstream string: Host to act as origin in development
40
+ - --debug boolean: Output debug logs (default: false)
40
41
 
41
- List all your routines.
42
+ ---
42
43
 
43
- ```bash
44
- $ esa routine list
45
- ```
44
+ ### esa commit [entry]
46
45
 
47
- ### route [script]
48
-
49
- Manage the routes bound to your routine.
50
-
51
- #### add [route] [site]
52
-
53
- Bind a Route to a routine.
46
+ Commit your code and save as a new version.
54
47
 
55
48
  ```bash
56
- $ esa route add [route] [site]
49
+ esa commit [entry]
57
50
  ```
58
51
 
59
- #### delete <route>
60
-
61
- Delete a related route.
62
-
63
- ```bash
64
- $ esa route delete <route>
65
- ```
52
+ - Options:
53
+ - -m, --minify boolean: Minify code before committing (default: false)
54
+ - -a, --assets string: Assets directory
55
+ - -d, --description string: Description for the routine/version (skip interactive input)
56
+ - -n, --name string: Edge Routine name
66
57
 
67
- - route `string` `required`
68
- - The name of the routes to delete.
58
+ ---
69
59
 
70
- #### list
60
+ ### esa deploy [entry]
71
61
 
72
- List all related routes.
62
+ Deploy your project.
73
63
 
74
64
  ```bash
75
- $ esa route list
65
+ esa deploy [entry]
76
66
  ```
77
67
 
78
- ### login
68
+ - Positionals:
69
+ - entry: Entry file of the Routine
79
70
 
80
- Login to the server.
71
+ - Options:
72
+ - -v, --version string: Version to deploy (skip interactive selection)
73
+ - -e, --environment string: Environment to deploy to. Choices: staging | production
74
+ - -n, --name string: Name of the routine
75
+ - -a, --assets boolean: Deploy assets
76
+ - -d, --description string: Description of the version
77
+ - -m, --minify boolean: Minify the code
81
78
 
82
- ```bash
83
- $ esa login
84
- ```
79
+ ---
85
80
 
86
- ### dev [entry]
81
+ ### esa deployments [list | delete]
87
82
 
88
- Start a local server for developing your routine.
83
+ Manage your deployments.
89
84
 
90
85
  ```bash
91
- $ esa dev [entry] [OPTIONS]
86
+ esa deployments list
87
+ esa deployments delete [deploymentId...]
92
88
  ```
93
89
 
94
- - entry `string` `optional`
95
- - Entry file of the Routine.
96
-
97
- - -port, --p `number` `optional`
98
- - Port to listen on.
99
-
100
- - --inspect-port `number` `optional`
101
- - Chrome inspect devTool port.
102
-
103
- - -minify, --m `boolean` `optional`
104
- - Minify code during development.
105
-
106
- - --local-upstream `string` `optional`
107
- - Host to act as origin in development.
108
-
109
- - --refresh-command `string` `optional`
110
- - Provide a command to be executed before the auto-refresh on save.
111
-
112
- ### deployments [script]
90
+ - Subcommands:
91
+ - list: List all deployments
92
+ - delete [deploymentId...]: Delete one or more deployment versions
113
93
 
114
- Manage your deployments.
94
+ ---
115
95
 
116
- #### delete <deploymentId>
96
+ ### esa routine [list | delete]
117
97
 
118
- Delete one or more deployment versions.
98
+ Manage your routines.
119
99
 
120
100
  ```bash
121
- $ esa deployments delete <deploymentId>
101
+ esa routine list
102
+ esa routine delete <routineName>
122
103
  ```
123
104
 
124
- - deploymentId `string` `required`
125
- - The ID of the deployments to delete.
126
-
127
- #### list
105
+ - Subcommands:
106
+ - list: List all your routines
107
+ - delete <routineName>: Delete a routine
128
108
 
129
- List all deployments.
109
+ ---
130
110
 
131
- ```bash
132
- $ esa deployments list
133
- ```
111
+ ### esa site [list]
134
112
 
135
- ### deploy [entry]
136
-
137
- Deploy your project.
113
+ Manage your sites.
138
114
 
139
115
  ```bash
140
- $ esa deploy [entry]
116
+ esa site list
141
117
  ```
142
118
 
143
- - entry `string` `optional`
144
- - Entry file of the Routine.
119
+ - Subcommands:
120
+ - list: List all your sites
145
121
 
146
- ### domain [script]
122
+ ---
147
123
 
148
- Manage the domain names bound to your routine.
149
-
150
- #### add <domain>
124
+ ### esa domain <add | list | delete>
151
125
 
152
- Bind a domain to a routine.
126
+ Manage the domain names bound to your routine.
153
127
 
154
128
  ```bash
155
- $ esa domain add <domain>
129
+ esa domain add <domain>
130
+ esa domain list
131
+ esa domain delete <domain>
156
132
  ```
157
133
 
158
- - domain `string` `required`
159
- - The name of domain to add.
134
+ - Subcommands:
135
+ - add <domain>: Bind a domain to a routine
136
+ - list: List all related domains
137
+ - delete <domain>: Delete a related domain
160
138
 
161
- #### delete <domain>
139
+ ---
162
140
 
163
- Delete a related domain.
141
+ ### esa route <add | list | delete>
142
+
143
+ Manage the routes bound to your routine.
164
144
 
165
145
  ```bash
166
- $ esa domain delete <domain>
146
+ esa route add
147
+ esa route list
148
+ esa route delete <routeName>
167
149
  ```
168
150
 
169
- - domains `string` `required`
170
- - The names of the related domains to delete.
171
-
172
- #### list
151
+ - Subcommands:
152
+ - add: Bind a Route to a routine
153
+ - list: List all related routes
154
+ - delete <routeName>: Delete a related route
173
155
 
174
- List all related domains.
156
+ ---
175
157
 
176
- ```bash
177
- $ esa domain list
178
- ```
158
+ ### esa login
179
159
 
180
- ### commit [entry]
181
-
182
- Commit your code, save as a new version.
160
+ Login to the server.
183
161
 
184
162
  ```bash
185
- $ esa commit [entry] [OPTIONS]
163
+ esa login
186
164
  ```
187
165
 
188
- - entry `string` `optional`
189
- - Entry file of the Routine.
166
+ - Options:
167
+ - --access-key-id, --ak string: AccessKey ID (AK)
168
+ - --access-key-secret, --sk string: AccessKey Secret (SK)
190
169
 
191
- - -m, --minify `boolean` `optional`
192
- - Minify code before committing.
170
+ ---
193
171
 
194
- ### logout
172
+ ### esa logout
195
173
 
196
174
  Logout.
197
175
 
198
176
  ```bash
199
- $ esa logout
177
+ esa logout
200
178
  ```
201
179
 
202
- ### config
180
+ ---
203
181
 
204
- Modify your local or global configuration using -l, -g.
205
-
206
- ```bash
207
- $ esa config [OPTIONS]
208
- ```
182
+ ### esa config [-l | -g]
209
183
 
210
- - -g, --global `boolean` `optional`
211
- - Edit global config file.
212
-
213
- - -l, --local `boolean` `optional`
214
- - Edit local config file.
215
-
216
- ### lang
217
-
218
- Set the language of the CLI.
184
+ Modify your local or global configuration.
219
185
 
220
186
  ```bash
221
- $ esa lang
187
+ esa config [--local] [--global]
222
188
  ```
223
189
 
224
- ### site [script]
190
+ - Options:
191
+ - -l, --local boolean: Edit local config file (default: false)
192
+ - -g, --global boolean: Edit global config file (default: false)
225
193
 
226
- Manage your sites.
194
+ ---
227
195
 
228
- #### list
196
+ ### esa lang
229
197
 
230
- List all your sites.
198
+ Set the language of the CLI.
231
199
 
232
200
  ```bash
233
- $ esa site list
201
+ esa lang
234
202
  ```