@faasjs/load 2.8.1 → 3.0.0-canary.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/dist/index.d.mts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +10 -16
- package/dist/index.mjs +10 -16
- package/package.json +9 -9
package/dist/index.d.mts
CHANGED
|
@@ -25,7 +25,7 @@ declare class Config {
|
|
|
25
25
|
* @param root {string} 根目录
|
|
26
26
|
* @param filename {filename} 目标文件,用于读取目录层级
|
|
27
27
|
*/
|
|
28
|
-
declare function loadConfig(root: string, filename: string): Config;
|
|
28
|
+
declare function loadConfig(root: string, filename: string, staging: string): Config;
|
|
29
29
|
|
|
30
30
|
/**
|
|
31
31
|
* 加载 ts 文件
|
|
@@ -37,6 +37,8 @@ declare function loadConfig(root: string, filename: string): Config;
|
|
|
37
37
|
* @param options.tmp {boolean} 是否为临时文件,true 则生成的文件会被删除,默认为 false
|
|
38
38
|
* @param options.modules {object} 生成 modules 的配置
|
|
39
39
|
* @param options.modules.excludes {string[]} modules 中需排除的模块
|
|
40
|
+
*
|
|
41
|
+
* @deprecated
|
|
40
42
|
*/
|
|
41
43
|
declare function loadTs(filename: string, options?: {
|
|
42
44
|
input?: {
|
package/dist/index.d.ts
CHANGED
|
@@ -25,7 +25,7 @@ declare class Config {
|
|
|
25
25
|
* @param root {string} 根目录
|
|
26
26
|
* @param filename {filename} 目标文件,用于读取目录层级
|
|
27
27
|
*/
|
|
28
|
-
declare function loadConfig(root: string, filename: string): Config;
|
|
28
|
+
declare function loadConfig(root: string, filename: string, staging: string): Config;
|
|
29
29
|
|
|
30
30
|
/**
|
|
31
31
|
* 加载 ts 文件
|
|
@@ -37,6 +37,8 @@ declare function loadConfig(root: string, filename: string): Config;
|
|
|
37
37
|
* @param options.tmp {boolean} 是否为临时文件,true 则生成的文件会被删除,默认为 false
|
|
38
38
|
* @param options.modules {object} 生成 modules 的配置
|
|
39
39
|
* @param options.modules.excludes {string[]} modules 中需排除的模块
|
|
40
|
+
*
|
|
41
|
+
* @deprecated
|
|
40
42
|
*/
|
|
41
43
|
declare function loadTs(filename: string, options?: {
|
|
42
44
|
input?: {
|
package/dist/index.js
CHANGED
|
@@ -14,6 +14,10 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
|
|
|
14
14
|
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
15
15
|
});
|
|
16
16
|
var Config = class {
|
|
17
|
+
root;
|
|
18
|
+
filename;
|
|
19
|
+
origin;
|
|
20
|
+
defaults;
|
|
17
21
|
/**
|
|
18
22
|
* 创建配置类,并自动读取配置内容
|
|
19
23
|
*
|
|
@@ -32,12 +36,14 @@ var Config = class {
|
|
|
32
36
|
const root2 = path.join(base, path$1);
|
|
33
37
|
if (root2 === base) return base;
|
|
34
38
|
const faas = path.join(root2, "faas.yaml");
|
|
39
|
+
console.log(faas);
|
|
35
40
|
if (fs.existsSync(faas))
|
|
36
41
|
configs.push(
|
|
37
42
|
jsYaml.load(fs.readFileSync(faas).toString())
|
|
38
43
|
);
|
|
39
44
|
return root2;
|
|
40
45
|
});
|
|
46
|
+
console.log(configs);
|
|
41
47
|
this.origin = deep_merge.deepMerge(...configs);
|
|
42
48
|
this.defaults = deep_merge.deepMerge(this.origin.defaults || {});
|
|
43
49
|
for (const key in this.origin) {
|
|
@@ -48,24 +54,12 @@ var Config = class {
|
|
|
48
54
|
for (const pluginKey in data.plugins) {
|
|
49
55
|
const plugin = data.plugins[pluginKey];
|
|
50
56
|
plugin.name = pluginKey;
|
|
51
|
-
if (plugin.provider)
|
|
52
|
-
if (typeof plugin.provider === "string") {
|
|
53
|
-
if (!data.providers[plugin.provider])
|
|
54
|
-
throw Error(
|
|
55
|
-
`[faas.yaml] missing provider: ${plugin.provider} <${key}/plugins/${pluginKey}>`
|
|
56
|
-
);
|
|
57
|
-
plugin.provider = data.providers[plugin.provider];
|
|
58
|
-
} else
|
|
59
|
-
plugin.provider = deep_merge.deepMerge(
|
|
60
|
-
data.providers[plugin.provider],
|
|
61
|
-
plugin.provider
|
|
62
|
-
);
|
|
63
57
|
}
|
|
64
58
|
}
|
|
65
59
|
}
|
|
66
60
|
};
|
|
67
|
-
function loadConfig(root, filename) {
|
|
68
|
-
return new Config(root, filename);
|
|
61
|
+
function loadConfig(root, filename, staging) {
|
|
62
|
+
return new Config(root, filename)[staging] || /* @__PURE__ */ Object.create(null);
|
|
69
63
|
}
|
|
70
64
|
var FaasPackages = [
|
|
71
65
|
"@faasjs/cloud_function",
|
|
@@ -144,7 +138,7 @@ function swc(externalModules) {
|
|
|
144
138
|
};
|
|
145
139
|
}
|
|
146
140
|
async function loadTs(filename, options = /* @__PURE__ */ Object.create(null)) {
|
|
147
|
-
|
|
141
|
+
console.warn("[@faasjs/load] Will deprecated in v3.");
|
|
148
142
|
const PackageJSON = __require(`${process.cwd()}/package.json`);
|
|
149
143
|
const external = PackageJSON.dependencies ? Object.keys(PackageJSON.dependencies) : [];
|
|
150
144
|
if (options.modules && options.modules.excludes == null)
|
|
@@ -160,7 +154,7 @@ async function loadTs(filename, options = /* @__PURE__ */ Object.create(null)) {
|
|
|
160
154
|
);
|
|
161
155
|
const bundle2 = await rollup_js.rollup(input);
|
|
162
156
|
const dependencies = /* @__PURE__ */ Object.create(null);
|
|
163
|
-
for (const m of
|
|
157
|
+
for (const m of bundle2.cache?.modules || [])
|
|
164
158
|
for (const d of m.dependencies)
|
|
165
159
|
if (!d.startsWith("/") && !dependencies[d] && !tsTransform.NodeBuiltinModules.includes(d))
|
|
166
160
|
dependencies[d] = "*";
|
package/dist/index.mjs
CHANGED
|
@@ -12,6 +12,10 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
|
|
|
12
12
|
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
13
13
|
});
|
|
14
14
|
var Config = class {
|
|
15
|
+
root;
|
|
16
|
+
filename;
|
|
17
|
+
origin;
|
|
18
|
+
defaults;
|
|
15
19
|
/**
|
|
16
20
|
* 创建配置类,并自动读取配置内容
|
|
17
21
|
*
|
|
@@ -30,12 +34,14 @@ var Config = class {
|
|
|
30
34
|
const root2 = join(base, path);
|
|
31
35
|
if (root2 === base) return base;
|
|
32
36
|
const faas = join(root2, "faas.yaml");
|
|
37
|
+
console.log(faas);
|
|
33
38
|
if (existsSync(faas))
|
|
34
39
|
configs.push(
|
|
35
40
|
load(readFileSync(faas).toString())
|
|
36
41
|
);
|
|
37
42
|
return root2;
|
|
38
43
|
});
|
|
44
|
+
console.log(configs);
|
|
39
45
|
this.origin = deepMerge(...configs);
|
|
40
46
|
this.defaults = deepMerge(this.origin.defaults || {});
|
|
41
47
|
for (const key in this.origin) {
|
|
@@ -46,24 +52,12 @@ var Config = class {
|
|
|
46
52
|
for (const pluginKey in data.plugins) {
|
|
47
53
|
const plugin = data.plugins[pluginKey];
|
|
48
54
|
plugin.name = pluginKey;
|
|
49
|
-
if (plugin.provider)
|
|
50
|
-
if (typeof plugin.provider === "string") {
|
|
51
|
-
if (!data.providers[plugin.provider])
|
|
52
|
-
throw Error(
|
|
53
|
-
`[faas.yaml] missing provider: ${plugin.provider} <${key}/plugins/${pluginKey}>`
|
|
54
|
-
);
|
|
55
|
-
plugin.provider = data.providers[plugin.provider];
|
|
56
|
-
} else
|
|
57
|
-
plugin.provider = deepMerge(
|
|
58
|
-
data.providers[plugin.provider],
|
|
59
|
-
plugin.provider
|
|
60
|
-
);
|
|
61
55
|
}
|
|
62
56
|
}
|
|
63
57
|
}
|
|
64
58
|
};
|
|
65
|
-
function loadConfig(root, filename) {
|
|
66
|
-
return new Config(root, filename);
|
|
59
|
+
function loadConfig(root, filename, staging) {
|
|
60
|
+
return new Config(root, filename)[staging] || /* @__PURE__ */ Object.create(null);
|
|
67
61
|
}
|
|
68
62
|
var FaasPackages = [
|
|
69
63
|
"@faasjs/cloud_function",
|
|
@@ -142,7 +136,7 @@ function swc(externalModules) {
|
|
|
142
136
|
};
|
|
143
137
|
}
|
|
144
138
|
async function loadTs(filename, options = /* @__PURE__ */ Object.create(null)) {
|
|
145
|
-
|
|
139
|
+
console.warn("[@faasjs/load] Will deprecated in v3.");
|
|
146
140
|
const PackageJSON = __require(`${process.cwd()}/package.json`);
|
|
147
141
|
const external = PackageJSON.dependencies ? Object.keys(PackageJSON.dependencies) : [];
|
|
148
142
|
if (options.modules && options.modules.excludes == null)
|
|
@@ -158,7 +152,7 @@ async function loadTs(filename, options = /* @__PURE__ */ Object.create(null)) {
|
|
|
158
152
|
);
|
|
159
153
|
const bundle2 = await rollup(input);
|
|
160
154
|
const dependencies = /* @__PURE__ */ Object.create(null);
|
|
161
|
-
for (const m of
|
|
155
|
+
for (const m of bundle2.cache?.modules || [])
|
|
162
156
|
for (const d of m.dependencies)
|
|
163
157
|
if (!d.startsWith("/") && !dependencies[d] && !NodeBuiltinModules.includes(d))
|
|
164
158
|
dependencies[d] = "*";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@faasjs/load",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0-canary.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -38,18 +38,18 @@
|
|
|
38
38
|
"rollup": "*"
|
|
39
39
|
},
|
|
40
40
|
"peerDependencies": {
|
|
41
|
-
"@faasjs/deep_merge": "
|
|
42
|
-
"@faasjs/func": "
|
|
43
|
-
"@faasjs/ts-transform": "
|
|
41
|
+
"@faasjs/deep_merge": "3.0.0-canary.1",
|
|
42
|
+
"@faasjs/func": "3.0.0-canary.1",
|
|
43
|
+
"@faasjs/ts-transform": "3.0.0-canary.1"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@types/js-yaml": "*",
|
|
47
|
-
"@faasjs/deep_merge": "
|
|
48
|
-
"@faasjs/func": "
|
|
49
|
-
"@faasjs/ts-transform": "
|
|
47
|
+
"@faasjs/deep_merge": "3.0.0-canary.1",
|
|
48
|
+
"@faasjs/func": "3.0.0-canary.1",
|
|
49
|
+
"@faasjs/ts-transform": "3.0.0-canary.1"
|
|
50
50
|
},
|
|
51
51
|
"engines": {
|
|
52
|
-
"
|
|
53
|
-
"
|
|
52
|
+
"node": ">=22.0.0",
|
|
53
|
+
"npm": ">=10.0.0"
|
|
54
54
|
}
|
|
55
55
|
}
|