@ldsg/utils 0.0.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/LICENSE +22 -0
- package/README.md +3 -0
- package/dist/extend-app-data.d.ts +9 -0
- package/dist/extend-app-data.d.ts.map +1 -0
- package/dist/extend-app-data.js +29 -0
- package/dist/fetch-app-data.d.ts +8 -0
- package/dist/fetch-app-data.d.ts.map +1 -0
- package/dist/fetch-app-data.js +25 -0
- package/dist/generate-by-app-data.d.ts +9 -0
- package/dist/generate-by-app-data.d.ts.map +1 -0
- package/dist/generate-by-app-data.js +25 -0
- package/dist/generate.d.ts +9 -0
- package/dist/generate.d.ts.map +1 -0
- package/dist/generate.js +20 -0
- package/dist/get-app-data.d.ts +9 -0
- package/dist/get-app-data.d.ts.map +1 -0
- package/dist/get-app-data.js +24 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +21 -0
- package/package.json +43 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2014-present Sebastian McKenzie and other contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
6
|
+
a copy of this software and associated documentation files (the
|
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
11
|
+
the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be
|
|
14
|
+
included in all copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { AppData } from "@ldsg/common";
|
|
2
|
+
export interface ExtendAppDataParams {
|
|
3
|
+
appData: AppData;
|
|
4
|
+
extraAppDataPath?: string;
|
|
5
|
+
}
|
|
6
|
+
type ExtendAppData = (params: ExtendAppDataParams) => Promise<AppData>;
|
|
7
|
+
export declare const extendAppData: ExtendAppData;
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=extend-app-data.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extend-app-data.d.ts","sourceRoot":"","sources":["../src/extend-app-data.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAGvC,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,OAAO,CAAC;IACjB,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED,KAAK,aAAa,GAAG,CAAC,MAAM,EAAE,mBAAmB,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;AAEvE,eAAO,MAAM,aAAa,EAAE,aAmB3B,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.extendAppData = void 0;
|
|
16
|
+
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
17
|
+
const extendAppData = (params) => __awaiter(void 0, void 0, void 0, function* () {
|
|
18
|
+
const { appData, extraAppDataPath } = params;
|
|
19
|
+
let extraAppData = {};
|
|
20
|
+
if (extraAppDataPath) {
|
|
21
|
+
const existsRes = yield fs_extra_1.default.exists(extraAppDataPath);
|
|
22
|
+
if (existsRes) {
|
|
23
|
+
extraAppData = yield fs_extra_1.default.readJson(extraAppDataPath);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
const res = Object.assign(Object.assign({}, extraAppData), appData);
|
|
27
|
+
return res;
|
|
28
|
+
});
|
|
29
|
+
exports.extendAppData = extendAppData;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { AppData } from "@ldsg/common";
|
|
2
|
+
export interface FetchAppDataParams {
|
|
3
|
+
lgsgAppDataUrl: string;
|
|
4
|
+
}
|
|
5
|
+
type FetchAppData = (params: FetchAppDataParams) => Promise<AppData>;
|
|
6
|
+
export declare const fetchAppData: FetchAppData;
|
|
7
|
+
export {};
|
|
8
|
+
//# sourceMappingURL=fetch-app-data.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fetch-app-data.d.ts","sourceRoot":"","sources":["../src/fetch-app-data.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAGvC,MAAM,WAAW,kBAAkB;IACjC,cAAc,EAAE,MAAM,CAAC;CACxB;AAED,KAAK,YAAY,GAAG,CAAC,MAAM,EAAE,kBAAkB,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;AAErE,eAAO,MAAM,YAAY,EAAE,YAU1B,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.fetchAppData = void 0;
|
|
16
|
+
const axios_1 = __importDefault(require("axios"));
|
|
17
|
+
const fetchAppData = (params) => __awaiter(void 0, void 0, void 0, function* () {
|
|
18
|
+
const { lgsgAppDataUrl: url } = params;
|
|
19
|
+
const axiosRes = yield (0, axios_1.default)({
|
|
20
|
+
url,
|
|
21
|
+
});
|
|
22
|
+
const res = axiosRes.data;
|
|
23
|
+
return res;
|
|
24
|
+
});
|
|
25
|
+
exports.fetchAppData = fetchAppData;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { AppData } from "@ldsg/common";
|
|
2
|
+
interface GenerateByAppDataParams {
|
|
3
|
+
appData: AppData;
|
|
4
|
+
outputPath: string;
|
|
5
|
+
}
|
|
6
|
+
type GenerateByAppData = (params: GenerateByAppDataParams) => Promise<void>;
|
|
7
|
+
export declare const generateByAppData: GenerateByAppData;
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=generate-by-app-data.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate-by-app-data.d.ts","sourceRoot":"","sources":["../src/generate-by-app-data.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAc,MAAM,cAAc,CAAC;AAGnD,UAAU,uBAAuB;IAC/B,OAAO,EAAE,OAAO,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,KAAK,iBAAiB,GAAG,CAAC,MAAM,EAAE,uBAAuB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;AAE5E,eAAO,MAAM,iBAAiB,EAAE,iBAa/B,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.generateByAppData = void 0;
|
|
16
|
+
const common_1 = require("@ldsg/common");
|
|
17
|
+
const adm_zip_1 = __importDefault(require("adm-zip"));
|
|
18
|
+
const generateByAppData = (params) => __awaiter(void 0, void 0, void 0, function* () {
|
|
19
|
+
const { appData, outputPath } = params;
|
|
20
|
+
const zipAppDataRes = yield (0, common_1.zipAppData)(Object.assign(Object.assign({}, appData), { type: "nodebuffer" }));
|
|
21
|
+
const { archive } = zipAppDataRes;
|
|
22
|
+
const admZip = new adm_zip_1.default(archive);
|
|
23
|
+
admZip.extractAllTo(outputPath, true);
|
|
24
|
+
});
|
|
25
|
+
exports.generateByAppData = generateByAppData;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
interface GenerateParams {
|
|
2
|
+
lgsgAppDataUrl: string;
|
|
3
|
+
outputPath: string;
|
|
4
|
+
extraAppDataPath?: string;
|
|
5
|
+
}
|
|
6
|
+
type Generate = (params: GenerateParams) => Promise<void>;
|
|
7
|
+
export declare const generate: Generate;
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=generate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../src/generate.ts"],"names":[],"mappings":"AAIA,UAAU,cAAc;IACtB,cAAc,EAAE,MAAM,CAAC;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED,KAAK,QAAQ,GAAG,CAAC,MAAM,EAAE,cAAc,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;AAE1D,eAAO,MAAM,QAAQ,EAAE,QAMtB,CAAC"}
|
package/dist/generate.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.generate = void 0;
|
|
13
|
+
const generate_by_app_data_1 = require("./generate-by-app-data");
|
|
14
|
+
const get_app_data_1 = require("./get-app-data");
|
|
15
|
+
const generate = (params) => __awaiter(void 0, void 0, void 0, function* () {
|
|
16
|
+
const { outputPath } = params;
|
|
17
|
+
const appData = yield (0, get_app_data_1.getAppData)(params);
|
|
18
|
+
yield (0, generate_by_app_data_1.generateByAppData)({ appData, outputPath });
|
|
19
|
+
});
|
|
20
|
+
exports.generate = generate;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { AppData } from "@ldsg/common";
|
|
2
|
+
import { FetchAppDataParams } from "./fetch-app-data";
|
|
3
|
+
interface GetAppDataParams extends FetchAppDataParams {
|
|
4
|
+
extraAppDataPath?: string;
|
|
5
|
+
}
|
|
6
|
+
type GetAppData = (params: GetAppDataParams) => Promise<AppData>;
|
|
7
|
+
export declare const getAppData: GetAppData;
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=get-app-data.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-app-data.d.ts","sourceRoot":"","sources":["../src/get-app-data.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,OAAO,EAAgB,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAEpE,UAAU,gBAAiB,SAAQ,kBAAkB;IACnD,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED,KAAK,UAAU,GAAG,CAAC,MAAM,EAAE,gBAAgB,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;AAEjE,eAAO,MAAM,UAAU,EAAE,UAWxB,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.getAppData = void 0;
|
|
13
|
+
const extend_app_data_1 = require("./extend-app-data");
|
|
14
|
+
const fetch_app_data_1 = require("./fetch-app-data");
|
|
15
|
+
const getAppData = (params) => __awaiter(void 0, void 0, void 0, function* () {
|
|
16
|
+
const { extraAppDataPath } = params;
|
|
17
|
+
const appData = yield (0, fetch_app_data_1.fetchAppData)(params);
|
|
18
|
+
const res = yield (0, extend_app_data_1.extendAppData)({
|
|
19
|
+
appData,
|
|
20
|
+
extraAppDataPath,
|
|
21
|
+
});
|
|
22
|
+
return res;
|
|
23
|
+
});
|
|
24
|
+
exports.getAppData = getAppData;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,YAAY,CAAC;AAC3B,cAAc,wBAAwB,CAAC;AACvC,cAAc,gBAAgB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./extend-app-data"), exports);
|
|
18
|
+
__exportStar(require("./fetch-app-data"), exports);
|
|
19
|
+
__exportStar(require("./generate"), exports);
|
|
20
|
+
__exportStar(require("./generate-by-app-data"), exports);
|
|
21
|
+
__exportStar(require("./get-app-data"), exports);
|
package/package.json
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ldsg/utils",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"main": "dist/index.js",
|
|
5
|
+
"files": [
|
|
6
|
+
"dist/"
|
|
7
|
+
],
|
|
8
|
+
"types": "dist",
|
|
9
|
+
"bin": {
|
|
10
|
+
"ldsg": "dist/index.js"
|
|
11
|
+
},
|
|
12
|
+
"scripts": {
|
|
13
|
+
"build": "rm -rf dist && tsc --project tsconfig.build.json"
|
|
14
|
+
},
|
|
15
|
+
"author": "wanxger",
|
|
16
|
+
"license": "ISC",
|
|
17
|
+
"description": "",
|
|
18
|
+
"dependencies": {
|
|
19
|
+
"@ldsg/app": "workspace:*",
|
|
20
|
+
"@ldsg/common": "workspace:*",
|
|
21
|
+
"@ldsg/services": "workspace:*",
|
|
22
|
+
"adm-zip": "^0.5.16",
|
|
23
|
+
"axios": "^1.7.7",
|
|
24
|
+
"commander": "^12.1.0",
|
|
25
|
+
"fs-extra": "^11.2.0",
|
|
26
|
+
"lodash": "^4.17.21"
|
|
27
|
+
},
|
|
28
|
+
"devDependencies": {
|
|
29
|
+
"@types/adm-zip": "^0.5.6",
|
|
30
|
+
"@types/fs-extra": "^11.0.4",
|
|
31
|
+
"@types/lodash": "^4.14.202",
|
|
32
|
+
"@types/node": "^20.13.0",
|
|
33
|
+
"@types/supertest": "^6.0.0",
|
|
34
|
+
"dotenv": "^16.4.5",
|
|
35
|
+
"supertest": "^6.3.4",
|
|
36
|
+
"ts-loader": "^9.5.1",
|
|
37
|
+
"ts-node": "^10.9.2",
|
|
38
|
+
"tslib": "^2.6.2",
|
|
39
|
+
"typescript": "^5.5.2",
|
|
40
|
+
"webpack": "^5.97.1",
|
|
41
|
+
"webpack-cli": "^5.1.4"
|
|
42
|
+
}
|
|
43
|
+
}
|