esa-cli 0.0.2-beta.21 → 0.0.2-beta.23
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 +31 -149
- package/dist/commands/commit/index.js +7 -2
- package/dist/commands/common/constant.js +4 -4
- package/dist/commands/common/utils.js +89 -89
- package/dist/commands/config.js +1 -1
- package/dist/commands/deploy/index.js +3 -2
- package/dist/commands/deployments/delete.js +2 -2
- package/dist/commands/deployments/index.js +1 -1
- package/dist/commands/dev/ew2/devPack.js +9 -9
- package/dist/commands/dev/ew2/kvService.js +5 -1
- package/dist/commands/dev/ew2/mock/kv.js +1 -1
- package/dist/commands/dev/ew2/server.js +1 -2
- package/dist/commands/dev/index.js +3 -3
- package/dist/commands/dev/mockWorker/devPack.js +3 -3
- package/dist/commands/domain/add.js +2 -2
- package/dist/commands/domain/index.js +2 -2
- package/dist/commands/init/helper.js +7 -9
- package/dist/commands/init/template.jsonc +1 -1
- package/dist/commands/route/add.js +19 -52
- package/dist/commands/route/helper.js +9 -10
- package/dist/commands/route/index.js +2 -2
- package/dist/commands/routine/delete.js +7 -6
- package/dist/commands/routine/index.js +4 -3
- package/dist/commands/routine/list.js +40 -22
- package/dist/commands/site/index.js +1 -1
- package/dist/commands/utils.js +5 -5
- package/dist/components/filterSelector.js +1 -1
- package/dist/components/routeBuilder.js +68 -0
- package/dist/docs/Commands_en.md +110 -74
- package/dist/docs/Commands_zh_CN.md +110 -74
- package/dist/i18n/locales.json +94 -58
- package/dist/index.js +2 -2
- package/dist/libs/apiService.js +7 -6
- package/dist/libs/logger.js +7 -7
- package/dist/utils/checkDevPort.js +2 -2
- package/dist/utils/checkIsRoutineCreated.js +2 -2
- package/dist/utils/compress.js +5 -5
- package/dist/utils/download.js +3 -3
- package/dist/utils/fileUtils/index.js +69 -18
- package/dist/utils/installDeno.js +1 -1
- package/dist/utils/installEw2.js +2 -2
- package/package.json +3 -2
- package/zh_CN.md +28 -154
|
@@ -31,11 +31,11 @@ const EW2OS = [Platforms.AppleArm, Platforms.AppleIntel, Platforms.LinuxX86];
|
|
|
31
31
|
const useEw2 = EW2OS.includes(OS);
|
|
32
32
|
const dev = {
|
|
33
33
|
command: 'dev [entry]',
|
|
34
|
-
describe: `💻 ${t('dev_describe').d('Start a local server for developing your
|
|
34
|
+
describe: `💻 ${t('dev_describe').d('Start a local server for developing your project')}`,
|
|
35
35
|
builder: (yargs) => {
|
|
36
36
|
yargsIns = yargs
|
|
37
37
|
.positional('entry', {
|
|
38
|
-
describe: t('dev_entry_describe').d('Entry file of
|
|
38
|
+
describe: t('dev_entry_describe').d('Entry file of Functions& Pages'),
|
|
39
39
|
type: 'string',
|
|
40
40
|
demandOption: false
|
|
41
41
|
})
|
|
@@ -187,7 +187,7 @@ const dev = {
|
|
|
187
187
|
yield worker.start();
|
|
188
188
|
}
|
|
189
189
|
catch (err) {
|
|
190
|
-
|
|
190
|
+
logger.error(`Worker start failed: ${err}`);
|
|
191
191
|
process.exit(1);
|
|
192
192
|
}
|
|
193
193
|
const ignored = (path) => {
|
|
@@ -40,12 +40,12 @@ const generateEntry = (id, projectEntry, userRoot) => __awaiter(void 0, void 0,
|
|
|
40
40
|
const prepare = (configPath, entry, port, localUpstream, userRoot) => __awaiter(void 0, void 0, void 0, function* () {
|
|
41
41
|
const options = {};
|
|
42
42
|
const currentOptions = { entry, port, localUpstream };
|
|
43
|
-
//
|
|
43
|
+
// Support running multiple deno instances simultaneously
|
|
44
44
|
const id = new Date().getTime().toString();
|
|
45
45
|
// @ts-ignore
|
|
46
46
|
global.id = id;
|
|
47
47
|
yield generateEntry(id, entry, userRoot);
|
|
48
|
-
//
|
|
48
|
+
// Configuration items for each dev session, distinguished by id in one file
|
|
49
49
|
if (fs.existsSync(configPath)) {
|
|
50
50
|
const currentConfig = fs
|
|
51
51
|
.readFileSync(configPath, 'utf-8')
|
|
@@ -101,7 +101,7 @@ const devPack = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
101
101
|
}
|
|
102
102
|
else {
|
|
103
103
|
logger.notInProject();
|
|
104
|
-
process.exit(
|
|
104
|
+
process.exit(1);
|
|
105
105
|
}
|
|
106
106
|
return prepare(path.resolve(userRoot, '.dev/devConfig.js'), projectEntry, port, localUpstream, userRoot)
|
|
107
107
|
.then(() => {
|
|
@@ -14,7 +14,7 @@ import { getProjectConfig } from '../../utils/fileUtils/index.js';
|
|
|
14
14
|
import { bindRoutineWithDomain, checkDirectory, checkIsLoginSuccess, validDomain, validName } from '../utils.js';
|
|
15
15
|
const addDomain = {
|
|
16
16
|
command: 'add <domain>',
|
|
17
|
-
describe: `🔗 ${t('domain_add_describe').d('Bind a domain to
|
|
17
|
+
describe: `🔗 ${t('domain_add_describe').d('Bind a domain to your project')}`,
|
|
18
18
|
builder: (yargs) => {
|
|
19
19
|
return yargs
|
|
20
20
|
.positional('domain', {
|
|
@@ -22,7 +22,7 @@ const addDomain = {
|
|
|
22
22
|
type: 'string',
|
|
23
23
|
demandOption: true
|
|
24
24
|
})
|
|
25
|
-
.usage(`${t('common_usage').d('Usage')}: esa domain add <domain>`)
|
|
25
|
+
.usage(`${t('common_usage').d('Usage')}: esa-cli domain add <domain>`)
|
|
26
26
|
.option('help', {
|
|
27
27
|
alias: 'h',
|
|
28
28
|
describe: t('common_help').d('Help'),
|
|
@@ -5,7 +5,7 @@ import listDomain from './list.js';
|
|
|
5
5
|
let yargsIns;
|
|
6
6
|
const domainCommand = {
|
|
7
7
|
command: 'domain [script]',
|
|
8
|
-
describe: `🔗 ${t('domain_describe').d('Manage the domain names bound to your
|
|
8
|
+
describe: `🔗 ${t('domain_describe').d('Manage the domain names bound to your project')}`,
|
|
9
9
|
builder: (yargs) => {
|
|
10
10
|
yargsIns = yargs;
|
|
11
11
|
return yargs
|
|
@@ -18,7 +18,7 @@ const domainCommand = {
|
|
|
18
18
|
type: 'boolean',
|
|
19
19
|
default: false
|
|
20
20
|
})
|
|
21
|
-
.usage(`${t('common_usage').d('Usage')}: esa domain <add | list | delete>`);
|
|
21
|
+
.usage(`${t('common_usage').d('Usage')}: esa-cli domain <add | list | delete>`);
|
|
22
22
|
},
|
|
23
23
|
handler: (argv) => {
|
|
24
24
|
if (yargsIns && (argv.help || argv._.length < 2)) {
|
|
@@ -100,7 +100,7 @@ export function checkAndUpdatePackage(packageName) {
|
|
|
100
100
|
const spinner = logger.ora;
|
|
101
101
|
spinner.text = t('checking_template_update').d('Checking esa-template updates...');
|
|
102
102
|
spinner.start();
|
|
103
|
-
//
|
|
103
|
+
// Get currently installed version
|
|
104
104
|
const __dirname = getDirName(import.meta.url);
|
|
105
105
|
const packageJsonPath = path.join(__dirname, '../../../');
|
|
106
106
|
let versionInfo;
|
|
@@ -124,7 +124,7 @@ export function checkAndUpdatePackage(packageName) {
|
|
|
124
124
|
}
|
|
125
125
|
const match = versionInfo.match(new RegExp(`(${packageName})@([0-9.]+)`));
|
|
126
126
|
const currentVersion = match ? match[2] : '';
|
|
127
|
-
//
|
|
127
|
+
// Get latest version
|
|
128
128
|
const latestVersion = execSync(`npm view ${packageName} version`, {
|
|
129
129
|
cwd: packageJsonPath
|
|
130
130
|
})
|
|
@@ -173,11 +173,10 @@ export function checkAndUpdatePackage(packageName) {
|
|
|
173
173
|
});
|
|
174
174
|
}
|
|
175
175
|
export const getFrameworkConfig = (framework) => {
|
|
176
|
-
//
|
|
176
|
+
// Read template.jsonc from init directory
|
|
177
177
|
const templatePath = path.join(getDirName(import.meta.url), 'template.jsonc');
|
|
178
178
|
const jsonc = fs.readFileSync(templatePath, 'utf-8');
|
|
179
179
|
const json = JSON.parse(jsonc);
|
|
180
|
-
console.log(json);
|
|
181
180
|
return json[framework];
|
|
182
181
|
};
|
|
183
182
|
/**
|
|
@@ -185,7 +184,7 @@ export const getFrameworkConfig = (framework) => {
|
|
|
185
184
|
* @returns 框架全部配置
|
|
186
185
|
*/
|
|
187
186
|
export const getAllFrameworkConfig = () => {
|
|
188
|
-
//
|
|
187
|
+
// Read template.jsonc from init directory
|
|
189
188
|
const templatePath = path.join(getDirName(import.meta.url), 'template.jsonc');
|
|
190
189
|
const jsonc = fs.readFileSync(templatePath, 'utf-8');
|
|
191
190
|
const json = JSON.parse(jsonc);
|
|
@@ -232,7 +231,7 @@ export function getInitParamsFromArgv(argv) {
|
|
|
232
231
|
params.deploy = Boolean(a.deploy);
|
|
233
232
|
return params;
|
|
234
233
|
}
|
|
235
|
-
//
|
|
234
|
+
// Configure project name
|
|
236
235
|
export const configProjectName = (initParams) => __awaiter(void 0, void 0, void 0, function* () {
|
|
237
236
|
if (initParams.name) {
|
|
238
237
|
log.step(`Project name configured ${initParams.name}`);
|
|
@@ -593,7 +592,7 @@ export const initGit = (initParams) => __awaiter(void 0, void 0, void 0, functio
|
|
|
593
592
|
export function getGitVersion() {
|
|
594
593
|
return __awaiter(this, void 0, void 0, function* () {
|
|
595
594
|
try {
|
|
596
|
-
|
|
595
|
+
let stdout = yield execCommand(['git', '--version'], {
|
|
597
596
|
useSpinner: false,
|
|
598
597
|
silent: true,
|
|
599
598
|
captureOutput: true
|
|
@@ -609,7 +608,7 @@ export function getGitVersion() {
|
|
|
609
608
|
}
|
|
610
609
|
export function isGitInstalled() {
|
|
611
610
|
return __awaiter(this, void 0, void 0, function* () {
|
|
612
|
-
return (yield getGitVersion()) !== null;
|
|
611
|
+
return (yield getGitVersion()) !== '' && (yield getGitVersion()) !== null;
|
|
613
612
|
});
|
|
614
613
|
}
|
|
615
614
|
/**
|
|
@@ -685,7 +684,6 @@ function ensureGitignore(projectRoot, assetsDirectory) {
|
|
|
685
684
|
? `${existingContent.replace(/\n$/, '')}\n${toAppend.join('\n')}\n`
|
|
686
685
|
: `${toAppend.join('\n')}\n`;
|
|
687
686
|
fs.writeFileSync(gitignorePath, newContent, 'utf-8');
|
|
688
|
-
logger.log('Updated .gitignore');
|
|
689
687
|
}
|
|
690
688
|
catch (_a) {
|
|
691
689
|
// Do not fail init due to .gitignore issues
|
|
@@ -14,6 +14,7 @@ import logger from '../../libs/logger.js';
|
|
|
14
14
|
import { validRoutine } from '../../utils/checkIsRoutineCreated.js';
|
|
15
15
|
import { getProjectConfig } from '../../utils/fileUtils/index.js';
|
|
16
16
|
import { checkDirectory, checkIsLoginSuccess } from '../utils.js';
|
|
17
|
+
import { routeBuilder } from '../../components/routeBuilder.js';
|
|
17
18
|
import { transferRouteToRuleString } from './helper.js';
|
|
18
19
|
const addRoute = {
|
|
19
20
|
command: 'add [route] [site]',
|
|
@@ -78,7 +79,6 @@ export function handlerAddRoute(argv) {
|
|
|
78
79
|
name: i.SiteName,
|
|
79
80
|
value: i.SiteId
|
|
80
81
|
}));
|
|
81
|
-
// 获取路由名称,支持直接通过参数传入
|
|
82
82
|
let routeName = argv.alias;
|
|
83
83
|
if (!routeName) {
|
|
84
84
|
const response = yield inquirer.prompt([
|
|
@@ -99,35 +99,18 @@ export function handlerAddRoute(argv) {
|
|
|
99
99
|
let siteName = argv.site;
|
|
100
100
|
let siteId;
|
|
101
101
|
if (!siteName) {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
{
|
|
109
|
-
type: 'list',
|
|
110
|
-
name: 'routeSite',
|
|
111
|
-
message: t('create_route_site').d('Select a site that is active in your account:'),
|
|
112
|
-
choices: siteList
|
|
113
|
-
}
|
|
114
|
-
]);
|
|
115
|
-
siteId = response.routeSite;
|
|
116
|
-
}
|
|
117
|
-
else {
|
|
118
|
-
// 根据站点名称查找对应的站点ID
|
|
119
|
-
const matchedSite = siteList.find((site) => site.name === siteName);
|
|
120
|
-
if (matchedSite) {
|
|
121
|
-
siteId = matchedSite.value;
|
|
122
|
-
}
|
|
123
|
-
else {
|
|
124
|
-
logger.error(t('site_not_found').d(`Site "${siteName}" not found in your account`));
|
|
125
|
-
return;
|
|
102
|
+
const response = yield inquirer.prompt([
|
|
103
|
+
{
|
|
104
|
+
type: 'list',
|
|
105
|
+
name: 'routeSite',
|
|
106
|
+
message: t('create_route_site').d('Select a site that is active in your account:'),
|
|
107
|
+
choices: siteList
|
|
126
108
|
}
|
|
127
|
-
|
|
109
|
+
]);
|
|
110
|
+
siteId = response.routeSite;
|
|
128
111
|
}
|
|
129
112
|
else {
|
|
130
|
-
//
|
|
113
|
+
// Find corresponding site ID by site name
|
|
131
114
|
const matchedSite = siteList.find((site) => site.name === siteName);
|
|
132
115
|
if (matchedSite) {
|
|
133
116
|
siteId = matchedSite.value;
|
|
@@ -137,40 +120,24 @@ export function handlerAddRoute(argv) {
|
|
|
137
120
|
return;
|
|
138
121
|
}
|
|
139
122
|
}
|
|
140
|
-
// 获取路由值,支持直接通过参数传入
|
|
141
123
|
let inputRoute = argv.route;
|
|
142
124
|
if (!inputRoute) {
|
|
143
|
-
//
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
if (!
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
type: 'input',
|
|
152
|
-
name: 'inputRoute',
|
|
153
|
-
message: t('create_route_route').d('Enter a Route (e.g., example.com/*):'),
|
|
154
|
-
validate: (input) => {
|
|
155
|
-
if (!input) {
|
|
156
|
-
return t('route_input_required').d('Route is required');
|
|
157
|
-
}
|
|
158
|
-
if (!input.includes('*') && !input.includes('/')) {
|
|
159
|
-
return t('route_format_invalid').d('Route format is invalid. Please include wildcard (*) or path (/)');
|
|
160
|
-
}
|
|
161
|
-
return true;
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
]);
|
|
165
|
-
inputRoute = response.inputRoute;
|
|
125
|
+
// Get selected site name for route building
|
|
126
|
+
const selectedSite = siteList.find((site) => site.value === siteId);
|
|
127
|
+
const displaySiteName = selectedSite ? selectedSite.name : siteName;
|
|
128
|
+
// Use route builder
|
|
129
|
+
const builtRoute = yield routeBuilder(displaySiteName);
|
|
130
|
+
if (!builtRoute) {
|
|
131
|
+
logger.info(t('route_build_cancelled').d('Route building cancelled'));
|
|
132
|
+
return;
|
|
166
133
|
}
|
|
134
|
+
inputRoute = builtRoute;
|
|
167
135
|
}
|
|
168
136
|
const rule = transferRouteToRuleString(inputRoute);
|
|
169
137
|
if (!rule) {
|
|
170
138
|
logger.error(t('route_format_invalid').d('Invalid route format'));
|
|
171
139
|
return;
|
|
172
140
|
}
|
|
173
|
-
// 获取站点名称用于显示
|
|
174
141
|
const selectedSite = siteList.find((site) => site.value === siteId);
|
|
175
142
|
const displaySiteName = selectedSite ? selectedSite.name : siteName;
|
|
176
143
|
const req = {
|
|
@@ -72,8 +72,7 @@ export const transferRouteToRuleString = (routePath) => {
|
|
|
72
72
|
export const transferRuleStringToRoute = (ruleStr) => {
|
|
73
73
|
if (!ruleStr) {
|
|
74
74
|
return '';
|
|
75
|
-
}
|
|
76
|
-
// 去掉外层括号并按 " and " 分割
|
|
75
|
+
} // Remove outer brackets and split by " and "
|
|
77
76
|
const cleanedRule = ruleStr.replace(/^\(|\)$/g, '');
|
|
78
77
|
const parts = cleanedRule.split(' and ');
|
|
79
78
|
if (parts.length !== 2) {
|
|
@@ -81,36 +80,36 @@ export const transferRuleStringToRoute = (ruleStr) => {
|
|
|
81
80
|
}
|
|
82
81
|
let host = '';
|
|
83
82
|
let uriPath = '';
|
|
84
|
-
//
|
|
83
|
+
// Process host part
|
|
85
84
|
const hostPart = parts[0].trim();
|
|
86
85
|
if (hostPart.startsWith(`${RuleMatchOperatorEndsWith}(${RuleMatchTypeHost},`)) {
|
|
87
|
-
// host
|
|
86
|
+
// Logic when host matches eq
|
|
88
87
|
// ends_with(http.host, "value")
|
|
89
88
|
const match = hostPart.match(/ends_with\(http\.host,\s*"([^"]+)"\)/);
|
|
90
89
|
if (match) {
|
|
91
|
-
host = `*${match[1]}`; //
|
|
90
|
+
host = `*${match[1]}`; // Add prefix *
|
|
92
91
|
}
|
|
93
92
|
}
|
|
94
93
|
else if (hostPart.startsWith(`${RuleMatchTypeHost} ${RuleMatchOperatorEq}`)) {
|
|
95
|
-
// host
|
|
94
|
+
// Logic when host matches eq
|
|
96
95
|
// http.host eq "value"
|
|
97
96
|
const match = hostPart.match(/http\.host eq "([^"]+)"/);
|
|
98
97
|
if (match) {
|
|
99
98
|
host = match[1];
|
|
100
99
|
}
|
|
101
100
|
}
|
|
102
|
-
//
|
|
101
|
+
// Process uriPath part
|
|
103
102
|
const uriPathPart = parts[1].trim();
|
|
104
103
|
if (uriPathPart.startsWith(`${RuleMatchOperatorStartsWith}(${RuleMatchTypeUriPath},`)) {
|
|
105
|
-
// uriPath
|
|
104
|
+
// Logic when uriPath matches startsWith
|
|
106
105
|
// starts_with(http.request.uri.path, "value")
|
|
107
106
|
const match = uriPathPart.match(/starts_with\(http\.request\.uri\.path,\s*"([^"]+)"\)/);
|
|
108
107
|
if (match) {
|
|
109
|
-
uriPath = `${match[1]}*`; //
|
|
108
|
+
uriPath = `${match[1]}*`; // Add suffix *
|
|
110
109
|
}
|
|
111
110
|
}
|
|
112
111
|
else if (uriPathPart.startsWith(`${RuleMatchTypeUriPath} ${RuleMatchOperatorEq}`)) {
|
|
113
|
-
// uriPath
|
|
112
|
+
// Logic when uriPath matches eq
|
|
114
113
|
// http.request.uri.path eq "value"
|
|
115
114
|
const match = uriPathPart.match(/http\.request\.uri\.path eq "([^"]+)"/);
|
|
116
115
|
if (match) {
|
|
@@ -5,7 +5,7 @@ import listRoute from './list.js';
|
|
|
5
5
|
let yargsIns;
|
|
6
6
|
const routeCommand = {
|
|
7
7
|
command: 'route [script]',
|
|
8
|
-
describe: `🚄 ${t('route_describe').d('Manage the routes bound to your
|
|
8
|
+
describe: `🚄 ${t('route_describe').d('Manage the routes bound to your project')}`,
|
|
9
9
|
builder: (yargs) => {
|
|
10
10
|
yargsIns = yargs;
|
|
11
11
|
return yargs
|
|
@@ -18,7 +18,7 @@ const routeCommand = {
|
|
|
18
18
|
type: 'boolean',
|
|
19
19
|
default: false
|
|
20
20
|
})
|
|
21
|
-
.usage(`${t('common_usage').d('Usage')}: esa route <add | list | delete>`);
|
|
21
|
+
.usage(`${t('common_usage').d('Usage')}: esa-cli route <add | list | delete>`);
|
|
22
22
|
},
|
|
23
23
|
handler: (argv) => {
|
|
24
24
|
if (yargsIns && (argv.help || argv._.length < 2)) {
|
|
@@ -12,17 +12,18 @@ import { ApiService } from '../../libs/apiService.js';
|
|
|
12
12
|
import logger from '../../libs/logger.js';
|
|
13
13
|
import { checkIsLoginSuccess } from '../utils.js';
|
|
14
14
|
const deleteCommand = {
|
|
15
|
-
command: 'delete <
|
|
16
|
-
|
|
15
|
+
command: 'delete <projectName>',
|
|
16
|
+
aliases: ['delete <routineName>'],
|
|
17
|
+
describe: `🗑 ${t('delete_describe').d('Delete a project')}`,
|
|
17
18
|
builder: (yargs) => {
|
|
18
19
|
return yargs
|
|
19
|
-
.positional('
|
|
20
|
-
describe: t('delete_routineName_positional_describe').d('The name of the
|
|
20
|
+
.positional('projectName', {
|
|
21
|
+
describe: t('delete_routineName_positional_describe').d('The name of the project to delete'),
|
|
21
22
|
type: 'string',
|
|
22
23
|
array: true,
|
|
23
24
|
demandOption: true
|
|
24
25
|
})
|
|
25
|
-
.usage(`${t('common_usage').d('Usage')}: $0 delete <
|
|
26
|
+
.usage(`${t('common_usage').d('Usage')}: $0 delete <projectName>`);
|
|
26
27
|
},
|
|
27
28
|
handler: (argv) => __awaiter(void 0, void 0, void 0, function* () {
|
|
28
29
|
handleDelete(argv);
|
|
@@ -34,7 +35,7 @@ export function handleDelete(argv) {
|
|
|
34
35
|
const isSuccess = yield checkIsLoginSuccess();
|
|
35
36
|
if (!isSuccess)
|
|
36
37
|
return;
|
|
37
|
-
const routineName = argv.routineName;
|
|
38
|
+
const routineName = argv.projectName || argv.routineName;
|
|
38
39
|
const req = { Name: routineName };
|
|
39
40
|
return yield deleteRoutineFromUserAccount(req);
|
|
40
41
|
});
|
|
@@ -3,8 +3,9 @@ import routineDelete from './delete.js';
|
|
|
3
3
|
import routineList from './list.js';
|
|
4
4
|
let yargsIns;
|
|
5
5
|
const routineCommand = {
|
|
6
|
-
command: '
|
|
7
|
-
|
|
6
|
+
command: 'project [script]',
|
|
7
|
+
aliases: ['routine'],
|
|
8
|
+
describe: `🧭 ${t('routine_describe').d('Manage your project')}`,
|
|
8
9
|
builder: (yargs) => {
|
|
9
10
|
yargsIns = yargs;
|
|
10
11
|
return yargs
|
|
@@ -16,7 +17,7 @@ const routineCommand = {
|
|
|
16
17
|
type: 'boolean',
|
|
17
18
|
default: false
|
|
18
19
|
})
|
|
19
|
-
.usage(`${t('common_usage').d('Usage')}: esa
|
|
20
|
+
.usage(`${t('common_usage').d('Usage')}: esa-cli project [list | delete]`);
|
|
20
21
|
},
|
|
21
22
|
handler: (argv) => {
|
|
22
23
|
if (yargsIns && (argv.help || argv._.length < 2)) {
|
|
@@ -16,41 +16,59 @@ import logger from '../../libs/logger.js';
|
|
|
16
16
|
import { checkIsLoginSuccess } from '../utils.js';
|
|
17
17
|
const list = {
|
|
18
18
|
command: 'list',
|
|
19
|
-
describe: `📋 ${t('list_describe').d('List all your
|
|
19
|
+
describe: `📋 ${t('list_describe').d('List all your projects')}`,
|
|
20
20
|
builder: (yargs) => {
|
|
21
|
-
return yargs
|
|
21
|
+
return yargs
|
|
22
|
+
.option('keyword', {
|
|
23
|
+
alias: 'k',
|
|
24
|
+
describe: t('deploy_option_keyword').d('Keyword to search for projects'),
|
|
25
|
+
type: 'string'
|
|
26
|
+
})
|
|
27
|
+
.usage(`${t('common_usage').d('Usage')}: \$0 list [--keyword <keyword>]`);
|
|
22
28
|
},
|
|
23
29
|
handler: (argv) => __awaiter(void 0, void 0, void 0, function* () {
|
|
24
30
|
handleList(argv);
|
|
25
31
|
})
|
|
26
32
|
};
|
|
27
33
|
export default list;
|
|
34
|
+
export function getAllRoutines(options) {
|
|
35
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
36
|
+
var _a;
|
|
37
|
+
const server = yield ApiService.getInstance();
|
|
38
|
+
const allRoutines = [];
|
|
39
|
+
let pageNumber = 1;
|
|
40
|
+
const pageSize = (options === null || options === void 0 ? void 0 : options.PageSize) || 50;
|
|
41
|
+
while (true) {
|
|
42
|
+
const res = yield server.listUserRoutines({
|
|
43
|
+
RegionId: options === null || options === void 0 ? void 0 : options.RegionId,
|
|
44
|
+
PageNumber: pageNumber,
|
|
45
|
+
PageSize: pageSize,
|
|
46
|
+
SearchKeyWord: options === null || options === void 0 ? void 0 : options.SearchKeyWord
|
|
47
|
+
});
|
|
48
|
+
if (!((_a = res === null || res === void 0 ? void 0 : res.body) === null || _a === void 0 ? void 0 : _a.Routines)) {
|
|
49
|
+
break;
|
|
50
|
+
}
|
|
51
|
+
allRoutines.push(...res.body.Routines);
|
|
52
|
+
const totalCount = res.body.TotalCount;
|
|
53
|
+
const currentCount = allRoutines.length;
|
|
54
|
+
if (currentCount >= totalCount) {
|
|
55
|
+
break;
|
|
56
|
+
}
|
|
57
|
+
pageNumber++;
|
|
58
|
+
}
|
|
59
|
+
return allRoutines;
|
|
60
|
+
});
|
|
61
|
+
}
|
|
28
62
|
export function handleList(argv) {
|
|
29
63
|
return __awaiter(this, void 0, void 0, function* () {
|
|
30
|
-
var _a, _b;
|
|
31
|
-
const { site } = argv;
|
|
32
64
|
const isSuccess = yield checkIsLoginSuccess();
|
|
33
65
|
if (!isSuccess)
|
|
34
66
|
return;
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
SiteSearchType: 'fuzzy',
|
|
39
|
-
Status: 'active',
|
|
40
|
-
PageNumber: 1,
|
|
41
|
-
PageSize: 50
|
|
42
|
-
};
|
|
43
|
-
const res = yield server.listSites(req);
|
|
44
|
-
const siteList = (_a = res === null || res === void 0 ? void 0 : res.data.Sites) !== null && _a !== void 0 ? _a : [];
|
|
45
|
-
const siteNameList = siteList === null || siteList === void 0 ? void 0 : siteList.map((item) => item.SiteName);
|
|
46
|
-
logger.log(chalk.bold.bgGray(`📃 ${t('list_site_name_title').d('List all of site names')}:`));
|
|
47
|
-
logger.tree(siteNameList);
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
|
-
const res = yield server.listUserRoutines();
|
|
51
|
-
const routineList = (_b = res === null || res === void 0 ? void 0 : res.body) === null || _b === void 0 ? void 0 : _b.Routines;
|
|
67
|
+
const routineList = yield getAllRoutines({
|
|
68
|
+
SearchKeyWord: argv.keyword
|
|
69
|
+
});
|
|
52
70
|
if (routineList) {
|
|
53
|
-
logger.log(chalk.bold.bgGray(`📃 ${t('list_routine_name_title').d('List all of
|
|
71
|
+
logger.log(chalk.bold.bgGray(`📃 ${t('list_routine_name_title').d('List all of Functions& Pages')}:`));
|
|
54
72
|
displayRoutineList(routineList);
|
|
55
73
|
}
|
|
56
74
|
});
|
|
@@ -14,7 +14,7 @@ const siteCommand = {
|
|
|
14
14
|
type: 'boolean',
|
|
15
15
|
default: false
|
|
16
16
|
})
|
|
17
|
-
.usage(`${t('common_usage').d('Usage')}: esa site [list]`);
|
|
17
|
+
.usage(`${t('common_usage').d('Usage')}: esa-cli site [list]`);
|
|
18
18
|
},
|
|
19
19
|
handler: (argv) => {
|
|
20
20
|
if (yargsIns && (argv.help || argv._.length < 2)) {
|
package/dist/commands/utils.js
CHANGED
|
@@ -71,7 +71,7 @@ export const bindRoutineWithDomain = (name, domain) => __awaiter(void 0, void 0,
|
|
|
71
71
|
export function validName(name) {
|
|
72
72
|
return /^[a-zA-Z0-9-_]+$/.test(name);
|
|
73
73
|
}
|
|
74
|
-
//
|
|
74
|
+
// Validate if domain is valid
|
|
75
75
|
export function validDomain(domain) {
|
|
76
76
|
return /^(?:[a-z0-9-](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/.test(domain);
|
|
77
77
|
}
|
|
@@ -89,7 +89,7 @@ export function checkIsLoginSuccess() {
|
|
|
89
89
|
if (!endpoint) {
|
|
90
90
|
endpoint = cliConfig === null || cliConfig === void 0 ? void 0 : cliConfig.endpoint;
|
|
91
91
|
}
|
|
92
|
-
const namedCommand = chalk.green('esa login');
|
|
92
|
+
const namedCommand = chalk.green('esa-cli login');
|
|
93
93
|
if (!accessKeyId || !accessKeySecret) {
|
|
94
94
|
logger.log(`❌ ${t('utils_login_error').d('Maybe you are not logged in yet.')}`);
|
|
95
95
|
logger.log(`🔔 ${t('utils_login_error_config', { namedCommand }).d(`Please run command to login: ${namedCommand}`)}`);
|
|
@@ -131,12 +131,12 @@ export function validateLoginCredentials(accessKeyId_1, accessKeySecret_1, endpo
|
|
|
131
131
|
});
|
|
132
132
|
}
|
|
133
133
|
export function isValidRouteForDomain(route, domain) {
|
|
134
|
-
//
|
|
135
|
-
//
|
|
134
|
+
// Build a regex that allows subdomains and arbitrary paths
|
|
135
|
+
// For example, match URLs like *.example.com/*
|
|
136
136
|
return route.includes(domain);
|
|
137
137
|
}
|
|
138
138
|
export function escapeRegExp(string) {
|
|
139
|
-
return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); // $&
|
|
139
|
+
return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); // $& represents the entire matched string
|
|
140
140
|
}
|
|
141
141
|
export const getAllSites = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
142
142
|
var _a;
|
|
@@ -51,7 +51,7 @@ export const FilterSelector = ({ data, onSubmit, hideCount = 20 }) => {
|
|
|
51
51
|
else if (tabPressCount === 1) {
|
|
52
52
|
const filteredDataInner = data.filter((site) => site.label.includes(inputValue));
|
|
53
53
|
setFilteredData(filteredDataInner);
|
|
54
|
-
//
|
|
54
|
+
// Enter selection mode when match results >= 1
|
|
55
55
|
if ((filteredDataInner.length >= 1 &&
|
|
56
56
|
showAll &&
|
|
57
57
|
filteredDataInner.length > hideCount) ||
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { Box, render, Text } from 'ink';
|
|
11
|
+
import TextInput from 'ink-text-input';
|
|
12
|
+
import React, { useState } from 'react';
|
|
13
|
+
import t from '../i18n/index.js';
|
|
14
|
+
export const RouteBuilder = ({ siteName, onSubmit, onCancel }) => {
|
|
15
|
+
const [prefix, setPrefix] = useState('');
|
|
16
|
+
const [suffix, setSuffix] = useState('');
|
|
17
|
+
const [currentInput, setCurrentInput] = useState('prefix');
|
|
18
|
+
const [error, setError] = useState('');
|
|
19
|
+
const handleSubmit = () => {
|
|
20
|
+
if (currentInput === 'prefix') {
|
|
21
|
+
setCurrentInput('suffix');
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
// Build complete route, add dot before prefix and slash before suffix if not empty
|
|
25
|
+
const prefixWithDot = prefix ? `${prefix}.` : '';
|
|
26
|
+
const suffixWithDot = suffix ? `/${suffix}` : '';
|
|
27
|
+
const route = `${prefixWithDot}${siteName}${suffixWithDot}`;
|
|
28
|
+
onSubmit(route);
|
|
29
|
+
};
|
|
30
|
+
const handleCancel = () => {
|
|
31
|
+
onCancel();
|
|
32
|
+
};
|
|
33
|
+
const currentPrompt = currentInput === 'prefix'
|
|
34
|
+
? t('route_builder_prefix_prompt')
|
|
35
|
+
.d(`Enter route prefix for ${siteName} (e.g., abc, def):`)
|
|
36
|
+
.replace('${siteName}', siteName)
|
|
37
|
+
: t('route_builder_suffix_prompt')
|
|
38
|
+
.d(`Enter route suffix for ${siteName} (e.g., *, users/*):`)
|
|
39
|
+
.replace('${siteName}', siteName);
|
|
40
|
+
const prefixWithDot = prefix ? `${prefix}.` : '';
|
|
41
|
+
const suffixWithDot = suffix ? `/${suffix}` : '';
|
|
42
|
+
const preview = `Preview: ${prefixWithDot}${siteName}${suffixWithDot}`;
|
|
43
|
+
return (React.createElement(Box, { flexDirection: "column" },
|
|
44
|
+
React.createElement(Box, null,
|
|
45
|
+
React.createElement(Text, null, "Building route for site: "),
|
|
46
|
+
React.createElement(Text, { color: "cyan" }, siteName)),
|
|
47
|
+
React.createElement(Box, { marginTop: 1 },
|
|
48
|
+
React.createElement(Text, null, currentPrompt)),
|
|
49
|
+
React.createElement(Box, { marginTop: 1 },
|
|
50
|
+
React.createElement(TextInput, { value: currentInput === 'prefix' ? prefix : suffix, onChange: currentInput === 'prefix' ? setPrefix : setSuffix, onSubmit: handleSubmit })),
|
|
51
|
+
preview && (React.createElement(Box, { marginTop: 1 },
|
|
52
|
+
React.createElement(Text, { color: "green" }, preview))),
|
|
53
|
+
React.createElement(Box, { marginTop: 1 },
|
|
54
|
+
React.createElement(Text, { color: "gray" }, t('route_builder_instructions').d('Press Enter to continue, Ctrl+C to cancel'))),
|
|
55
|
+
error && (React.createElement(Box, { marginTop: 1 },
|
|
56
|
+
React.createElement(Text, { color: "red" }, error)))));
|
|
57
|
+
};
|
|
58
|
+
export const routeBuilder = (siteName) => __awaiter(void 0, void 0, void 0, function* () {
|
|
59
|
+
return new Promise((resolve) => {
|
|
60
|
+
const { unmount } = render(React.createElement(RouteBuilder, { siteName: siteName, onSubmit: (route) => {
|
|
61
|
+
unmount();
|
|
62
|
+
resolve(route);
|
|
63
|
+
}, onCancel: () => {
|
|
64
|
+
unmount();
|
|
65
|
+
resolve(null);
|
|
66
|
+
} }));
|
|
67
|
+
});
|
|
68
|
+
});
|