@superblocksteam/util 1.1.2 → 1.2.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.
|
@@ -28,6 +28,7 @@ export type SuperblocksConfig = SuperblocksMonorepoConfig | SuperblocksApplicati
|
|
|
28
28
|
* @param checkParentDir Whether to recursively check the parent directory for a Superblocks config file
|
|
29
29
|
*/
|
|
30
30
|
export declare function getSuperblocksMonorepoConfigJson(checkParentDir?: boolean, pathPrefix?: string): Promise<[SuperblocksMonorepoConfig, string]>;
|
|
31
|
-
export declare function getSuperblocksApplicationConfigJson(): Promise<SuperblocksApplicationConfig>;
|
|
31
|
+
export declare function getSuperblocksApplicationConfigJson(applicationPath?: string): Promise<SuperblocksApplicationConfig>;
|
|
32
|
+
export declare function getSuperblocksApplicationConfigIfExists(applicationPath: string): Promise<SuperblocksApplicationConfig | undefined>;
|
|
32
33
|
export declare function getSuperblocksBackendConfigJson(): Promise<SuperblocksBackendConfig>;
|
|
33
34
|
export declare function getSuperblocksResourceConfigIfExists(): Promise<SuperblocksResourceConfig | undefined>;
|
package/dist/resource-configs.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getSuperblocksResourceConfigIfExists = exports.getSuperblocksBackendConfigJson = exports.getSuperblocksApplicationConfigJson = exports.getSuperblocksMonorepoConfigJson = void 0;
|
|
3
|
+
exports.getSuperblocksResourceConfigIfExists = exports.getSuperblocksBackendConfigJson = exports.getSuperblocksApplicationConfigIfExists = exports.getSuperblocksApplicationConfigJson = exports.getSuperblocksMonorepoConfigJson = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const path_1 = tslib_1.__importDefault(require("path"));
|
|
6
6
|
const fs = tslib_1.__importStar(require("fs-extra"));
|
|
@@ -41,10 +41,13 @@ async function getSuperblocksMonorepoConfigJson(checkParentDir = false, pathPref
|
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
43
|
exports.getSuperblocksMonorepoConfigJson = getSuperblocksMonorepoConfigJson;
|
|
44
|
-
async function getSuperblocksApplicationConfigJson() {
|
|
44
|
+
async function getSuperblocksApplicationConfigJson(applicationPath) {
|
|
45
45
|
let superblocksConfig;
|
|
46
46
|
try {
|
|
47
|
-
|
|
47
|
+
const configPath = applicationPath
|
|
48
|
+
? path_1.default.join(applicationPath, constants_1.RESOURCE_CONFIG_PATH)
|
|
49
|
+
: constants_1.RESOURCE_CONFIG_PATH;
|
|
50
|
+
superblocksConfig = await fs.readJSON(configPath);
|
|
48
51
|
}
|
|
49
52
|
catch {
|
|
50
53
|
// no superblocks config file found
|
|
@@ -56,6 +59,23 @@ async function getSuperblocksApplicationConfigJson() {
|
|
|
56
59
|
return superblocksConfig;
|
|
57
60
|
}
|
|
58
61
|
exports.getSuperblocksApplicationConfigJson = getSuperblocksApplicationConfigJson;
|
|
62
|
+
async function getSuperblocksApplicationConfigIfExists(applicationPath) {
|
|
63
|
+
let superblocksConfig;
|
|
64
|
+
try {
|
|
65
|
+
const configPath = applicationPath
|
|
66
|
+
? path_1.default.join(applicationPath, constants_1.RESOURCE_CONFIG_PATH)
|
|
67
|
+
: constants_1.RESOURCE_CONFIG_PATH;
|
|
68
|
+
superblocksConfig = await fs.readJSON(configPath);
|
|
69
|
+
}
|
|
70
|
+
catch {
|
|
71
|
+
// no superblocks config file found
|
|
72
|
+
}
|
|
73
|
+
if ((superblocksConfig === null || superblocksConfig === void 0 ? void 0 : superblocksConfig.configType) !== "APPLICATION") {
|
|
74
|
+
return undefined;
|
|
75
|
+
}
|
|
76
|
+
return superblocksConfig;
|
|
77
|
+
}
|
|
78
|
+
exports.getSuperblocksApplicationConfigIfExists = getSuperblocksApplicationConfigIfExists;
|
|
59
79
|
async function getSuperblocksBackendConfigJson() {
|
|
60
80
|
let superblocksConfig;
|
|
61
81
|
try {
|
package/package.json
CHANGED
package/src/resource-configs.ts
CHANGED
|
@@ -84,10 +84,15 @@ export async function getSuperblocksMonorepoConfigJson(
|
|
|
84
84
|
}
|
|
85
85
|
}
|
|
86
86
|
|
|
87
|
-
export async function getSuperblocksApplicationConfigJson(
|
|
87
|
+
export async function getSuperblocksApplicationConfigJson(
|
|
88
|
+
applicationPath?: string
|
|
89
|
+
): Promise<SuperblocksApplicationConfig> {
|
|
88
90
|
let superblocksConfig;
|
|
89
91
|
try {
|
|
90
|
-
|
|
92
|
+
const configPath = applicationPath
|
|
93
|
+
? path.join(applicationPath, RESOURCE_CONFIG_PATH)
|
|
94
|
+
: RESOURCE_CONFIG_PATH;
|
|
95
|
+
superblocksConfig = await fs.readJSON(configPath);
|
|
91
96
|
} catch {
|
|
92
97
|
// no superblocks config file found
|
|
93
98
|
throw new Error(
|
|
@@ -104,6 +109,26 @@ export async function getSuperblocksApplicationConfigJson(): Promise<Superblocks
|
|
|
104
109
|
return superblocksConfig as SuperblocksApplicationConfig;
|
|
105
110
|
}
|
|
106
111
|
|
|
112
|
+
export async function getSuperblocksApplicationConfigIfExists(
|
|
113
|
+
applicationPath: string
|
|
114
|
+
): Promise<SuperblocksApplicationConfig | undefined> {
|
|
115
|
+
let superblocksConfig: SuperblocksApplicationConfig | undefined;
|
|
116
|
+
try {
|
|
117
|
+
const configPath = applicationPath
|
|
118
|
+
? path.join(applicationPath, RESOURCE_CONFIG_PATH)
|
|
119
|
+
: RESOURCE_CONFIG_PATH;
|
|
120
|
+
superblocksConfig = await fs.readJSON(configPath);
|
|
121
|
+
} catch {
|
|
122
|
+
// no superblocks config file found
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
if (superblocksConfig?.configType !== "APPLICATION") {
|
|
126
|
+
return undefined;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
return superblocksConfig as SuperblocksApplicationConfig;
|
|
130
|
+
}
|
|
131
|
+
|
|
107
132
|
export async function getSuperblocksBackendConfigJson(): Promise<SuperblocksBackendConfig> {
|
|
108
133
|
let superblocksConfig;
|
|
109
134
|
try {
|