easy-soft-develop 2.1.216 → 2.1.220
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/bin/cli.js +7 -7
- package/package.json +8 -7
- package/src/cliCollection/create-project-from-repository.js +76 -0
- package/src/cliCollection/{update-project-with-master-template.js → update-project-from-repository.js} +1 -1
- package/src/config/develop.update.project.from.repository.js +57 -0
- package/src/project/initProject.js +5 -0
- package/src/tools/update.project.from.repository.js +196 -0
- package/types/cliCollection/create-project-from-repository.d.ts +1 -0
- package/types/cliCollection/update-project-from-repository.d.ts +1 -0
- package/types/config/develop.update.project.from.repository.d.ts +4 -0
- package/types/tools/update.project.from.repository.d.ts +7 -0
- package/src/cliCollection/create-project-with-master-template.js +0 -65
- package/src/tools/update.project.from.master.template.js +0 -274
package/bin/cli.js
CHANGED
|
@@ -15,8 +15,8 @@ const createRepositoryProject = require('../src/cliCollection/create-repository-
|
|
|
15
15
|
const clearAllDependence = require('../src/cliCollection/clear-all-dependence');
|
|
16
16
|
const updatePackageFromPackage = require('../src/cliCollection/update-package-from-package');
|
|
17
17
|
const createProjectWithTemplate = require('../src/cliCollection/create-project-with-template');
|
|
18
|
-
const
|
|
19
|
-
const
|
|
18
|
+
const createProjectFromRepository = require('../src/cliCollection/create-project-from-repository');
|
|
19
|
+
const updateProjectFromRepository = require('../src/cliCollection/update-project-from-repository');
|
|
20
20
|
const prompt = require('../src/cliCollection/prompt');
|
|
21
21
|
const code = require('../src/cliCollection/createCode');
|
|
22
22
|
const rimraf = require('../src/cliCollection/rimraf');
|
|
@@ -159,20 +159,20 @@ program
|
|
|
159
159
|
});
|
|
160
160
|
|
|
161
161
|
program
|
|
162
|
-
.command('create-project-
|
|
162
|
+
.command('create-project-from-repository')
|
|
163
163
|
.description('update package from local or remote package.json file')
|
|
164
|
-
.option('--
|
|
164
|
+
.option('--repository <string>', 'repository with download')
|
|
165
165
|
.option('--folder <string>', 'folder name create project in it')
|
|
166
166
|
.option(
|
|
167
167
|
'--exampleUrl <string>',
|
|
168
168
|
'example url, if it has value, will prompt info after create',
|
|
169
169
|
)
|
|
170
170
|
.action((a, o) => {
|
|
171
|
-
|
|
171
|
+
createProjectFromRepository.run(a, o);
|
|
172
172
|
});
|
|
173
173
|
|
|
174
174
|
program
|
|
175
|
-
.command('update-project-
|
|
175
|
+
.command('update-project-from-repository')
|
|
176
176
|
.description('update from master template repository')
|
|
177
177
|
.option('--projectPath <string>', 'target project path that will be updated')
|
|
178
178
|
.option(
|
|
@@ -180,7 +180,7 @@ program
|
|
|
180
180
|
'web agent for remote , if it has value, will use the agent to access remote url',
|
|
181
181
|
)
|
|
182
182
|
.action((a, o) => {
|
|
183
|
-
|
|
183
|
+
updateProjectFromRepository.run(a, o);
|
|
184
184
|
});
|
|
185
185
|
|
|
186
186
|
program
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "easy-soft-develop",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.220",
|
|
4
4
|
"description": "",
|
|
5
5
|
"homepage": "https://github.com/kityandhero/easy-soft-develop#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -32,13 +32,14 @@
|
|
|
32
32
|
"test:bin:check-all-package-version": "node ./bin/cli.js check-all-package-version",
|
|
33
33
|
"test:bin:code": "node ./bin/cli.js code --dataPath ./develop/generatorCodeSource/code.json",
|
|
34
34
|
"test:bin:create-assist-scripts": "node ./bin/cli.js create-assist-scripts",
|
|
35
|
+
"test:bin:create-project-from-repository": "node ./bin/cli.js create-project-from-repository --repository kityandhero/mono-antd-management-fast-master-template --folder ./temp/create-project-from-repository-demo",
|
|
35
36
|
"test:bin:create-repository-project": "node ./bin/cli.js create-repository-project",
|
|
36
37
|
"test:bin:exit": "node ./bin/cli.js exit",
|
|
37
38
|
"test:bin:publish": "node ./bin/cli.js publish --packages ss --otp true",
|
|
38
39
|
"test:bin:rimraf": "node ./bin/cli.js rimraf --path ./testRemoveThisPath",
|
|
39
40
|
"test:bin:sleep": "node ./bin/cli.js sleep --second 2 --showInfo true",
|
|
40
41
|
"test:bin:update-all-package-version": "node ./bin/cli.js update-all-package-version",
|
|
41
|
-
"test:bin:update-project-
|
|
42
|
+
"test:bin:update-project-from-repository": "node ./bin/cli.js update-project-from-repository --projectPath E:\\temp\\2\\test",
|
|
42
43
|
"test:commitRefresh": "node ./test/commitRefresh.test.js",
|
|
43
44
|
"test:createCleanScriptFile": "node ./test/createCleanScriptFile.test.js",
|
|
44
45
|
"test:createCommitRefreshScriptFile": "node ./test/createCommitRefreshScriptFile.test.js",
|
|
@@ -91,19 +92,19 @@
|
|
|
91
92
|
"@commitlint/config-pnpm-scopes": "^19.1.0",
|
|
92
93
|
"commitizen": "^4.3.0",
|
|
93
94
|
"conventional-changelog-conventionalcommits": "^8.0.0",
|
|
94
|
-
"cz-git": "^1.9.
|
|
95
|
+
"cz-git": "^1.9.4",
|
|
95
96
|
"eslint": "^8.57.0",
|
|
96
97
|
"eslint-config-prettier": "^9.1.0",
|
|
97
98
|
"eslint-formatter-pretty": "^6.0.1",
|
|
98
99
|
"eslint-import-resolver-typescript": "^3.6.1",
|
|
99
100
|
"eslint-plugin-eslint-comments": "^3.2.0",
|
|
100
101
|
"eslint-plugin-import": "^2.29.1",
|
|
101
|
-
"eslint-plugin-prettier": "^5.1
|
|
102
|
-
"eslint-plugin-promise": "^6.
|
|
103
|
-
"husky": "^9.
|
|
102
|
+
"eslint-plugin-prettier": "^5.2.1",
|
|
103
|
+
"eslint-plugin-promise": "^6.6.0",
|
|
104
|
+
"husky": "^9.1.1",
|
|
104
105
|
"lint-staged": "^15.2.7",
|
|
105
106
|
"npm-check-updates": "^16.14.20",
|
|
106
107
|
"prettier": "^3.3.3",
|
|
107
|
-
"prettier-plugin-packagejson": "^2.5.
|
|
108
|
+
"prettier-plugin-packagejson": "^2.5.1"
|
|
108
109
|
}
|
|
109
110
|
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
const createProjectFromRepository = require('download-git-repo');
|
|
2
|
+
|
|
3
|
+
const {
|
|
4
|
+
promptError,
|
|
5
|
+
exit,
|
|
6
|
+
checkStringIsEmpty,
|
|
7
|
+
promptWarn,
|
|
8
|
+
mkdirSync,
|
|
9
|
+
existDirectorySync,
|
|
10
|
+
promptInfo,
|
|
11
|
+
resolvePath,
|
|
12
|
+
promptSuccess,
|
|
13
|
+
promptTip,
|
|
14
|
+
} = require('../tools/meta');
|
|
15
|
+
|
|
16
|
+
exports.run = function (s, o) {
|
|
17
|
+
const {
|
|
18
|
+
_optionValues: { repository, folder, exampleUrl = '' },
|
|
19
|
+
} = o;
|
|
20
|
+
|
|
21
|
+
if (checkStringIsEmpty(folder)) {
|
|
22
|
+
promptWarn('Please enter project folder name');
|
|
23
|
+
|
|
24
|
+
exit();
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
if (checkStringIsEmpty(folder)) {
|
|
28
|
+
promptWarn('project folder name not allow empty');
|
|
29
|
+
|
|
30
|
+
exit();
|
|
31
|
+
} else {
|
|
32
|
+
if (checkStringIsEmpty(repository)) {
|
|
33
|
+
promptError('repository not allow empty');
|
|
34
|
+
|
|
35
|
+
exit();
|
|
36
|
+
} else {
|
|
37
|
+
const repositoryAdjust = repository;
|
|
38
|
+
|
|
39
|
+
const folderPath = resolvePath(`./${folder}`);
|
|
40
|
+
|
|
41
|
+
if (existDirectorySync(folderPath)) {
|
|
42
|
+
promptWarn('project folder already exist, please choose another');
|
|
43
|
+
|
|
44
|
+
exit();
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
mkdirSync(folderPath);
|
|
48
|
+
|
|
49
|
+
promptTip('repository', repositoryAdjust);
|
|
50
|
+
promptTip('folder', folder);
|
|
51
|
+
|
|
52
|
+
promptInfo('download will start, please wait a moment...');
|
|
53
|
+
|
|
54
|
+
createProjectFromRepository(
|
|
55
|
+
repositoryAdjust,
|
|
56
|
+
folderPath,
|
|
57
|
+
{ clone: false },
|
|
58
|
+
(err) => {
|
|
59
|
+
if (!err) {
|
|
60
|
+
promptSuccess('download success');
|
|
61
|
+
|
|
62
|
+
if (!checkStringIsEmpty(exampleUrl)) {
|
|
63
|
+
promptTip('here is a example project repo', exampleUrl);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
promptInfo('please modify info in package.json file');
|
|
67
|
+
} else {
|
|
68
|
+
promptError(err);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
exit();
|
|
72
|
+
},
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
const {
|
|
2
|
+
writeJsonFileSync,
|
|
3
|
+
readJsonFileSync,
|
|
4
|
+
existFileSync,
|
|
5
|
+
mkdirSync,
|
|
6
|
+
} = require('../tools/meta');
|
|
7
|
+
|
|
8
|
+
const developUpdateProjectFromRepository = {
|
|
9
|
+
repository: '',
|
|
10
|
+
sourcePath: '',
|
|
11
|
+
targetPath: '',
|
|
12
|
+
folders: [],
|
|
13
|
+
files: [],
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const developUpdateProjectFromRepositoryConfigFilePath =
|
|
17
|
+
'./develop/config/develop.update.project.from.repository.json';
|
|
18
|
+
|
|
19
|
+
function createDevelopUpdateProjectFromRepositoryConfigFile() {
|
|
20
|
+
mkdirSync(`./develop`);
|
|
21
|
+
|
|
22
|
+
mkdirSync(`./develop/config`);
|
|
23
|
+
|
|
24
|
+
writeJsonFileSync(
|
|
25
|
+
developUpdateProjectFromRepositoryConfigFilePath,
|
|
26
|
+
developUpdateProjectFromRepository,
|
|
27
|
+
{
|
|
28
|
+
coverFile: false,
|
|
29
|
+
},
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function getDevelopUpdateProjectFromRepositoryConfig(
|
|
34
|
+
createFileWhenNoExist = false,
|
|
35
|
+
) {
|
|
36
|
+
const developUpdateProjectFromRepositoryConfigFileExist = existFileSync(
|
|
37
|
+
developUpdateProjectFromRepositoryConfigFilePath,
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
if (!developUpdateProjectFromRepositoryConfigFileExist) {
|
|
41
|
+
if (createFileWhenNoExist) {
|
|
42
|
+
createDevelopUpdateProjectFromRepositoryConfigFile([]);
|
|
43
|
+
} else {
|
|
44
|
+
return developUpdateProjectFromRepository;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return {
|
|
49
|
+
...developUpdateProjectFromRepository,
|
|
50
|
+
...readJsonFileSync(developUpdateProjectFromRepositoryConfigFilePath),
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
module.exports = {
|
|
55
|
+
createDevelopUpdateProjectFromRepositoryConfigFile,
|
|
56
|
+
getDevelopUpdateProjectFromRepositoryConfig,
|
|
57
|
+
};
|
|
@@ -32,6 +32,9 @@ const {
|
|
|
32
32
|
const {
|
|
33
33
|
createDevelopSubPathVersionNcuConfigFile,
|
|
34
34
|
} = require('../config/develop.subPath.version.ncu');
|
|
35
|
+
const {
|
|
36
|
+
createDevelopUpdateProjectFromRepositoryConfigFile,
|
|
37
|
+
} = require('../config/develop.update.project.from.repository');
|
|
35
38
|
|
|
36
39
|
function createRepositoryProjectFolder(name) {
|
|
37
40
|
mkdirSync(`./${name}`);
|
|
@@ -200,6 +203,8 @@ function initialEnvironment() {
|
|
|
200
203
|
|
|
201
204
|
createDevelopSubPathVersionNcuConfigFile(['packages']);
|
|
202
205
|
|
|
206
|
+
createDevelopUpdateProjectFromRepositoryConfigFile();
|
|
207
|
+
|
|
203
208
|
promptSuccess(`step *: config environment`);
|
|
204
209
|
|
|
205
210
|
promptEmptyLine();
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
const download = require('download');
|
|
2
|
+
const agent = require('hpagent');
|
|
3
|
+
const zip = require('cross-zip');
|
|
4
|
+
|
|
5
|
+
const {
|
|
6
|
+
promptSuccess,
|
|
7
|
+
promptLine,
|
|
8
|
+
promptError,
|
|
9
|
+
promptWarn,
|
|
10
|
+
exit,
|
|
11
|
+
resolvePath,
|
|
12
|
+
checkStringIsEmpty,
|
|
13
|
+
promptInfo,
|
|
14
|
+
exec,
|
|
15
|
+
copyFileSync,
|
|
16
|
+
copyFolderSync,
|
|
17
|
+
promptTip,
|
|
18
|
+
} = require('./meta');
|
|
19
|
+
|
|
20
|
+
const {
|
|
21
|
+
getDevelopUpdateProjectFromRepositoryConfig,
|
|
22
|
+
} = require('../config/develop.update.project.from.repository');
|
|
23
|
+
|
|
24
|
+
const { HttpsProxyAgent } = agent;
|
|
25
|
+
|
|
26
|
+
const zipFileName = 'repositorySource';
|
|
27
|
+
|
|
28
|
+
function clearResource() {
|
|
29
|
+
const removeSourceFolderCmd = `rimraf ${resolvePath(`./temp/source/`)}`;
|
|
30
|
+
|
|
31
|
+
promptInfo(`remove folder: "./temp/source/"`);
|
|
32
|
+
|
|
33
|
+
exec(removeSourceFolderCmd);
|
|
34
|
+
|
|
35
|
+
const removeZipFolderCmd = `rimraf ${resolvePath(`./temp/zip/`)}`;
|
|
36
|
+
|
|
37
|
+
promptInfo(`remove folder: "./temp/zip/"`);
|
|
38
|
+
|
|
39
|
+
exec(removeZipFolderCmd);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function handlePackage({
|
|
43
|
+
projectPath,
|
|
44
|
+
zipPath,
|
|
45
|
+
sourcePath,
|
|
46
|
+
targetPath,
|
|
47
|
+
folders,
|
|
48
|
+
files,
|
|
49
|
+
}) {
|
|
50
|
+
const unzipPath = resolvePath(`./temp/source/`);
|
|
51
|
+
|
|
52
|
+
zip.unzip(zipPath, unzipPath, () => {
|
|
53
|
+
promptSuccess(`unzip success.`);
|
|
54
|
+
|
|
55
|
+
promptTip('repository zip file unzip to path', unzipPath);
|
|
56
|
+
|
|
57
|
+
const projectPathAdjust = resolvePath(projectPath);
|
|
58
|
+
|
|
59
|
+
promptInfo(`target project path: "${projectPathAdjust}".`);
|
|
60
|
+
|
|
61
|
+
const sourceMainPath = `./temp/source/${sourcePath}`;
|
|
62
|
+
const targetMainPath = `${projectPath}/${targetPath}`;
|
|
63
|
+
|
|
64
|
+
promptLine();
|
|
65
|
+
|
|
66
|
+
for (const itemFolder of folders) {
|
|
67
|
+
copyFolderSync({
|
|
68
|
+
sourceMainPath,
|
|
69
|
+
targetMainPath,
|
|
70
|
+
filepath: itemFolder,
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
for (const itemFile of files) {
|
|
75
|
+
copyFileSync({
|
|
76
|
+
sourceMainPath,
|
|
77
|
+
targetMainPath,
|
|
78
|
+
filepath: itemFile,
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
clearResource();
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
async function handleTempPackagePath({ agent, packageUrl, repo }) {
|
|
87
|
+
let zipPath = '';
|
|
88
|
+
|
|
89
|
+
let agentInfo = '';
|
|
90
|
+
|
|
91
|
+
if (checkStringIsEmpty(agent)) {
|
|
92
|
+
agentInfo = `download with none agent`;
|
|
93
|
+
} else {
|
|
94
|
+
agentInfo = `download with agent "${agent}"`;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
promptInfo(
|
|
98
|
+
`try master management template ${repo} repository, ${agentInfo}.`,
|
|
99
|
+
);
|
|
100
|
+
|
|
101
|
+
if (agent) {
|
|
102
|
+
promptSuccess(`agent: ${agent}`);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
promptInfo(`${repo} repository: "${packageUrl}".`);
|
|
106
|
+
|
|
107
|
+
await download(packageUrl, resolvePath(`./temp/zip`), {
|
|
108
|
+
...(agent
|
|
109
|
+
? {
|
|
110
|
+
agent: {
|
|
111
|
+
https: new HttpsProxyAgent({
|
|
112
|
+
keepAlive: true,
|
|
113
|
+
keepAliveMsecs: 1000,
|
|
114
|
+
maxSockets: 256,
|
|
115
|
+
maxFreeSockets: 256,
|
|
116
|
+
scheduling: 'lifo',
|
|
117
|
+
proxy: agent,
|
|
118
|
+
}),
|
|
119
|
+
},
|
|
120
|
+
}
|
|
121
|
+
: {}),
|
|
122
|
+
filename: `${zipFileName}.zip`,
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
promptSuccess(`download zip from ${repo} repository success!`);
|
|
126
|
+
|
|
127
|
+
zipPath = resolvePath(`./temp/zip/${zipFileName}.zip`);
|
|
128
|
+
|
|
129
|
+
promptInfo(`master template zip file Path: "${zipPath}".`);
|
|
130
|
+
|
|
131
|
+
return zipPath;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
async function updateProjectFromRepository({ projectPath = '.', agent }) {
|
|
135
|
+
clearResource();
|
|
136
|
+
|
|
137
|
+
const {
|
|
138
|
+
repository = '',
|
|
139
|
+
sourcePath = '',
|
|
140
|
+
targetPath = '',
|
|
141
|
+
folders = [],
|
|
142
|
+
files = [],
|
|
143
|
+
} = {
|
|
144
|
+
repository: '',
|
|
145
|
+
sourcePath: '',
|
|
146
|
+
targetPath: '',
|
|
147
|
+
folders: [],
|
|
148
|
+
files: [],
|
|
149
|
+
...getDevelopUpdateProjectFromRepositoryConfig(),
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
const repositoryRemoteUrl = repository;
|
|
153
|
+
|
|
154
|
+
if (checkStringIsEmpty(repositoryRemoteUrl)) {
|
|
155
|
+
promptError('please input primary remote package.json url');
|
|
156
|
+
|
|
157
|
+
exit();
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
let zipPath = '';
|
|
161
|
+
|
|
162
|
+
promptSuccess(`prepare to update from master template: `);
|
|
163
|
+
|
|
164
|
+
promptLine();
|
|
165
|
+
|
|
166
|
+
try {
|
|
167
|
+
zipPath = await handleTempPackagePath({
|
|
168
|
+
agent,
|
|
169
|
+
packageUrl: repositoryRemoteUrl,
|
|
170
|
+
repo: 'github',
|
|
171
|
+
});
|
|
172
|
+
} catch (error) {
|
|
173
|
+
if (checkStringIsEmpty(repositoryRemoteUrl)) {
|
|
174
|
+
promptError('please input repository remote url');
|
|
175
|
+
|
|
176
|
+
exit();
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
promptLine();
|
|
180
|
+
|
|
181
|
+
promptWarn(`use github repository failure! `);
|
|
182
|
+
|
|
183
|
+
promptLine();
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
handlePackage({
|
|
187
|
+
projectPath,
|
|
188
|
+
zipPath,
|
|
189
|
+
sourcePath,
|
|
190
|
+
targetPath,
|
|
191
|
+
folders,
|
|
192
|
+
files,
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
module.exports = { updateProjectFromRepository };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function run(s: any, o: any): void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function run(s: any, o: any): Promise<void>;
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
const download = require('download-git-repo');
|
|
2
|
-
|
|
3
|
-
const {
|
|
4
|
-
promptError,
|
|
5
|
-
exit,
|
|
6
|
-
checkStringIsEmpty,
|
|
7
|
-
promptWarn,
|
|
8
|
-
mkdirSync,
|
|
9
|
-
existDirectorySync,
|
|
10
|
-
promptInfo,
|
|
11
|
-
resolvePath,
|
|
12
|
-
promptSuccess,
|
|
13
|
-
} = require('../tools/meta');
|
|
14
|
-
|
|
15
|
-
exports.run = function (s, o) {
|
|
16
|
-
const {
|
|
17
|
-
_optionValues: { templateUrl, folder, exampleUrl = '' },
|
|
18
|
-
} = o;
|
|
19
|
-
|
|
20
|
-
if (checkStringIsEmpty(folder)) {
|
|
21
|
-
promptWarn('Please enter project folder name');
|
|
22
|
-
|
|
23
|
-
exit();
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
if (checkStringIsEmpty(folder)) {
|
|
27
|
-
promptWarn('project folder name not allow empty');
|
|
28
|
-
|
|
29
|
-
exit();
|
|
30
|
-
} else {
|
|
31
|
-
const templateUrlAdjust = checkStringIsEmpty(templateUrl)
|
|
32
|
-
? 'kityandhero/mono-antd-management-fast-master-template'
|
|
33
|
-
: templateUrl;
|
|
34
|
-
|
|
35
|
-
const folderPath = resolvePath(`./${folder}`);
|
|
36
|
-
|
|
37
|
-
if (existDirectorySync(folderPath)) {
|
|
38
|
-
promptWarn('project folder already exist, please choose another');
|
|
39
|
-
|
|
40
|
-
exit();
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
mkdirSync(folderPath);
|
|
44
|
-
|
|
45
|
-
promptInfo(`template url:${templateUrlAdjust}`);
|
|
46
|
-
promptInfo(`folder:${folder}`);
|
|
47
|
-
promptInfo('download will start, please wait a moment...');
|
|
48
|
-
|
|
49
|
-
download(templateUrlAdjust, folderPath, { clone: false }, (err) => {
|
|
50
|
-
if (!err) {
|
|
51
|
-
promptSuccess('download success');
|
|
52
|
-
|
|
53
|
-
if (!checkStringIsEmpty(exampleUrl)) {
|
|
54
|
-
promptInfo(`we build a example project repo is here: ${exampleUrl}`);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
promptInfo('please modify info in package.json file');
|
|
58
|
-
} else {
|
|
59
|
-
promptError(err);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
exit();
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
};
|
|
@@ -1,274 +0,0 @@
|
|
|
1
|
-
const download = require('download');
|
|
2
|
-
const agent = require('hpagent');
|
|
3
|
-
const zip = require('cross-zip');
|
|
4
|
-
|
|
5
|
-
const {
|
|
6
|
-
promptSuccess,
|
|
7
|
-
promptLine,
|
|
8
|
-
promptError,
|
|
9
|
-
promptWarn,
|
|
10
|
-
exit,
|
|
11
|
-
resolvePath,
|
|
12
|
-
checkStringIsEmpty,
|
|
13
|
-
promptInfo,
|
|
14
|
-
exec,
|
|
15
|
-
copyFileSync,
|
|
16
|
-
copyFolderSync,
|
|
17
|
-
} = require('./meta');
|
|
18
|
-
|
|
19
|
-
const { HttpsProxyAgent } = agent;
|
|
20
|
-
|
|
21
|
-
function clearResource() {
|
|
22
|
-
const removeSourceFolderCmd = `rimraf ${resolvePath(`./temp/source/`)}`;
|
|
23
|
-
|
|
24
|
-
promptInfo(`remove folder: "./temp/source/"`);
|
|
25
|
-
|
|
26
|
-
exec(removeSourceFolderCmd);
|
|
27
|
-
|
|
28
|
-
const removeZipFolderCmd = `rimraf ${resolvePath(`./temp/zip/`)}`;
|
|
29
|
-
|
|
30
|
-
promptInfo(`remove folder: "./temp/zip/"`);
|
|
31
|
-
|
|
32
|
-
exec(removeZipFolderCmd);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
function handlePackage(projectPath, zipPath) {
|
|
36
|
-
const unzipPath = resolvePath(`./temp/source/`);
|
|
37
|
-
|
|
38
|
-
zip.unzip(zipPath, unzipPath, () => {
|
|
39
|
-
promptSuccess(`unzip success.`);
|
|
40
|
-
|
|
41
|
-
promptInfo(
|
|
42
|
-
`master template zip unzip to path: "${resolvePath(`./temp/source/mono-antd-management-fast-master-template-main`)}".`,
|
|
43
|
-
);
|
|
44
|
-
|
|
45
|
-
const projectPathAdjust = resolvePath(projectPath);
|
|
46
|
-
|
|
47
|
-
promptInfo(`target project path: "${projectPathAdjust}".`);
|
|
48
|
-
|
|
49
|
-
const sourceMainPath = `./temp/source/mono-antd-management-fast-master-template-main/packages/master-management/`;
|
|
50
|
-
const targetMainPath = `${projectPath}/packages/master-management/`;
|
|
51
|
-
|
|
52
|
-
promptLine();
|
|
53
|
-
|
|
54
|
-
copyFileSync({
|
|
55
|
-
sourceMainPath,
|
|
56
|
-
targetMainPath,
|
|
57
|
-
filepath: 'config/router.master.template.config.js',
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
copyFolderSync({
|
|
61
|
-
sourceMainPath,
|
|
62
|
-
targetMainPath,
|
|
63
|
-
filepath: 'generatorConfig/general/',
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
copyFileSync({
|
|
67
|
-
sourceMainPath,
|
|
68
|
-
targetMainPath,
|
|
69
|
-
filepath: 'src/commonAssist/Action/actionGeneral.js',
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
copyFolderSync({
|
|
73
|
-
sourceMainPath,
|
|
74
|
-
targetMainPath,
|
|
75
|
-
filepath: 'src/components/PageLoading/',
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
copyFolderSync({
|
|
79
|
-
sourceMainPath,
|
|
80
|
-
targetMainPath,
|
|
81
|
-
filepath: 'src/customConfig/general/',
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
copyFolderSync({
|
|
85
|
-
sourceMainPath,
|
|
86
|
-
targetMainPath,
|
|
87
|
-
filepath: 'src/customSpecialComponents/BaseUpdateRoleModal/',
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
copyFileSync({
|
|
91
|
-
sourceMainPath,
|
|
92
|
-
targetMainPath,
|
|
93
|
-
filepath: 'src/customSpecialComponents/CustomAssembly/menuHeader.js',
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
copyFileSync({
|
|
97
|
-
sourceMainPath,
|
|
98
|
-
targetMainPath,
|
|
99
|
-
filepath: 'src/customSpecialComponents/CustomAssembly/timeAndOperator.js',
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
copyFolderSync({
|
|
103
|
-
sourceMainPath,
|
|
104
|
-
targetMainPath,
|
|
105
|
-
filepath: 'src/customSpecialComponents/UpdateModuleModalBase/',
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
copyFileSync({
|
|
109
|
-
sourceMainPath,
|
|
110
|
-
targetMainPath,
|
|
111
|
-
filepath: 'src/localeConfig/general/zh-CN/menu.js',
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
-
copyFileSync({
|
|
115
|
-
sourceMainPath,
|
|
116
|
-
targetMainPath,
|
|
117
|
-
filepath: 'src/locales/zh-CN/menu.js',
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
copyFolderSync({
|
|
121
|
-
sourceMainPath,
|
|
122
|
-
targetMainPath,
|
|
123
|
-
filepath: 'src/pageBases/',
|
|
124
|
-
});
|
|
125
|
-
|
|
126
|
-
copyFolderSync({
|
|
127
|
-
sourceMainPath,
|
|
128
|
-
targetMainPath,
|
|
129
|
-
filepath: 'src/pages/',
|
|
130
|
-
});
|
|
131
|
-
|
|
132
|
-
copyFileSync({
|
|
133
|
-
sourceMainPath,
|
|
134
|
-
targetMainPath,
|
|
135
|
-
filepath: 'src/utils/init.js',
|
|
136
|
-
});
|
|
137
|
-
|
|
138
|
-
copyFileSync({
|
|
139
|
-
sourceMainPath,
|
|
140
|
-
targetMainPath,
|
|
141
|
-
filepath: 'src/utils/tools.jsx',
|
|
142
|
-
});
|
|
143
|
-
|
|
144
|
-
copyFileSync({
|
|
145
|
-
sourceMainPath,
|
|
146
|
-
targetMainPath,
|
|
147
|
-
filepath: 'src/access.js',
|
|
148
|
-
});
|
|
149
|
-
|
|
150
|
-
copyFileSync({
|
|
151
|
-
sourceMainPath,
|
|
152
|
-
targetMainPath,
|
|
153
|
-
filepath: 'src/app.jsx',
|
|
154
|
-
});
|
|
155
|
-
|
|
156
|
-
copyFileSync({
|
|
157
|
-
sourceMainPath,
|
|
158
|
-
targetMainPath,
|
|
159
|
-
filepath: 'src/global.less',
|
|
160
|
-
});
|
|
161
|
-
|
|
162
|
-
copyFileSync({
|
|
163
|
-
sourceMainPath,
|
|
164
|
-
targetMainPath,
|
|
165
|
-
filepath: 'src/overrides.less',
|
|
166
|
-
});
|
|
167
|
-
|
|
168
|
-
copyFileSync({
|
|
169
|
-
sourceMainPath,
|
|
170
|
-
targetMainPath,
|
|
171
|
-
filepath: 'plugin.ts',
|
|
172
|
-
});
|
|
173
|
-
|
|
174
|
-
copyFileSync({
|
|
175
|
-
sourceMainPath,
|
|
176
|
-
targetMainPath,
|
|
177
|
-
filepath: 'tsconfig.json',
|
|
178
|
-
});
|
|
179
|
-
|
|
180
|
-
clearResource();
|
|
181
|
-
});
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
async function handleTempPackagePath({ agent, packageUrl, repo }) {
|
|
185
|
-
let zipPath = '';
|
|
186
|
-
|
|
187
|
-
let agentInfo = '';
|
|
188
|
-
|
|
189
|
-
if (checkStringIsEmpty(agent)) {
|
|
190
|
-
agentInfo = `download with none agent`;
|
|
191
|
-
} else {
|
|
192
|
-
agentInfo = `download with agent "${agent}"`;
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
promptInfo(
|
|
196
|
-
`try master management template ${repo} repository, ${agentInfo}.`,
|
|
197
|
-
);
|
|
198
|
-
|
|
199
|
-
if (agent) {
|
|
200
|
-
promptSuccess(`agent: ${agent}`);
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
promptInfo(`${repo} repository: "${packageUrl}".`);
|
|
204
|
-
|
|
205
|
-
await download(packageUrl, resolvePath(`./temp/zip`), {
|
|
206
|
-
...(agent
|
|
207
|
-
? {
|
|
208
|
-
agent: {
|
|
209
|
-
https: new HttpsProxyAgent({
|
|
210
|
-
keepAlive: true,
|
|
211
|
-
keepAliveMsecs: 1000,
|
|
212
|
-
maxSockets: 256,
|
|
213
|
-
maxFreeSockets: 256,
|
|
214
|
-
scheduling: 'lifo',
|
|
215
|
-
proxy: agent,
|
|
216
|
-
}),
|
|
217
|
-
},
|
|
218
|
-
}
|
|
219
|
-
: {}),
|
|
220
|
-
});
|
|
221
|
-
|
|
222
|
-
promptSuccess(`download zip from ${repo} repository success!`);
|
|
223
|
-
|
|
224
|
-
zipPath = resolvePath(
|
|
225
|
-
`./temp/zip/mono-antd-management-fast-master-template-main.zip`,
|
|
226
|
-
);
|
|
227
|
-
|
|
228
|
-
promptInfo(`master template zip file Path: "${zipPath}".`);
|
|
229
|
-
|
|
230
|
-
return zipPath;
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
async function updateProjectFromRepository({ projectPath = '.', agent }) {
|
|
234
|
-
clearResource();
|
|
235
|
-
|
|
236
|
-
const repositoryRemoteUrl =
|
|
237
|
-
'https://codeload.github.com/kityandhero/mono-antd-management-fast-master-template/zip/refs/heads/main';
|
|
238
|
-
|
|
239
|
-
if (checkStringIsEmpty(repositoryRemoteUrl)) {
|
|
240
|
-
promptError('please input primary remote package.json url');
|
|
241
|
-
|
|
242
|
-
exit();
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
let zipPath = '';
|
|
246
|
-
|
|
247
|
-
promptSuccess(`prepare to update from master template: `);
|
|
248
|
-
|
|
249
|
-
promptLine();
|
|
250
|
-
|
|
251
|
-
try {
|
|
252
|
-
zipPath = await handleTempPackagePath({
|
|
253
|
-
agent,
|
|
254
|
-
packageUrl: repositoryRemoteUrl,
|
|
255
|
-
repo: 'github',
|
|
256
|
-
});
|
|
257
|
-
} catch (error) {
|
|
258
|
-
if (checkStringIsEmpty(repositoryRemoteUrl)) {
|
|
259
|
-
promptError('please input repository remote url');
|
|
260
|
-
|
|
261
|
-
exit();
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
promptLine();
|
|
265
|
-
|
|
266
|
-
promptWarn(`use github repository failure! `);
|
|
267
|
-
|
|
268
|
-
promptLine();
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
handlePackage(projectPath, zipPath);
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
module.exports = { updateProjectFromRepository };
|