@faasjs/load 2.9.0 → 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 CHANGED
@@ -2,8 +2,6 @@ import { Config as Config$1, Func } from '@faasjs/func';
2
2
 
3
3
  /**
4
4
  * 配置类
5
- *
6
- * @deprecated
7
5
  */
8
6
  declare class Config {
9
7
  [key: string]: any;
@@ -27,7 +25,7 @@ declare class Config {
27
25
  * @param root {string} 根目录
28
26
  * @param filename {filename} 目标文件,用于读取目录层级
29
27
  */
30
- declare function loadConfig(root: string, filename: string): Config;
28
+ declare function loadConfig(root: string, filename: string, staging: string): Config;
31
29
 
32
30
  /**
33
31
  * 加载 ts 文件
package/dist/index.d.ts CHANGED
@@ -2,8 +2,6 @@ import { Config as Config$1, Func } from '@faasjs/func';
2
2
 
3
3
  /**
4
4
  * 配置类
5
- *
6
- * @deprecated
7
5
  */
8
6
  declare class Config {
9
7
  [key: string]: any;
@@ -27,7 +25,7 @@ declare class Config {
27
25
  * @param root {string} 根目录
28
26
  * @param filename {filename} 目标文件,用于读取目录层级
29
27
  */
30
- declare function loadConfig(root: string, filename: string): Config;
28
+ declare function loadConfig(root: string, filename: string, staging: string): Config;
31
29
 
32
30
  /**
33
31
  * 加载 ts 文件
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
  *
@@ -21,7 +25,6 @@ var Config = class {
21
25
  * @param filename {filename} 目标文件,用于读取目录层级
22
26
  */
23
27
  constructor(root, filename) {
24
- console.warn("[@faasjs/load] Will deprecated in v3.");
25
28
  this.root = root;
26
29
  if (!this.root.endsWith(path.sep)) this.root += path.sep;
27
30
  this.filename = filename;
@@ -33,12 +36,14 @@ var Config = class {
33
36
  const root2 = path.join(base, path$1);
34
37
  if (root2 === base) return base;
35
38
  const faas = path.join(root2, "faas.yaml");
39
+ console.log(faas);
36
40
  if (fs.existsSync(faas))
37
41
  configs.push(
38
42
  jsYaml.load(fs.readFileSync(faas).toString())
39
43
  );
40
44
  return root2;
41
45
  });
46
+ console.log(configs);
42
47
  this.origin = deep_merge.deepMerge(...configs);
43
48
  this.defaults = deep_merge.deepMerge(this.origin.defaults || {});
44
49
  for (const key in this.origin) {
@@ -49,24 +54,12 @@ var Config = class {
49
54
  for (const pluginKey in data.plugins) {
50
55
  const plugin = data.plugins[pluginKey];
51
56
  plugin.name = pluginKey;
52
- if (plugin.provider)
53
- if (typeof plugin.provider === "string") {
54
- if (!data.providers[plugin.provider])
55
- throw Error(
56
- `[faas.yaml] missing provider: ${plugin.provider} <${key}/plugins/${pluginKey}>`
57
- );
58
- plugin.provider = data.providers[plugin.provider];
59
- } else
60
- plugin.provider = deep_merge.deepMerge(
61
- data.providers[plugin.provider],
62
- plugin.provider
63
- );
64
57
  }
65
58
  }
66
59
  }
67
60
  };
68
- function loadConfig(root, filename) {
69
- return new Config(root, filename);
61
+ function loadConfig(root, filename, staging) {
62
+ return new Config(root, filename)[staging] || /* @__PURE__ */ Object.create(null);
70
63
  }
71
64
  var FaasPackages = [
72
65
  "@faasjs/cloud_function",
@@ -145,7 +138,6 @@ function swc(externalModules) {
145
138
  };
146
139
  }
147
140
  async function loadTs(filename, options = /* @__PURE__ */ Object.create(null)) {
148
- var _a;
149
141
  console.warn("[@faasjs/load] Will deprecated in v3.");
150
142
  const PackageJSON = __require(`${process.cwd()}/package.json`);
151
143
  const external = PackageJSON.dependencies ? Object.keys(PackageJSON.dependencies) : [];
@@ -162,7 +154,7 @@ async function loadTs(filename, options = /* @__PURE__ */ Object.create(null)) {
162
154
  );
163
155
  const bundle2 = await rollup_js.rollup(input);
164
156
  const dependencies = /* @__PURE__ */ Object.create(null);
165
- for (const m of ((_a = bundle2.cache) == null ? void 0 : _a.modules) || [])
157
+ for (const m of bundle2.cache?.modules || [])
166
158
  for (const d of m.dependencies)
167
159
  if (!d.startsWith("/") && !dependencies[d] && !tsTransform.NodeBuiltinModules.includes(d))
168
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
  *
@@ -19,7 +23,6 @@ var Config = class {
19
23
  * @param filename {filename} 目标文件,用于读取目录层级
20
24
  */
21
25
  constructor(root, filename) {
22
- console.warn("[@faasjs/load] Will deprecated in v3.");
23
26
  this.root = root;
24
27
  if (!this.root.endsWith(sep)) this.root += sep;
25
28
  this.filename = filename;
@@ -31,12 +34,14 @@ var Config = class {
31
34
  const root2 = join(base, path);
32
35
  if (root2 === base) return base;
33
36
  const faas = join(root2, "faas.yaml");
37
+ console.log(faas);
34
38
  if (existsSync(faas))
35
39
  configs.push(
36
40
  load(readFileSync(faas).toString())
37
41
  );
38
42
  return root2;
39
43
  });
44
+ console.log(configs);
40
45
  this.origin = deepMerge(...configs);
41
46
  this.defaults = deepMerge(this.origin.defaults || {});
42
47
  for (const key in this.origin) {
@@ -47,24 +52,12 @@ var Config = class {
47
52
  for (const pluginKey in data.plugins) {
48
53
  const plugin = data.plugins[pluginKey];
49
54
  plugin.name = pluginKey;
50
- if (plugin.provider)
51
- if (typeof plugin.provider === "string") {
52
- if (!data.providers[plugin.provider])
53
- throw Error(
54
- `[faas.yaml] missing provider: ${plugin.provider} <${key}/plugins/${pluginKey}>`
55
- );
56
- plugin.provider = data.providers[plugin.provider];
57
- } else
58
- plugin.provider = deepMerge(
59
- data.providers[plugin.provider],
60
- plugin.provider
61
- );
62
55
  }
63
56
  }
64
57
  }
65
58
  };
66
- function loadConfig(root, filename) {
67
- return new Config(root, filename);
59
+ function loadConfig(root, filename, staging) {
60
+ return new Config(root, filename)[staging] || /* @__PURE__ */ Object.create(null);
68
61
  }
69
62
  var FaasPackages = [
70
63
  "@faasjs/cloud_function",
@@ -143,7 +136,6 @@ function swc(externalModules) {
143
136
  };
144
137
  }
145
138
  async function loadTs(filename, options = /* @__PURE__ */ Object.create(null)) {
146
- var _a;
147
139
  console.warn("[@faasjs/load] Will deprecated in v3.");
148
140
  const PackageJSON = __require(`${process.cwd()}/package.json`);
149
141
  const external = PackageJSON.dependencies ? Object.keys(PackageJSON.dependencies) : [];
@@ -160,7 +152,7 @@ async function loadTs(filename, options = /* @__PURE__ */ Object.create(null)) {
160
152
  );
161
153
  const bundle2 = await rollup(input);
162
154
  const dependencies = /* @__PURE__ */ Object.create(null);
163
- for (const m of ((_a = bundle2.cache) == null ? void 0 : _a.modules) || [])
155
+ for (const m of bundle2.cache?.modules || [])
164
156
  for (const d of m.dependencies)
165
157
  if (!d.startsWith("/") && !dependencies[d] && !NodeBuiltinModules.includes(d))
166
158
  dependencies[d] = "*";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@faasjs/load",
3
- "version": "2.9.0",
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": "2.9.0",
42
- "@faasjs/func": "2.9.0",
43
- "@faasjs/ts-transform": "2.9.0"
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": "2.9.0",
48
- "@faasjs/func": "2.9.0",
49
- "@faasjs/ts-transform": "2.9.0"
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
- "npm": ">=9.0.0",
53
- "node": ">=18.0.0"
52
+ "node": ">=22.0.0",
53
+ "npm": ">=10.0.0"
54
54
  }
55
55
  }