@pisell/common 0.0.17 → 0.0.18-1
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/es/config/index.d.ts +30 -0
- package/es/script/utils/index.js +2 -1
- package/lib/config/index.d.ts +30 -0
- package/lib/script/utils/index.js +7 -6
- package/package.json +1 -1
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export declare type PisellConfigType = {
|
|
2
|
+
ENV: {
|
|
3
|
+
host: string;
|
|
4
|
+
socket: string;
|
|
5
|
+
helpHost: string;
|
|
6
|
+
boxlocal_h5: string;
|
|
7
|
+
accounts: string;
|
|
8
|
+
domain: string;
|
|
9
|
+
googleMap: string;
|
|
10
|
+
appCenter: string;
|
|
11
|
+
static: string;
|
|
12
|
+
};
|
|
13
|
+
/** 当前主项目类型 */
|
|
14
|
+
platform: 'shop' | string;
|
|
15
|
+
/** 包内请求 由主项目注入 */
|
|
16
|
+
request: {
|
|
17
|
+
get: RequestMethod;
|
|
18
|
+
post: RequestMethod;
|
|
19
|
+
put: RequestMethod;
|
|
20
|
+
remove: RequestMethod;
|
|
21
|
+
request: RequestMethod;
|
|
22
|
+
};
|
|
23
|
+
/** 消息通知url */
|
|
24
|
+
webhookUrl?: string;
|
|
25
|
+
};
|
|
26
|
+
export interface RequestMethod {
|
|
27
|
+
<T = any>(url: string, data?: Record<string, any>, config?: any): Promise<T>;
|
|
28
|
+
}
|
|
29
|
+
export declare const initConfig: (options: PisellConfigType) => void;
|
|
30
|
+
export declare const getConfig: () => PisellConfigType;
|
package/es/script/utils/index.js
CHANGED
|
@@ -5,6 +5,7 @@ function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(
|
|
|
5
5
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
6
6
|
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
7
7
|
import * as dotenv from 'dotenv';
|
|
8
|
+
import path from 'path';
|
|
8
9
|
import ssh2 from 'ssh2';
|
|
9
10
|
|
|
10
11
|
/**
|
|
@@ -237,7 +238,7 @@ var versionSort = function versionSort(versionList) {
|
|
|
237
238
|
* @returns {*}
|
|
238
239
|
*/
|
|
239
240
|
var getCurrentProjectName = function getCurrentProjectName() {
|
|
240
|
-
return loadJSON(
|
|
241
|
+
return loadJSON(path.join(process.cwd(), './package.json')).name;
|
|
241
242
|
};
|
|
242
243
|
var loadJSON = function loadJSON(path) {
|
|
243
244
|
return JSON.parse(fs.readFileSync(new URL(path, import.meta.url)));
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export declare type PisellConfigType = {
|
|
2
|
+
ENV: {
|
|
3
|
+
host: string;
|
|
4
|
+
socket: string;
|
|
5
|
+
helpHost: string;
|
|
6
|
+
boxlocal_h5: string;
|
|
7
|
+
accounts: string;
|
|
8
|
+
domain: string;
|
|
9
|
+
googleMap: string;
|
|
10
|
+
appCenter: string;
|
|
11
|
+
static: string;
|
|
12
|
+
};
|
|
13
|
+
/** 当前主项目类型 */
|
|
14
|
+
platform: 'shop' | string;
|
|
15
|
+
/** 包内请求 由主项目注入 */
|
|
16
|
+
request: {
|
|
17
|
+
get: RequestMethod;
|
|
18
|
+
post: RequestMethod;
|
|
19
|
+
put: RequestMethod;
|
|
20
|
+
remove: RequestMethod;
|
|
21
|
+
request: RequestMethod;
|
|
22
|
+
};
|
|
23
|
+
/** 消息通知url */
|
|
24
|
+
webhookUrl?: string;
|
|
25
|
+
};
|
|
26
|
+
export interface RequestMethod {
|
|
27
|
+
<T = any>(url: string, data?: Record<string, any>, config?: any): Promise<T>;
|
|
28
|
+
}
|
|
29
|
+
export declare const initConfig: (options: PisellConfigType) => void;
|
|
30
|
+
export declare const getConfig: () => PisellConfigType;
|
|
@@ -44,6 +44,7 @@ __export(utils_exports, {
|
|
|
44
44
|
});
|
|
45
45
|
module.exports = __toCommonJS(utils_exports);
|
|
46
46
|
var dotenv = __toESM(require("dotenv"));
|
|
47
|
+
var import_path = __toESM(require("path"));
|
|
47
48
|
var import_ssh2 = __toESM(require("ssh2"));
|
|
48
49
|
var import_meta = {};
|
|
49
50
|
var isWorkingTreeClean = async () => {
|
|
@@ -112,7 +113,7 @@ var serverUpload = (conn, { localPath, remotePath }) => {
|
|
|
112
113
|
});
|
|
113
114
|
});
|
|
114
115
|
};
|
|
115
|
-
var serverUnpack = (conn, { path, fileName, fullFileName, changelog }) => {
|
|
116
|
+
var serverUnpack = (conn, { path: path2, fileName, fullFileName, changelog }) => {
|
|
116
117
|
if (!conn)
|
|
117
118
|
return Promise.reject("未连接服务器");
|
|
118
119
|
return new Promise((resolve, reject) => {
|
|
@@ -124,7 +125,7 @@ var serverUnpack = (conn, { path, fileName, fullFileName, changelog }) => {
|
|
|
124
125
|
}
|
|
125
126
|
stream.end(
|
|
126
127
|
`
|
|
127
|
-
cd ${
|
|
128
|
+
cd ${path2}
|
|
128
129
|
unzip ${fullFileName} -d ${fileName} && mv ${fileName}/dist/* ${fileName}/ && rmdir ${fileName}/dist
|
|
129
130
|
rm -rf ${fullFileName}
|
|
130
131
|
echo "${changelog}" > ./${fileName}/changelog.md
|
|
@@ -145,7 +146,7 @@ var serverUnpack = (conn, { path, fileName, fullFileName, changelog }) => {
|
|
|
145
146
|
});
|
|
146
147
|
});
|
|
147
148
|
};
|
|
148
|
-
var releaseProject = (conn, { path, fileName }) => {
|
|
149
|
+
var releaseProject = (conn, { path: path2, fileName }) => {
|
|
149
150
|
return new Promise((resolve, reject) => {
|
|
150
151
|
conn.shell((err, stream) => {
|
|
151
152
|
if (err) {
|
|
@@ -155,7 +156,7 @@ var releaseProject = (conn, { path, fileName }) => {
|
|
|
155
156
|
}
|
|
156
157
|
stream.end(
|
|
157
158
|
`
|
|
158
|
-
cd ${
|
|
159
|
+
cd ${path2}
|
|
159
160
|
cp -R -f pre-master next-master
|
|
160
161
|
rm -rf pre-master
|
|
161
162
|
\\cp -R -f ${fileName}/* next-master
|
|
@@ -197,9 +198,9 @@ var versionSort = (versionList) => {
|
|
|
197
198
|
});
|
|
198
199
|
};
|
|
199
200
|
var getCurrentProjectName = () => {
|
|
200
|
-
return loadJSON(
|
|
201
|
+
return loadJSON(import_path.default.join(process.cwd(), "./package.json")).name;
|
|
201
202
|
};
|
|
202
|
-
var loadJSON = (
|
|
203
|
+
var loadJSON = (path2) => JSON.parse(fs.readFileSync(new URL(path2, import_meta.url)));
|
|
203
204
|
var getCurrentUserName = async () => {
|
|
204
205
|
const { stdout } = await $`git config user.name`;
|
|
205
206
|
return stdout;
|