@nocobase/utils 2.1.0-alpha.2 → 2.1.0-alpha.20
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 +201 -661
- package/README.md +79 -10
- package/lib/index.d.ts +2 -0
- package/lib/index.js +5 -1
- package/lib/server-request.d.ts +36 -0
- package/lib/server-request.js +128 -0
- package/lib/storage-path.d.ts +25 -0
- package/lib/storage-path.js +71 -0
- package/package.json +5 -3
- package/plugin-symlink.js +13 -3
package/README.md
CHANGED
|
@@ -1,17 +1,24 @@
|
|
|
1
1
|
# NocoBase
|
|
2
2
|
|
|
3
3
|
<video width="100%" controls>
|
|
4
|
-
|
|
4
|
+
<source src="https://github.com/user-attachments/assets/4d11a87b-00e2-48f3-9bf7-389d21072d13" type="video/mp4">
|
|
5
5
|
</video>
|
|
6
6
|
|
|
7
|
+
<p align="center">
|
|
8
|
+
<a href="https://trendshift.io/repositories/4112" target="_blank"><img src="https://trendshift.io/api/badge/repositories/4112" alt="nocobase%2Fnocobase | Trendshift" style="width: 250px; height: 55px;" width="250" height="55"/></a>
|
|
9
|
+
<a href="https://www.producthunt.com/posts/nocobase?embed=true&utm_source=badge-top-post-topic-badge&utm_medium=badge&utm_souce=badge-nocobase" target="_blank"><img src="https://api.producthunt.com/widgets/embed-image/v1/top-post-topic-badge.svg?post_id=456520&theme=light&period=weekly&topic_id=267" alt="NocoBase - Scalability-first, open-source no-code platform | Product Hunt" style="width: 250px; height: 54px;" width="250" height="54" /></a>
|
|
10
|
+
</p>
|
|
7
11
|
|
|
8
12
|
## What is NocoBase
|
|
9
13
|
|
|
10
|
-
NocoBase is
|
|
11
|
-
|
|
14
|
+
NocoBase is the most extensible AI-powered no-code platform.
|
|
15
|
+
Total control. Infinite extensibility. AI collaboration.
|
|
16
|
+
Enable your team to adapt quickly and cut costs dramatically.
|
|
17
|
+
No years of development. No millions wasted.
|
|
18
|
+
Deploy NocoBase in minutes — and take control of everything.
|
|
12
19
|
|
|
13
20
|
Homepage:
|
|
14
|
-
https://www.nocobase.com/
|
|
21
|
+
https://www.nocobase.com/
|
|
15
22
|
|
|
16
23
|
Online Demo:
|
|
17
24
|
https://demo.nocobase.com/new
|
|
@@ -19,12 +26,74 @@ https://demo.nocobase.com/new
|
|
|
19
26
|
Documents:
|
|
20
27
|
https://docs.nocobase.com/
|
|
21
28
|
|
|
22
|
-
|
|
23
|
-
https://
|
|
29
|
+
Forum:
|
|
30
|
+
https://forum.nocobase.com/
|
|
24
31
|
|
|
25
|
-
|
|
26
|
-
https://www.nocobase.com/en/
|
|
32
|
+
Use Cases:
|
|
33
|
+
https://www.nocobase.com/en/blog/tags/customer-stories
|
|
27
34
|
|
|
35
|
+
## Release Notes
|
|
28
36
|
|
|
29
|
-
|
|
30
|
-
|
|
37
|
+
Our [blog](https://www.nocobase.com/en/blog/timeline) is regularly updated with release notes and provides a weekly summary.
|
|
38
|
+
|
|
39
|
+
## Distinctive features
|
|
40
|
+
|
|
41
|
+
### 1. Data model-driven, not form/table–driven
|
|
42
|
+
|
|
43
|
+
Instead of being constrained by forms or tables, NocoBase adopts a data model–driven approach, separating data structure from user interface to unlock unlimited possibilities.
|
|
44
|
+
|
|
45
|
+
- UI and data structure are fully decoupled
|
|
46
|
+
- Multiple blocks and actions can be created for the same table or record in any quantity or form
|
|
47
|
+
- Supports the main database, external databases, and third-party APIs as data sources
|
|
48
|
+
|
|
49
|
+

|
|
50
|
+
|
|
51
|
+
### 2. AI employees, integrated into your business systems
|
|
52
|
+
Unlike standalone AI demos, NocoBase allows you to embed AI capabilities seamlessly into your interfaces, workflows, and data context, making AI truly useful in real business scenarios.
|
|
53
|
+
|
|
54
|
+
- Define AI employees for roles such as translator, analyst, researcher, or assistant
|
|
55
|
+
- Seamless AI–human collaboration in interfaces and workflows
|
|
56
|
+
- Ensure AI usage is secure, transparent, and customizable for your business needs
|
|
57
|
+
|
|
58
|
+

|
|
59
|
+
|
|
60
|
+
### 3. What you see is what you get, incredibly easy to use
|
|
61
|
+
|
|
62
|
+
While enabling the development of complex business systems, NocoBase keeps the experience simple and intuitive.
|
|
63
|
+
|
|
64
|
+
- One-click switch between usage mode and configuration mode
|
|
65
|
+
- Pages serve as a canvas to arrange blocks and actions, similar to Notion
|
|
66
|
+
- Configuration mode is designed for ordinary users, not just programmers
|
|
67
|
+
|
|
68
|
+

|
|
69
|
+
|
|
70
|
+
### 4. Everything is a plugin, designed for extension
|
|
71
|
+
Adding more no-code features will never cover every business case. NocoBase is built for extension through its plugin-based microkernel architecture.
|
|
72
|
+
|
|
73
|
+
- All functionalities are plugins, similar to WordPress
|
|
74
|
+
- Plugins are ready to use upon installation
|
|
75
|
+
- Pages, blocks, actions, APIs, and data sources can all be extended through custom plugins
|
|
76
|
+
|
|
77
|
+

|
|
78
|
+
|
|
79
|
+
## Installation
|
|
80
|
+
|
|
81
|
+
NocoBase supports three installation methods:
|
|
82
|
+
|
|
83
|
+
- <a target="_blank" href="https://docs.nocobase.com/welcome/getting-started/installation/docker-compose">Installing With Docker (👍Recommended)</a>
|
|
84
|
+
|
|
85
|
+
Suitable for no-code scenarios, no code to write. When upgrading, just download the latest image and reboot.
|
|
86
|
+
|
|
87
|
+
- <a target="_blank" href="https://docs.nocobase.com/welcome/getting-started/installation/create-nocobase-app">Installing from create-nocobase-app CLI</a>
|
|
88
|
+
|
|
89
|
+
The business code of the project is completely independent and supports low-code development.
|
|
90
|
+
|
|
91
|
+
- <a target="_blank" href="https://docs.nocobase.com/welcome/getting-started/installation/git-clone">Installing from Git source code</a>
|
|
92
|
+
|
|
93
|
+
If you want to experience the latest unreleased version, or want to participate in the contribution, you need to make changes and debug on the source code, it is recommended to choose this installation method, which requires a high level of development skills, and if the code has been updated, you can git pull the latest code.
|
|
94
|
+
|
|
95
|
+
## How NocoBase works
|
|
96
|
+
|
|
97
|
+
<video width="100%" controls>
|
|
98
|
+
<source src="https://github.com/user-attachments/assets/8d183b44-9bb5-4792-b08f-bc08fe8dfaaf" type="video/mp4">
|
|
99
|
+
</video>
|
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
|
@@ -80,6 +80,8 @@ __reExport(src_exports, require("./variable-usage"), module.exports);
|
|
|
80
80
|
__reExport(src_exports, require("./wrap-middleware"), module.exports);
|
|
81
81
|
__reExport(src_exports, require("./run-sql"), module.exports);
|
|
82
82
|
__reExport(src_exports, require("./liquidjs"), module.exports);
|
|
83
|
+
__reExport(src_exports, require("./server-request"), module.exports);
|
|
84
|
+
__reExport(src_exports, require("./storage-path"), module.exports);
|
|
83
85
|
// Annotate the CommonJS export names for ESM import in node:
|
|
84
86
|
0 && (module.exports = {
|
|
85
87
|
Schema,
|
|
@@ -119,5 +121,7 @@ __reExport(src_exports, require("./liquidjs"), module.exports);
|
|
|
119
121
|
...require("./variable-usage"),
|
|
120
122
|
...require("./wrap-middleware"),
|
|
121
123
|
...require("./run-sql"),
|
|
122
|
-
...require("./liquidjs")
|
|
124
|
+
...require("./liquidjs"),
|
|
125
|
+
...require("./server-request"),
|
|
126
|
+
...require("./storage-path")
|
|
123
127
|
});
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
import { AxiosRequestConfig, AxiosResponse } from 'axios';
|
|
10
|
+
/**
|
|
11
|
+
* Match a hostname against a domain pattern.
|
|
12
|
+
* `*.example.com` matches exactly one subdomain level (e.g. `foo.example.com`)
|
|
13
|
+
* but not `example.com` itself or deeper levels like `a.b.example.com`.
|
|
14
|
+
*/
|
|
15
|
+
export declare function matchesDomainPattern(hostname: string, pattern: string): boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Validate a URL against the SERVER_REQUEST_WHITELIST environment variable.
|
|
18
|
+
*
|
|
19
|
+
* Throws an error if:
|
|
20
|
+
* - The URL scheme is not http or https.
|
|
21
|
+
* - SERVER_REQUEST_WHITELIST is set and the host does not match any entry.
|
|
22
|
+
*
|
|
23
|
+
* Silently returns for relative URLs (no scheme) so that internal API calls
|
|
24
|
+
* that use a relative path are not affected.
|
|
25
|
+
*
|
|
26
|
+
* Prefer using {@link serverRequest} over calling this directly.
|
|
27
|
+
*/
|
|
28
|
+
export declare function checkUrlAgainstWhitelist(url?: string): void;
|
|
29
|
+
/**
|
|
30
|
+
* Drop-in replacement for `axios.request()` with built-in SSRF protection.
|
|
31
|
+
*
|
|
32
|
+
* Validates `config.url` against {@link checkUrlAgainstWhitelist} before
|
|
33
|
+
* forwarding to axios. Use this instead of calling axios directly for all
|
|
34
|
+
* server-initiated outbound HTTP requests.
|
|
35
|
+
*/
|
|
36
|
+
export declare function serverRequest<T = any>(config: AxiosRequestConfig): Promise<AxiosResponse<T>>;
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
var __create = Object.create;
|
|
11
|
+
var __defProp = Object.defineProperty;
|
|
12
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
13
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
14
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
15
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
16
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
17
|
+
var __export = (target, all) => {
|
|
18
|
+
for (var name in all)
|
|
19
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
20
|
+
};
|
|
21
|
+
var __copyProps = (to, from, except, desc) => {
|
|
22
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
23
|
+
for (let key of __getOwnPropNames(from))
|
|
24
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
25
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
26
|
+
}
|
|
27
|
+
return to;
|
|
28
|
+
};
|
|
29
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
30
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
31
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
32
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
33
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
34
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
35
|
+
mod
|
|
36
|
+
));
|
|
37
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
38
|
+
var server_request_exports = {};
|
|
39
|
+
__export(server_request_exports, {
|
|
40
|
+
checkUrlAgainstWhitelist: () => checkUrlAgainstWhitelist,
|
|
41
|
+
matchesDomainPattern: () => matchesDomainPattern,
|
|
42
|
+
serverRequest: () => serverRequest
|
|
43
|
+
});
|
|
44
|
+
module.exports = __toCommonJS(server_request_exports);
|
|
45
|
+
var import_ipaddr = __toESM(require("ipaddr.js"));
|
|
46
|
+
var import_axios = __toESM(require("axios"));
|
|
47
|
+
const ALLOWED_PROTOCOLS = /* @__PURE__ */ new Set(["http:", "https:"]);
|
|
48
|
+
function matchesIpEntry(hostname, entry) {
|
|
49
|
+
try {
|
|
50
|
+
let addr = import_ipaddr.default.parse(hostname);
|
|
51
|
+
if (addr.kind() === "ipv6" && addr.isIPv4MappedAddress()) {
|
|
52
|
+
addr = addr.toIPv4Address();
|
|
53
|
+
}
|
|
54
|
+
if (entry.includes("/")) {
|
|
55
|
+
const cidr = import_ipaddr.default.parseCIDR(entry);
|
|
56
|
+
if (addr.kind() !== cidr[0].kind()) return false;
|
|
57
|
+
if (addr.kind() === "ipv4") {
|
|
58
|
+
return addr.match(cidr);
|
|
59
|
+
}
|
|
60
|
+
return addr.match(cidr);
|
|
61
|
+
}
|
|
62
|
+
let entryAddr = import_ipaddr.default.parse(entry);
|
|
63
|
+
if (entryAddr.kind() === "ipv6" && entryAddr.isIPv4MappedAddress()) {
|
|
64
|
+
entryAddr = entryAddr.toIPv4Address();
|
|
65
|
+
}
|
|
66
|
+
return addr.toString() === entryAddr.toString();
|
|
67
|
+
} catch {
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
__name(matchesIpEntry, "matchesIpEntry");
|
|
72
|
+
function matchesDomainPattern(hostname, pattern) {
|
|
73
|
+
const h = hostname.toLowerCase();
|
|
74
|
+
const p = pattern.toLowerCase();
|
|
75
|
+
if (p.startsWith("*.")) {
|
|
76
|
+
const suffix = p.slice(1);
|
|
77
|
+
if (!h.endsWith(suffix) || h.length <= suffix.length) return false;
|
|
78
|
+
const prefix = h.slice(0, h.length - suffix.length);
|
|
79
|
+
return !prefix.includes(".");
|
|
80
|
+
}
|
|
81
|
+
return h === p;
|
|
82
|
+
}
|
|
83
|
+
__name(matchesDomainPattern, "matchesDomainPattern");
|
|
84
|
+
function matchesEntry(hostname, entry) {
|
|
85
|
+
const e = entry.trim();
|
|
86
|
+
if (!e) return false;
|
|
87
|
+
return import_ipaddr.default.isValid(hostname) ? matchesIpEntry(hostname, e) : matchesDomainPattern(hostname, e);
|
|
88
|
+
}
|
|
89
|
+
__name(matchesEntry, "matchesEntry");
|
|
90
|
+
function checkUrlAgainstWhitelist(url) {
|
|
91
|
+
if (!url) return;
|
|
92
|
+
if (!url.includes("://")) return;
|
|
93
|
+
let parsed;
|
|
94
|
+
try {
|
|
95
|
+
parsed = new URL(url);
|
|
96
|
+
} catch {
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
if (!ALLOWED_PROTOCOLS.has(parsed.protocol)) {
|
|
100
|
+
throw new Error(
|
|
101
|
+
`URL scheme "${parsed.protocol.replace(":", "")}" is not allowed. Only http and https are permitted.`
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
const whitelist = process.env.SERVER_REQUEST_WHITELIST;
|
|
105
|
+
if (!whitelist || !whitelist.trim()) return;
|
|
106
|
+
const entries = whitelist.split(",").map((e) => e.trim()).filter(Boolean);
|
|
107
|
+
if (entries.length === 0) return;
|
|
108
|
+
const { hostname } = parsed;
|
|
109
|
+
const host = hostname.startsWith("[") && hostname.endsWith("]") ? hostname.slice(1, -1) : hostname;
|
|
110
|
+
for (const entry of entries) {
|
|
111
|
+
if (matchesEntry(host, entry)) return;
|
|
112
|
+
}
|
|
113
|
+
throw new Error(
|
|
114
|
+
`Outbound request to "${host}" is blocked. Add it to SERVER_REQUEST_WHITELIST to allow this request.`
|
|
115
|
+
);
|
|
116
|
+
}
|
|
117
|
+
__name(checkUrlAgainstWhitelist, "checkUrlAgainstWhitelist");
|
|
118
|
+
async function serverRequest(config) {
|
|
119
|
+
checkUrlAgainstWhitelist(config.url);
|
|
120
|
+
return import_axios.default.request(config);
|
|
121
|
+
}
|
|
122
|
+
__name(serverRequest, "serverRequest");
|
|
123
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
124
|
+
0 && (module.exports = {
|
|
125
|
+
checkUrlAgainstWhitelist,
|
|
126
|
+
matchesDomainPattern,
|
|
127
|
+
serverRequest
|
|
128
|
+
});
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Absolute path to the application storage root (same rules as CLI `resolveStorageRoot` in `cli-v1/src/util.js`).
|
|
11
|
+
*/
|
|
12
|
+
export declare function resolveStorageRoot(): string;
|
|
13
|
+
/**
|
|
14
|
+
* Join path segments under the application storage root.
|
|
15
|
+
* Resolution matches CLI `resolveStorageRoot()` / `initEnv`: use `STORAGE_PATH` when set
|
|
16
|
+
* (absolute or relative to cwd), otherwise `<cwd>/storage`.
|
|
17
|
+
*
|
|
18
|
+
* @example storagePathJoin('tmp')
|
|
19
|
+
* @example storagePathJoin('cache', 'apps', appName)
|
|
20
|
+
*/
|
|
21
|
+
export declare function storagePathJoin(...segments: string[]): string;
|
|
22
|
+
/**
|
|
23
|
+
* Resolve plugin storage path: `PLUGIN_STORAGE_PATH` first, else `<STORAGE_PATH>/plugins`.
|
|
24
|
+
*/
|
|
25
|
+
export declare function resolvePluginStoragePath(): string;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
var __create = Object.create;
|
|
11
|
+
var __defProp = Object.defineProperty;
|
|
12
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
13
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
14
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
15
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
16
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
17
|
+
var __export = (target, all) => {
|
|
18
|
+
for (var name in all)
|
|
19
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
20
|
+
};
|
|
21
|
+
var __copyProps = (to, from, except, desc) => {
|
|
22
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
23
|
+
for (let key of __getOwnPropNames(from))
|
|
24
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
25
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
26
|
+
}
|
|
27
|
+
return to;
|
|
28
|
+
};
|
|
29
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
30
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
31
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
32
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
33
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
34
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
35
|
+
mod
|
|
36
|
+
));
|
|
37
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
38
|
+
var storage_path_exports = {};
|
|
39
|
+
__export(storage_path_exports, {
|
|
40
|
+
resolvePluginStoragePath: () => resolvePluginStoragePath,
|
|
41
|
+
resolveStorageRoot: () => resolveStorageRoot,
|
|
42
|
+
storagePathJoin: () => storagePathJoin
|
|
43
|
+
});
|
|
44
|
+
module.exports = __toCommonJS(storage_path_exports);
|
|
45
|
+
var import_path = __toESM(require("path"));
|
|
46
|
+
function resolveStorageRoot() {
|
|
47
|
+
const raw = process.env.STORAGE_PATH;
|
|
48
|
+
if (raw) {
|
|
49
|
+
return import_path.default.isAbsolute(raw) ? raw : import_path.default.resolve(process.cwd(), raw);
|
|
50
|
+
}
|
|
51
|
+
return import_path.default.resolve(process.cwd(), "storage");
|
|
52
|
+
}
|
|
53
|
+
__name(resolveStorageRoot, "resolveStorageRoot");
|
|
54
|
+
function storagePathJoin(...segments) {
|
|
55
|
+
return import_path.default.join(resolveStorageRoot(), ...segments);
|
|
56
|
+
}
|
|
57
|
+
__name(storagePathJoin, "storagePathJoin");
|
|
58
|
+
function resolvePluginStoragePath() {
|
|
59
|
+
if (process.env.PLUGIN_STORAGE_PATH) {
|
|
60
|
+
const p = process.env.PLUGIN_STORAGE_PATH;
|
|
61
|
+
return import_path.default.isAbsolute(p) ? p : import_path.default.resolve(process.cwd(), p);
|
|
62
|
+
}
|
|
63
|
+
return storagePathJoin("plugins");
|
|
64
|
+
}
|
|
65
|
+
__name(resolvePluginStoragePath, "resolvePluginStoragePath");
|
|
66
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
67
|
+
0 && (module.exports = {
|
|
68
|
+
resolvePluginStoragePath,
|
|
69
|
+
resolveStorageRoot,
|
|
70
|
+
storagePathJoin
|
|
71
|
+
});
|
package/package.json
CHANGED
|
@@ -1,23 +1,25 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/utils",
|
|
3
|
-
"version": "2.1.0-alpha.
|
|
3
|
+
"version": "2.1.0-alpha.20",
|
|
4
4
|
"main": "lib/index.js",
|
|
5
5
|
"types": "./lib/index.d.ts",
|
|
6
|
-
"license": "
|
|
6
|
+
"license": "Apache-2.0",
|
|
7
7
|
"dependencies": {
|
|
8
8
|
"@budibase/handlebars-helpers": "0.14.0",
|
|
9
9
|
"@hapi/topo": "^6.0.0",
|
|
10
10
|
"@rc-component/mini-decimal": "^1.1.0",
|
|
11
|
+
"axios": "^1.7.0",
|
|
11
12
|
"dayjs": "^1.11.9",
|
|
12
13
|
"deepmerge": "^4.2.2",
|
|
13
14
|
"flat-to-nested": "^1.1.1",
|
|
14
15
|
"fs-extra": "^11.1.1",
|
|
15
16
|
"graphlib": "^2.1.8",
|
|
16
17
|
"handlebars": "^4.7.8",
|
|
18
|
+
"ipaddr.js": "^1.9.1",
|
|
17
19
|
"liquidjs": "^10.23.0",
|
|
18
20
|
"multer": "^1.4.5-lts.2",
|
|
19
21
|
"object-path": "^0.11.8",
|
|
20
22
|
"ses": "^1.14.0"
|
|
21
23
|
},
|
|
22
|
-
"gitHead": "
|
|
24
|
+
"gitHead": "3d1535db6bf93ca23257faf474afee0d565f54c6"
|
|
23
25
|
}
|
package/plugin-symlink.js
CHANGED
|
@@ -1,6 +1,15 @@
|
|
|
1
|
-
const
|
|
1
|
+
const path = require('path');
|
|
2
|
+
const { resolve } = path;
|
|
2
3
|
const fs = require('fs-extra');
|
|
3
4
|
|
|
5
|
+
function resolvePluginStoragePath() {
|
|
6
|
+
if (process.env.PLUGIN_STORAGE_PATH) {
|
|
7
|
+
const p = process.env.PLUGIN_STORAGE_PATH;
|
|
8
|
+
return path.isAbsolute(p) ? p : path.resolve(process.cwd(), p);
|
|
9
|
+
}
|
|
10
|
+
return path.join(process.env.STORAGE_PATH || path.resolve(process.cwd(), 'storage'), 'plugins');
|
|
11
|
+
}
|
|
12
|
+
|
|
4
13
|
/**
|
|
5
14
|
* Recursively get plugin names from a directory
|
|
6
15
|
* @param {string} target - Target directory to scan
|
|
@@ -136,7 +145,7 @@ async function createPluginSymLink(pluginName, sourcePath, nodeModulesPath, plug
|
|
|
136
145
|
* @returns {Promise<void>}
|
|
137
146
|
*/
|
|
138
147
|
async function createStoragePluginSymLink(pluginName) {
|
|
139
|
-
const storagePluginsPath =
|
|
148
|
+
const storagePluginsPath = resolvePluginStoragePath();
|
|
140
149
|
const nodeModulesPath = process.env.NODE_MODULES_PATH;
|
|
141
150
|
await createPluginSymLink(pluginName, storagePluginsPath, nodeModulesPath, 'storage');
|
|
142
151
|
}
|
|
@@ -146,7 +155,7 @@ async function createStoragePluginSymLink(pluginName) {
|
|
|
146
155
|
* @returns {Promise<void>}
|
|
147
156
|
*/
|
|
148
157
|
async function createStoragePluginsSymlink() {
|
|
149
|
-
const storagePluginsPath =
|
|
158
|
+
const storagePluginsPath = resolvePluginStoragePath();
|
|
150
159
|
if (!(await fs.pathExists(storagePluginsPath))) {
|
|
151
160
|
return;
|
|
152
161
|
}
|
|
@@ -178,6 +187,7 @@ async function createDevPluginsSymlink() {
|
|
|
178
187
|
await Promise.all(pluginNames.map((pluginName) => createDevPluginSymLink(pluginName)));
|
|
179
188
|
}
|
|
180
189
|
|
|
190
|
+
exports.resolvePluginStoragePath = resolvePluginStoragePath;
|
|
181
191
|
exports.createStoragePluginSymLink = createStoragePluginSymLink;
|
|
182
192
|
exports.createStoragePluginsSymlink = createStoragePluginsSymlink;
|
|
183
193
|
exports.createDevPluginSymLink = createDevPluginSymLink;
|