esa-cli 0.0.5 → 1.0.0
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 +32 -149
- package/dist/commands/commit/index.js +49 -104
- package/dist/commands/commit/prodBuild.js +2 -3
- package/dist/commands/common/constant.js +4 -4
- package/dist/commands/common/utils.js +419 -0
- package/dist/commands/config.js +2 -2
- package/dist/commands/deploy/helper.js +43 -49
- package/dist/commands/deploy/index.js +51 -174
- package/dist/commands/deployments/delete.js +32 -22
- package/dist/commands/deployments/index.js +4 -4
- package/dist/commands/deployments/list.js +21 -34
- package/dist/commands/dev/build.js +3 -3
- package/dist/commands/dev/doProcess.js +5 -5
- package/dist/commands/dev/ew2/cacheService.js +33 -0
- package/dist/commands/dev/ew2/devEntry.js +2 -1
- package/dist/commands/dev/ew2/devPack.js +31 -20
- package/dist/commands/dev/ew2/kvService.js +50 -0
- package/dist/commands/dev/ew2/mock/cache.js +99 -15
- package/dist/commands/dev/ew2/mock/kv.js +142 -21
- package/dist/commands/dev/ew2/server.js +163 -28
- package/dist/commands/dev/index.js +17 -18
- package/dist/commands/dev/mockWorker/devPack.js +19 -10
- package/dist/commands/dev/mockWorker/server.js +7 -6
- package/dist/commands/domain/add.js +4 -4
- package/dist/commands/domain/delete.js +3 -3
- package/dist/commands/domain/index.js +4 -4
- package/dist/commands/domain/list.js +7 -7
- package/dist/commands/init/helper.js +654 -21
- package/dist/commands/init/index.js +88 -152
- package/dist/commands/init/snippets/nextjs/next.config.mjs +6 -0
- package/dist/commands/init/snippets/nextjs/next.config.ts +7 -0
- package/dist/commands/init/snippets/react-router/react-router.config.ts +7 -0
- package/dist/commands/init/template.jsonc +84 -0
- package/dist/commands/init/types.js +1 -0
- package/dist/commands/lang.js +2 -2
- package/dist/commands/login/index.js +74 -34
- package/dist/commands/logout.js +6 -6
- package/dist/commands/route/add.js +101 -43
- package/dist/commands/route/delete.js +6 -6
- package/dist/commands/route/helper.js +9 -10
- package/dist/commands/route/index.js +4 -4
- package/dist/commands/route/list.js +4 -4
- package/dist/commands/routine/delete.js +9 -8
- package/dist/commands/routine/index.js +6 -5
- package/dist/commands/routine/list.js +45 -39
- package/dist/commands/site/index.js +3 -3
- package/dist/commands/site/list.js +6 -7
- package/dist/commands/utils.js +61 -25
- package/dist/components/descriptionInput.js +1 -1
- package/dist/components/filterSelector.js +1 -1
- package/dist/components/mutiLevelSelect.js +19 -20
- package/dist/components/mutiSelectTable.js +1 -1
- package/dist/components/routeBuilder.js +68 -0
- package/dist/components/selectInput.js +2 -3
- package/dist/components/selectItem.js +1 -1
- package/dist/docs/Commands_en.md +164 -117
- package/dist/docs/Commands_zh_CN.md +155 -107
- package/dist/docs/Config_en.md +70 -0
- package/dist/docs/Config_zh_CN.md +68 -0
- package/dist/i18n/index.js +2 -2
- package/dist/i18n/locales.json +414 -82
- package/dist/index.js +28 -13
- package/dist/libs/api.js +3 -6
- package/dist/libs/apiService.js +192 -69
- package/dist/libs/git/index.js +86 -9
- package/dist/libs/interface.js +0 -1
- package/dist/libs/logger.js +162 -10
- package/dist/libs/service.js +2 -2
- package/dist/libs/templates/index.js +1 -1
- package/dist/utils/checkAssetsExist.js +80 -0
- package/dist/utils/checkDevPort.js +5 -19
- package/dist/utils/checkEntryFileExist.js +10 -0
- package/dist/utils/checkIsRoutineCreated.js +27 -21
- package/dist/utils/checkVersion.js +119 -1
- package/dist/utils/command.js +149 -0
- package/dist/utils/compress.js +142 -0
- package/dist/utils/download.js +8 -8
- package/dist/utils/fileMd5.js +1 -1
- package/dist/utils/fileUtils/index.js +136 -45
- package/dist/utils/installDeno.js +4 -4
- package/dist/utils/installEw2.js +9 -9
- package/dist/utils/openInBrowser.js +1 -1
- package/dist/utils/prompt.js +97 -0
- package/package.json +23 -12
- package/zh_CN.md +29 -154
|
@@ -10,32 +10,32 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
import { exec } from 'child_process';
|
|
11
11
|
import { isIP } from 'net';
|
|
12
12
|
import chokidar from 'chokidar';
|
|
13
|
-
import doProcess from './doProcess.js';
|
|
14
|
-
import { getProjectConfig, generateConfigFile, getDevConf } from '../../utils/fileUtils/index.js';
|
|
15
|
-
import { getRoot } from '../../utils/fileUtils/base.js';
|
|
16
13
|
import SelectItems from '../../components/selectInput.js';
|
|
17
|
-
import logger from '../../libs/logger.js';
|
|
18
|
-
import MockServer from './mockWorker/server.js';
|
|
19
|
-
import mockPack from './mockWorker/devPack.js';
|
|
20
|
-
import Ew2Server from './ew2/server.js';
|
|
21
|
-
import ew2Pack from './ew2/devPack.js';
|
|
22
|
-
import { preCheckDeno } from '../../utils/installDeno.js';
|
|
23
|
-
import { preCheckEw2 } from '../../utils/installEw2.js';
|
|
24
|
-
import debounce from '../../utils/debounce.js';
|
|
25
14
|
import t from '../../i18n/index.js';
|
|
15
|
+
import logger from '../../libs/logger.js';
|
|
26
16
|
import checkAndInputPort from '../../utils/checkDevPort.js';
|
|
27
17
|
import { checkOS, Platforms } from '../../utils/checkOS.js';
|
|
18
|
+
import debounce from '../../utils/debounce.js';
|
|
19
|
+
import { getRoot } from '../../utils/fileUtils/base.js';
|
|
20
|
+
import { getProjectConfig, generateConfigFile, getDevConf } from '../../utils/fileUtils/index.js';
|
|
21
|
+
import { preCheckDeno } from '../../utils/installDeno.js';
|
|
22
|
+
import { preCheckEw2 } from '../../utils/installEw2.js';
|
|
23
|
+
import doProcess from './doProcess.js';
|
|
24
|
+
import ew2Pack from './ew2/devPack.js';
|
|
25
|
+
import Ew2Server from './ew2/server.js';
|
|
26
|
+
import mockPack from './mockWorker/devPack.js';
|
|
27
|
+
import MockServer from './mockWorker/server.js';
|
|
28
28
|
let yargsIns;
|
|
29
29
|
const OS = checkOS();
|
|
30
30
|
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) => {
|
|
@@ -203,7 +203,7 @@ const dev = {
|
|
|
203
203
|
userFileRepacking = false;
|
|
204
204
|
return;
|
|
205
205
|
}
|
|
206
|
-
worker.restart();
|
|
206
|
+
worker.restart(devPack);
|
|
207
207
|
return;
|
|
208
208
|
}
|
|
209
209
|
logger.info('Dev repack');
|
|
@@ -215,14 +215,13 @@ const dev = {
|
|
|
215
215
|
catch (err) { }
|
|
216
216
|
}
|
|
217
217
|
userFileRepacking = true;
|
|
218
|
-
yield devPack
|
|
219
|
-
yield worker.restart();
|
|
218
|
+
yield worker.restart(devPack);
|
|
220
219
|
}), 500));
|
|
221
220
|
var { devElement, exit } = doProcess(worker);
|
|
222
221
|
const { waitUntilExit } = devElement;
|
|
223
222
|
yield waitUntilExit();
|
|
224
223
|
function onWorkerClosed() {
|
|
225
|
-
exit
|
|
224
|
+
exit === null || exit === void 0 ? void 0 : exit();
|
|
226
225
|
}
|
|
227
226
|
watcher.close();
|
|
228
227
|
})
|
|
@@ -7,14 +7,14 @@ 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 path from 'path';
|
|
11
10
|
import fs from 'fs';
|
|
12
|
-
import
|
|
13
|
-
import devBuild from '../build.js';
|
|
11
|
+
import path from 'path';
|
|
14
12
|
import t from '../../../i18n/index.js';
|
|
15
|
-
import
|
|
16
|
-
import { getRoot, getDirName } from '../../../utils/fileUtils/base.js';
|
|
13
|
+
import logger from '../../../libs/logger.js';
|
|
17
14
|
import { checkPort } from '../../../utils/checkDevPort.js';
|
|
15
|
+
import { getRoot, getDirName } from '../../../utils/fileUtils/base.js';
|
|
16
|
+
import { getDevConf } from '../../../utils/fileUtils/index.js';
|
|
17
|
+
import devBuild from '../build.js';
|
|
18
18
|
const generateEntry = (id, projectEntry, userRoot) => __awaiter(void 0, void 0, void 0, function* () {
|
|
19
19
|
const __dirname = getDirName(import.meta.url);
|
|
20
20
|
const devDir = path.resolve(userRoot, '.dev');
|
|
@@ -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')
|
|
@@ -78,10 +78,19 @@ const prepare = (configPath, entry, port, localUpstream, userRoot) => __awaiter(
|
|
|
78
78
|
const devPack = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
79
79
|
logger.ora.start('Processing...\n');
|
|
80
80
|
const userRoot = getRoot();
|
|
81
|
-
|
|
81
|
+
// Try to find config file in order of preference: .jsonc, .toml
|
|
82
|
+
const configFormats = ['esa.jsonc', 'esa.toml'];
|
|
83
|
+
let configPath = null;
|
|
84
|
+
for (const format of configFormats) {
|
|
85
|
+
const testPath = path.resolve(userRoot, format);
|
|
86
|
+
if (fs.existsSync(testPath)) {
|
|
87
|
+
configPath = testPath;
|
|
88
|
+
break;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
82
91
|
let port, minify, localUpstream, entry;
|
|
83
92
|
let projectEntry = path.resolve(userRoot, 'src/index.js');
|
|
84
|
-
if (
|
|
93
|
+
if (configPath) {
|
|
85
94
|
port = getDevConf('port', 'dev', 18080);
|
|
86
95
|
minify = getDevConf('minify', 'dev', false);
|
|
87
96
|
localUpstream = getDevConf('localUpstream', 'dev', '');
|
|
@@ -92,7 +101,7 @@ const devPack = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
92
101
|
}
|
|
93
102
|
else {
|
|
94
103
|
logger.notInProject();
|
|
95
|
-
process.exit(
|
|
104
|
+
process.exit(1);
|
|
96
105
|
}
|
|
97
106
|
return prepare(path.resolve(userRoot, '.dev/devConfig.js'), projectEntry, port, localUpstream, userRoot)
|
|
98
107
|
.then(() => {
|
|
@@ -7,12 +7,12 @@ 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 spawn from 'cross-spawn';
|
|
11
|
-
import logger from '../../../libs/logger.js';
|
|
12
10
|
import path from 'path';
|
|
11
|
+
import spawn from 'cross-spawn';
|
|
13
12
|
import t from '../../../i18n/index.js';
|
|
14
|
-
import
|
|
13
|
+
import logger from '../../../libs/logger.js';
|
|
15
14
|
import { getRoot } from '../../../utils/fileUtils/base.js';
|
|
15
|
+
import { getDevConf } from '../../../utils/fileUtils/index.js';
|
|
16
16
|
class MockWorkerServer {
|
|
17
17
|
constructor(props) {
|
|
18
18
|
this.instance = null;
|
|
@@ -63,10 +63,11 @@ class MockWorkerServer {
|
|
|
63
63
|
logger.subError(chunk.toString().trim());
|
|
64
64
|
}
|
|
65
65
|
errorHandler(err) {
|
|
66
|
+
var _a;
|
|
66
67
|
logger.error(err.message ? err.message : err);
|
|
67
|
-
this.instance
|
|
68
|
+
(_a = this.instance) === null || _a === void 0 ? void 0 : _a.kill();
|
|
68
69
|
}
|
|
69
|
-
closeHandler(
|
|
70
|
+
closeHandler() {
|
|
70
71
|
if (this.restarting) {
|
|
71
72
|
this.restarting = false;
|
|
72
73
|
return;
|
|
@@ -86,7 +87,7 @@ class MockWorkerServer {
|
|
|
86
87
|
resolve(false);
|
|
87
88
|
return;
|
|
88
89
|
}
|
|
89
|
-
const onExit = (
|
|
90
|
+
const onExit = () => {
|
|
90
91
|
this.instance = null;
|
|
91
92
|
resolve(true);
|
|
92
93
|
};
|
|
@@ -7,14 +7,14 @@ 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 { bindRoutineWithDomain, checkDirectory, checkIsLoginSuccess, validDomain, validName } from '../utils.js';
|
|
11
|
-
import { getProjectConfig } from '../../utils/fileUtils/index.js';
|
|
12
10
|
import t from '../../i18n/index.js';
|
|
13
11
|
import logger from '../../libs/logger.js';
|
|
14
12
|
import { validRoutine } from '../../utils/checkIsRoutineCreated.js';
|
|
13
|
+
import { getProjectConfig } from '../../utils/fileUtils/index.js';
|
|
14
|
+
import { bindRoutineWithDomain, checkDirectory, checkIsLoginSuccess, validDomain, validName } from '../utils.js';
|
|
15
15
|
const addDomain = {
|
|
16
16
|
command: 'add <domain>',
|
|
17
|
-
describe:
|
|
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'),
|
|
@@ -7,12 +7,12 @@ 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 { getProjectConfig } from '../../utils/fileUtils/index.js';
|
|
11
|
-
import { checkDirectory, checkIsLoginSuccess } from '../utils.js';
|
|
12
|
-
import { ApiService } from '../../libs/apiService.js';
|
|
13
10
|
import t from '../../i18n/index.js';
|
|
11
|
+
import { ApiService } from '../../libs/apiService.js';
|
|
14
12
|
import logger from '../../libs/logger.js';
|
|
15
13
|
import { validRoutine } from '../../utils/checkIsRoutineCreated.js';
|
|
14
|
+
import { getProjectConfig } from '../../utils/fileUtils/index.js';
|
|
15
|
+
import { checkDirectory, checkIsLoginSuccess } from '../utils.js';
|
|
16
16
|
const deleteDomain = {
|
|
17
17
|
command: 'delete <domain>',
|
|
18
18
|
describe: `🗑 ${t('domain_delete_describe').d('Delete a related domain')}`,
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
+
import t from '../../i18n/index.js';
|
|
1
2
|
import addDomain from './add.js';
|
|
2
|
-
import listDomain from './list.js';
|
|
3
3
|
import deleteDomain from './delete.js';
|
|
4
|
-
import
|
|
4
|
+
import listDomain from './list.js';
|
|
5
5
|
let yargsIns;
|
|
6
6
|
const domainCommand = {
|
|
7
7
|
command: 'domain [script]',
|
|
8
|
-
describe:
|
|
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)) {
|
|
@@ -7,21 +7,21 @@ 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 { checkDirectory, checkIsLoginSuccess } from '../utils.js';
|
|
11
|
-
import logger from '../../libs/logger.js';
|
|
12
|
-
import { getProjectConfig } from '../../utils/fileUtils/index.js';
|
|
13
|
-
import { ApiService } from '../../libs/apiService.js';
|
|
14
10
|
import t from '../../i18n/index.js';
|
|
11
|
+
import { ApiService } from '../../libs/apiService.js';
|
|
12
|
+
import logger from '../../libs/logger.js';
|
|
15
13
|
import { validRoutine } from '../../utils/checkIsRoutineCreated.js';
|
|
14
|
+
import { getProjectConfig } from '../../utils/fileUtils/index.js';
|
|
15
|
+
import { checkDirectory, checkIsLoginSuccess } from '../utils.js';
|
|
16
16
|
const listDomain = {
|
|
17
17
|
command: 'list',
|
|
18
18
|
describe: `🔍 ${t('domain_list_describe').d('List all related domains')}`,
|
|
19
|
-
handler: (
|
|
20
|
-
handleListDomains(
|
|
19
|
+
handler: () => __awaiter(void 0, void 0, void 0, function* () {
|
|
20
|
+
handleListDomains();
|
|
21
21
|
})
|
|
22
22
|
};
|
|
23
23
|
export default listDomain;
|
|
24
|
-
export function handleListDomains(
|
|
24
|
+
export function handleListDomains() {
|
|
25
25
|
return __awaiter(this, void 0, void 0, function* () {
|
|
26
26
|
var _a, _b;
|
|
27
27
|
if (!checkDirectory()) {
|