@tego/devkit 1.3.14
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 -0
- package/assets/openChrome.applescript +95 -0
- package/bin/cli.js +2 -0
- package/lib/builder/build/buildCjs.mjs +40 -0
- package/lib/builder/build/buildClient.mjs +97 -0
- package/lib/builder/build/buildDeclaration.mjs +46 -0
- package/lib/builder/build/buildEsm.mjs +64 -0
- package/lib/builder/build/constant.mjs +58 -0
- package/lib/builder/build/index.mjs +2 -0
- package/lib/builder/build/tarPlugin.mjs +28 -0
- package/lib/builder/build/utils/buildPluginUtils.mjs +118 -0
- package/lib/builder/build/utils/getDepsConfig.mjs +86 -0
- package/lib/builder/build/utils/getPackages.mjs +63 -0
- package/lib/builder/build/utils/index.mjs +2 -0
- package/lib/builder/build/utils/utils.mjs +60 -0
- package/lib/builder/buildable-packages/app-web-package.mjs +38 -0
- package/lib/builder/buildable-packages/lib-package.mjs +63 -0
- package/lib/builder/buildable-packages/plugin-package.mjs +357 -0
- package/lib/builder/buildable-packages/skip-package.mjs +20 -0
- package/lib/builder/get-packages.mjs +63 -0
- package/lib/builder/index.mjs +56 -0
- package/lib/builder/interfaces.mjs +0 -0
- package/lib/cli.mjs +22 -0
- package/lib/commands/build.mjs +20 -0
- package/lib/commands/clean.mjs +18 -0
- package/lib/commands/create-nginx-conf.mjs +17 -0
- package/lib/commands/create-plugin.mjs +18 -0
- package/lib/commands/dev.mjs +131 -0
- package/lib/commands/e2e.mjs +204 -0
- package/lib/commands/global.mjs +23 -0
- package/lib/commands/index.mjs +36 -0
- package/lib/commands/init.mjs +13 -0
- package/lib/commands/p-test.mjs +79 -0
- package/lib/commands/pm2.mjs +16 -0
- package/lib/commands/postinstall.mjs +25 -0
- package/lib/commands/start.mjs +50 -0
- package/lib/commands/tar.mjs +15 -0
- package/lib/commands/test.mjs +70 -0
- package/lib/commands/upgrade.mjs +13 -0
- package/lib/constants.mjs +13 -0
- package/lib/index.mjs +8 -0
- package/lib/notify-updates.mjs +5 -0
- package/lib/open.mjs +92 -0
- package/lib/package-map-generator.mjs +219 -0
- package/lib/plugin-generator.mjs +63 -0
- package/lib/util.mjs +369 -0
- package/package.json +77 -0
- package/tachybase.conf.tpl +89 -0
- package/templates/plugin/.npmignore.tpl +2 -0
- package/templates/plugin/README.md.tpl +1 -0
- package/templates/plugin/client.d.ts +2 -0
- package/templates/plugin/client.js +1 -0
- package/templates/plugin/package.json.tpl +11 -0
- package/templates/plugin/server.d.ts +2 -0
- package/templates/plugin/server.js +1 -0
- package/templates/plugin/src/client/index.ts.tpl +1 -0
- package/templates/plugin/src/client/plugin.tsx.tpl +11 -0
- package/templates/plugin/src/index.ts +2 -0
- package/templates/plugin/src/server/collections/.gitkeep +0 -0
- package/templates/plugin/src/server/index.ts.tpl +1 -0
- package/templates/plugin/src/server/plugin.ts.tpl +19 -0
package/lib/util.mjs
ADDED
|
@@ -0,0 +1,369 @@
|
|
|
1
|
+
// src/util.ts
|
|
2
|
+
import { createHash } from "node:crypto";
|
|
3
|
+
import {
|
|
4
|
+
cpSync as _cpSync,
|
|
5
|
+
existsSync as _existsSync,
|
|
6
|
+
writeFileSync as _writeFileSync,
|
|
7
|
+
createWriteStream,
|
|
8
|
+
existsSync,
|
|
9
|
+
readFileSync,
|
|
10
|
+
rmSync,
|
|
11
|
+
symlinkSync,
|
|
12
|
+
unlinkSync,
|
|
13
|
+
writeFileSync
|
|
14
|
+
} from "node:fs";
|
|
15
|
+
import { mkdir, readFile, stat, unlink, writeFile } from "node:fs/promises";
|
|
16
|
+
import { createRequire } from "node:module";
|
|
17
|
+
import { Socket } from "node:net";
|
|
18
|
+
import { dirname, join, resolve, sep } from "node:path";
|
|
19
|
+
import { pipeline } from "node:stream/promises";
|
|
20
|
+
import chalk from "chalk";
|
|
21
|
+
import { config } from "dotenv";
|
|
22
|
+
import { execa } from "execa";
|
|
23
|
+
import fastGlob from "fast-glob";
|
|
24
|
+
import packageJson from "package-json";
|
|
25
|
+
import * as tar from "tar";
|
|
26
|
+
import { DEFAULT_DEV_HOST } from "./constants.mjs";
|
|
27
|
+
var require2 = createRequire(import.meta.url);
|
|
28
|
+
async function fsExists(path) {
|
|
29
|
+
try {
|
|
30
|
+
await stat(path);
|
|
31
|
+
return true;
|
|
32
|
+
} catch (error) {
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
function isPackageValid(pkg) {
|
|
37
|
+
try {
|
|
38
|
+
require2.resolve(pkg);
|
|
39
|
+
return true;
|
|
40
|
+
} catch (error) {
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
async function downloadTar(packageName, target) {
|
|
45
|
+
const info = await packageJson(packageName, { fullMetadata: true });
|
|
46
|
+
const url = info.dist.tarball;
|
|
47
|
+
const tarballFile = join(target, "..", `${createHash("md5").update(packageName).digest("hex")}-tarball.gz`);
|
|
48
|
+
await mkdir(dirname(tarballFile), { recursive: true });
|
|
49
|
+
const writer = createWriteStream(tarballFile);
|
|
50
|
+
const response = await fetch(url);
|
|
51
|
+
if (!response.ok || !response.body) {
|
|
52
|
+
throw new Error(`Failed to fetch tarball: ${response.statusText}`);
|
|
53
|
+
}
|
|
54
|
+
await pipeline(response.body, writer);
|
|
55
|
+
await mkdir(target, { recursive: true });
|
|
56
|
+
await tar.x({
|
|
57
|
+
file: tarballFile,
|
|
58
|
+
gzip: true,
|
|
59
|
+
cwd: target,
|
|
60
|
+
strip: 1,
|
|
61
|
+
k: true
|
|
62
|
+
});
|
|
63
|
+
await unlink(tarballFile);
|
|
64
|
+
}
|
|
65
|
+
function hasCorePackages() {
|
|
66
|
+
const coreDir = resolve(process.cwd(), "apps/build");
|
|
67
|
+
return existsSync(coreDir);
|
|
68
|
+
}
|
|
69
|
+
function hasTsNode() {
|
|
70
|
+
return isPackageValid("tsx");
|
|
71
|
+
}
|
|
72
|
+
function isDev() {
|
|
73
|
+
if (process.env.APP_ENV === "production") {
|
|
74
|
+
return false;
|
|
75
|
+
}
|
|
76
|
+
return hasTsNode();
|
|
77
|
+
}
|
|
78
|
+
var isProd = () => {
|
|
79
|
+
const { APP_SERVER_ROOT } = process.env;
|
|
80
|
+
const file = `${APP_SERVER_ROOT}/lib/index.js`;
|
|
81
|
+
if (!existsSync(resolve(process.cwd(), file))) {
|
|
82
|
+
console.log("For production environment, please build the code first.");
|
|
83
|
+
console.log();
|
|
84
|
+
console.log(chalk.yellow("$ pnpm build"));
|
|
85
|
+
console.log();
|
|
86
|
+
process.exit(1);
|
|
87
|
+
}
|
|
88
|
+
return true;
|
|
89
|
+
};
|
|
90
|
+
function nodeCheck() {
|
|
91
|
+
if (!hasTsNode()) {
|
|
92
|
+
console.log("Please install all dependencies");
|
|
93
|
+
console.log(chalk.yellow("$ pnpm install"));
|
|
94
|
+
process.exit(1);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
function run(command, args, options) {
|
|
98
|
+
if (command === "tsx") {
|
|
99
|
+
command = "node";
|
|
100
|
+
args = ["./node_modules/tsx/dist/cli.mjs"].concat(args || []);
|
|
101
|
+
}
|
|
102
|
+
return execa(command, args, {
|
|
103
|
+
shell: true,
|
|
104
|
+
stdio: "inherit",
|
|
105
|
+
...options,
|
|
106
|
+
env: {
|
|
107
|
+
...process.env,
|
|
108
|
+
...options?.env
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
async function isPortReachable(port, options = {}) {
|
|
113
|
+
const timeout = options.timeout ?? 1e3;
|
|
114
|
+
const host = options.host ?? "";
|
|
115
|
+
const promise = new Promise((resolve2, reject) => {
|
|
116
|
+
const socket = new Socket();
|
|
117
|
+
const onError = () => {
|
|
118
|
+
socket.destroy();
|
|
119
|
+
reject();
|
|
120
|
+
};
|
|
121
|
+
socket.setTimeout(timeout);
|
|
122
|
+
socket.once("error", onError);
|
|
123
|
+
socket.once("timeout", onError);
|
|
124
|
+
socket.connect(Number(port), host, () => {
|
|
125
|
+
socket.end();
|
|
126
|
+
resolve2();
|
|
127
|
+
});
|
|
128
|
+
});
|
|
129
|
+
try {
|
|
130
|
+
await promise;
|
|
131
|
+
return true;
|
|
132
|
+
} catch (_) {
|
|
133
|
+
return false;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
async function postCheck(opts) {
|
|
137
|
+
const port = opts.port || process.env.APP_PORT || "";
|
|
138
|
+
const result = await isPortReachable(port);
|
|
139
|
+
if (result) {
|
|
140
|
+
console.error(chalk.red(`post already in use ${port}`));
|
|
141
|
+
process.exit(1);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
async function runInstall() {
|
|
145
|
+
const { APP_SERVER_ROOT, SERVER_TSCONFIG_PATH } = process.env;
|
|
146
|
+
if (!SERVER_TSCONFIG_PATH) {
|
|
147
|
+
throw new Error("SERVER_TSCONFIG_PATH is empty.");
|
|
148
|
+
}
|
|
149
|
+
if (isDev()) {
|
|
150
|
+
const argv = [
|
|
151
|
+
"--tsconfig",
|
|
152
|
+
SERVER_TSCONFIG_PATH,
|
|
153
|
+
"-r",
|
|
154
|
+
"tsconfig-paths/register",
|
|
155
|
+
`${APP_SERVER_ROOT}/src/index.ts`,
|
|
156
|
+
"install",
|
|
157
|
+
"-s"
|
|
158
|
+
];
|
|
159
|
+
await run("tsx", argv);
|
|
160
|
+
} else if (isProd()) {
|
|
161
|
+
const file = `${APP_SERVER_ROOT}/lib/index.js`;
|
|
162
|
+
const argv = [file, "install", "-s"];
|
|
163
|
+
await run("node", argv);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
async function runAppCommand(command, args = []) {
|
|
167
|
+
const { APP_SERVER_ROOT, SERVER_TSCONFIG_PATH } = process.env;
|
|
168
|
+
if (!SERVER_TSCONFIG_PATH) {
|
|
169
|
+
throw new Error("SERVER_TSCONFIG_PATH is not set");
|
|
170
|
+
}
|
|
171
|
+
if (isDev()) {
|
|
172
|
+
const argv = [
|
|
173
|
+
"--tsconfig",
|
|
174
|
+
SERVER_TSCONFIG_PATH,
|
|
175
|
+
"-r",
|
|
176
|
+
"tsconfig-paths/register",
|
|
177
|
+
`${APP_SERVER_ROOT}/src/index.ts`,
|
|
178
|
+
command,
|
|
179
|
+
...args
|
|
180
|
+
];
|
|
181
|
+
await run("tsx", argv);
|
|
182
|
+
} else if (isProd()) {
|
|
183
|
+
const argv = [`${APP_SERVER_ROOT}/lib/index.js`, command, ...args];
|
|
184
|
+
await run("node", argv);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
function promptForTs() {
|
|
188
|
+
console.log(chalk.green("WAIT: ") + "TypeScript compiling...");
|
|
189
|
+
}
|
|
190
|
+
async function updateJsonFile(target, fn) {
|
|
191
|
+
const content = await readFile(target, "utf-8");
|
|
192
|
+
const json = JSON.parse(content);
|
|
193
|
+
await writeFile(target, JSON.stringify(fn(json), null, 2), "utf-8");
|
|
194
|
+
}
|
|
195
|
+
function generateAppDir() {
|
|
196
|
+
const defaultServerRoot = join(process.cwd(), "apps/tego");
|
|
197
|
+
const defaultClientRoot = join(process.cwd(), "apps/web");
|
|
198
|
+
process.env.APP_SERVER_ROOT = process.env.APP_SERVER_ROOT || defaultServerRoot;
|
|
199
|
+
process.env.APP_CLIENT_ROOT = process.env.APP_CLIENT_ROOT || defaultClientRoot;
|
|
200
|
+
}
|
|
201
|
+
async function genTsConfigPaths() {
|
|
202
|
+
try {
|
|
203
|
+
unlinkSync(resolve(process.cwd(), "node_modules/.bin/tsx"));
|
|
204
|
+
symlinkSync(
|
|
205
|
+
resolve(process.cwd(), "node_modules/tsx/dist/cli.mjs"),
|
|
206
|
+
resolve(process.cwd(), "node_modules/.bin/tsx"),
|
|
207
|
+
"file"
|
|
208
|
+
);
|
|
209
|
+
} catch (error) {
|
|
210
|
+
}
|
|
211
|
+
const cwd = process.cwd();
|
|
212
|
+
const cwdLength = cwd.length;
|
|
213
|
+
const paths = {};
|
|
214
|
+
const packages = fastGlob.sync(["apps/*/package.json", "packages/*/package.json"], {
|
|
215
|
+
absolute: true,
|
|
216
|
+
onlyFiles: true
|
|
217
|
+
});
|
|
218
|
+
await Promise.all(
|
|
219
|
+
packages.map(async (packageFile) => {
|
|
220
|
+
const packageJsonName = JSON.parse(await readFile(packageFile, "utf-8")).name;
|
|
221
|
+
const packageDir = dirname(packageFile);
|
|
222
|
+
const relativePath = packageDir.slice(cwdLength + 1).split(sep).join("/");
|
|
223
|
+
paths[`${packageJsonName}/client`] = [`${relativePath}/src/client`];
|
|
224
|
+
paths[`${packageJsonName}/package.json`] = [`${relativePath}/package.json`];
|
|
225
|
+
paths[packageJsonName] = [`${relativePath}/src`];
|
|
226
|
+
if (packageJsonName === "@tachybase/test") {
|
|
227
|
+
paths[`${packageJsonName}/server`] = [`${relativePath}/src/server`];
|
|
228
|
+
paths[`${packageJsonName}/e2e`] = [`${relativePath}/src/e2e`];
|
|
229
|
+
}
|
|
230
|
+
if (packageJsonName === "@tachybase/plugin-workflow-test") {
|
|
231
|
+
paths[`${packageJsonName}/e2e`] = [`${relativePath}/src/e2e`];
|
|
232
|
+
}
|
|
233
|
+
})
|
|
234
|
+
);
|
|
235
|
+
const tsConfigJsonPath = join(cwd, "./tsconfig.paths.json");
|
|
236
|
+
const content = { compilerOptions: { paths } };
|
|
237
|
+
writeFileSync(tsConfigJsonPath, JSON.stringify(content, null, 2), "utf-8");
|
|
238
|
+
return content;
|
|
239
|
+
}
|
|
240
|
+
function generatePlaywrightPath(clean = false) {
|
|
241
|
+
try {
|
|
242
|
+
const playwright = resolve(process.cwd(), "storage/playwright/tests");
|
|
243
|
+
if (clean && _existsSync(playwright)) {
|
|
244
|
+
rmSync(dirname(playwright), { force: true, recursive: true });
|
|
245
|
+
}
|
|
246
|
+
if (!_existsSync(playwright)) {
|
|
247
|
+
const testPkg = require2.resolve("@tachybase/test/package.json");
|
|
248
|
+
_cpSync(resolve(dirname(testPkg), "playwright/tests"), playwright, { recursive: true });
|
|
249
|
+
}
|
|
250
|
+
} catch (error) {
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
function parseEnv(name) {
|
|
254
|
+
if (name === "DB_UNDERSCORED") {
|
|
255
|
+
if (process.env.DB_UNDERSCORED === "true") {
|
|
256
|
+
return "true";
|
|
257
|
+
}
|
|
258
|
+
if (process.env.DB_UNDERSCORED) {
|
|
259
|
+
return "true";
|
|
260
|
+
}
|
|
261
|
+
return "false";
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
function initEnv() {
|
|
265
|
+
const env = {
|
|
266
|
+
APP_ENV: "development",
|
|
267
|
+
APP_KEY: "test-jwt-secret",
|
|
268
|
+
APP_PORT: 3e3,
|
|
269
|
+
API_BASE_PATH: "/api/",
|
|
270
|
+
DB_DIALECT: "sqlite",
|
|
271
|
+
DB_STORAGE: "storage/db/tachybase.sqlite",
|
|
272
|
+
DB_TIMEZONE: "+00:00",
|
|
273
|
+
DB_UNDERSCORED: parseEnv("DB_UNDERSCORED"),
|
|
274
|
+
DEFAULT_STORAGE_TYPE: "local",
|
|
275
|
+
LOCAL_STORAGE_DEST: "storage/uploads",
|
|
276
|
+
PLUGIN_STORAGE_PATH: resolve(process.cwd(), "storage/plugins"),
|
|
277
|
+
MFSU_AD: "none",
|
|
278
|
+
WS_PATH: "/ws",
|
|
279
|
+
SOCKET_PATH: "storage/gateway.sock",
|
|
280
|
+
PM2_HOME: resolve(process.cwd(), "./storage/.pm2"),
|
|
281
|
+
PLUGIN_PACKAGE_PREFIX: "@tachybase/plugin-,@tachybase/module-",
|
|
282
|
+
SERVER_TSCONFIG_PATH: "./tsconfig.server.json",
|
|
283
|
+
PLAYWRIGHT_AUTH_FILE: resolve(process.cwd(), "storage/playwright/.auth/admin.json"),
|
|
284
|
+
CACHE_DEFAULT_STORE: "memory",
|
|
285
|
+
CACHE_MEMORY_MAX: 2e3,
|
|
286
|
+
PLUGIN_STATICS_PATH: "/static/plugins/",
|
|
287
|
+
LOGGER_BASE_PATH: "storage/logs",
|
|
288
|
+
APP_SERVER_BASE_URL: "",
|
|
289
|
+
APP_PUBLIC_PATH: "/"
|
|
290
|
+
};
|
|
291
|
+
if (!process.env.APP_ENV_PATH && process.argv[2] && ["test", "test:client", "test:server"].includes(process.argv[2])) {
|
|
292
|
+
if (_existsSync(resolve(process.cwd(), ".env.test"))) {
|
|
293
|
+
process.env.APP_ENV_PATH = ".env.test";
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
if (!process.env.APP_ENV_PATH && process.argv[2] === "e2e") {
|
|
297
|
+
generatePlaywrightPath();
|
|
298
|
+
if (!_existsSync(".env.e2e") && _existsSync(".env.e2e.example")) {
|
|
299
|
+
const env2 = readFileSync(".env.e2e.example");
|
|
300
|
+
_writeFileSync(".env.e2e", env2);
|
|
301
|
+
}
|
|
302
|
+
if (!_existsSync(".env.e2e")) {
|
|
303
|
+
throw new Error("Please create .env.e2e file first!");
|
|
304
|
+
}
|
|
305
|
+
process.env.APP_ENV_PATH = ".env.e2e";
|
|
306
|
+
}
|
|
307
|
+
config({
|
|
308
|
+
path: resolve(process.cwd(), process.env.APP_ENV_PATH || ".env")
|
|
309
|
+
});
|
|
310
|
+
if (process.argv[2] === "e2e" && !process.env.APP_BASE_URL) {
|
|
311
|
+
process.env.APP_BASE_URL = `http://127.0.0.1:${process.env.APP_PORT}`;
|
|
312
|
+
}
|
|
313
|
+
for (const key in env) {
|
|
314
|
+
if (!process.env[key]) {
|
|
315
|
+
process.env[key] = env[key];
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
if (!process.env.__env_modified__ && process.env.APP_PUBLIC_PATH) {
|
|
319
|
+
const publicPath = process.env.APP_PUBLIC_PATH.replace(/\/$/g, "");
|
|
320
|
+
const keys = ["API_BASE_PATH", "WS_PATH", "PLUGIN_STATICS_PATH"];
|
|
321
|
+
for (const key of keys) {
|
|
322
|
+
process.env[key] = publicPath + process.env[key];
|
|
323
|
+
}
|
|
324
|
+
process.env.__env_modified__ = true;
|
|
325
|
+
}
|
|
326
|
+
if (!process.env.__env_modified__ && process.env.APP_SERVER_BASE_URL && !process.env.API_BASE_URL) {
|
|
327
|
+
process.env.API_BASE_URL = process.env.APP_SERVER_BASE_URL + process.env.API_BASE_PATH;
|
|
328
|
+
process.env.__env_modified__ = true;
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
var getHostInUrl = async (host) => {
|
|
332
|
+
if (host === DEFAULT_DEV_HOST) {
|
|
333
|
+
return "localhost";
|
|
334
|
+
}
|
|
335
|
+
const { isIPv6 } = await import("node:net");
|
|
336
|
+
if (isIPv6(host)) {
|
|
337
|
+
return host === "::" ? "[::1]" : `[${host}]`;
|
|
338
|
+
}
|
|
339
|
+
return host;
|
|
340
|
+
};
|
|
341
|
+
var castArray = (arr) => {
|
|
342
|
+
if (arr === void 0) {
|
|
343
|
+
return [];
|
|
344
|
+
}
|
|
345
|
+
return Array.isArray(arr) ? arr : [arr];
|
|
346
|
+
};
|
|
347
|
+
export {
|
|
348
|
+
castArray,
|
|
349
|
+
downloadTar,
|
|
350
|
+
fsExists,
|
|
351
|
+
genTsConfigPaths,
|
|
352
|
+
generateAppDir,
|
|
353
|
+
generatePlaywrightPath,
|
|
354
|
+
getHostInUrl,
|
|
355
|
+
hasCorePackages,
|
|
356
|
+
hasTsNode,
|
|
357
|
+
initEnv,
|
|
358
|
+
isDev,
|
|
359
|
+
isPackageValid,
|
|
360
|
+
isPortReachable,
|
|
361
|
+
isProd,
|
|
362
|
+
nodeCheck,
|
|
363
|
+
postCheck,
|
|
364
|
+
promptForTs,
|
|
365
|
+
run,
|
|
366
|
+
runAppCommand,
|
|
367
|
+
runInstall,
|
|
368
|
+
updateJsonFile
|
|
369
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@tego/devkit",
|
|
3
|
+
"version": "1.3.14",
|
|
4
|
+
"description": "",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": "./lib/index.mjs"
|
|
9
|
+
},
|
|
10
|
+
"bin": {
|
|
11
|
+
"tachybase": "./bin/cli.js"
|
|
12
|
+
},
|
|
13
|
+
"files": [
|
|
14
|
+
"assets",
|
|
15
|
+
"bin",
|
|
16
|
+
"lib",
|
|
17
|
+
"templates",
|
|
18
|
+
"tachybase.conf.tpl"
|
|
19
|
+
],
|
|
20
|
+
"dependencies": {
|
|
21
|
+
"@hapi/topo": "^6.0.2",
|
|
22
|
+
"@npmcli/arborist": "9.1.2",
|
|
23
|
+
"@pnpm/workspace.find-packages": "^1.1.12",
|
|
24
|
+
"@rsbuild/core": "1.4.2",
|
|
25
|
+
"@rsbuild/plugin-less": "1.2.4",
|
|
26
|
+
"@rsbuild/plugin-react": "1.3.2",
|
|
27
|
+
"@rslib/core": "0.10.4",
|
|
28
|
+
"@types/fs-extra": "^11.0.4",
|
|
29
|
+
"@umijs/utils": "3.5.43",
|
|
30
|
+
"@vercel/ncc": "0.38.3",
|
|
31
|
+
"@vitejs/plugin-react": "^4.6.0",
|
|
32
|
+
"chalk": "^5.4.1",
|
|
33
|
+
"commander": "^12.1.0",
|
|
34
|
+
"dotenv": "^16.5.0",
|
|
35
|
+
"execa": "^8.0.1",
|
|
36
|
+
"fast-glob": "^3.3.3",
|
|
37
|
+
"fs-extra": "^11.3.0",
|
|
38
|
+
"lodash": "^4.17.21",
|
|
39
|
+
"npm-packlist": "10.0.0",
|
|
40
|
+
"open": "10.1.2",
|
|
41
|
+
"p-all": "3.0.0",
|
|
42
|
+
"package-json": "10.0.1",
|
|
43
|
+
"pm2": "6.0.8",
|
|
44
|
+
"portfinder": "^1.0.37",
|
|
45
|
+
"semver": "7.7.2",
|
|
46
|
+
"serve": "^14.2.4",
|
|
47
|
+
"tar": "7.4.3",
|
|
48
|
+
"tree-kill": "^1.2.2",
|
|
49
|
+
"tsconfig-paths": "^4.2.0",
|
|
50
|
+
"tsup": "8.3.5",
|
|
51
|
+
"tsx": "4.20.3",
|
|
52
|
+
"typescript": "5.8.3",
|
|
53
|
+
"update-notifier": "7.3.1",
|
|
54
|
+
"vite": "^5.4.19",
|
|
55
|
+
"vite-plugin-css-injected-by-js": "^3.5.2",
|
|
56
|
+
"yargs-parser": "13.1.2",
|
|
57
|
+
"yocto-spinner": "1.0.0"
|
|
58
|
+
},
|
|
59
|
+
"devDependencies": {
|
|
60
|
+
"@types/fs-extra": "^11.0.4",
|
|
61
|
+
"@types/lodash": "^4.17.18",
|
|
62
|
+
"@types/node": "20.17.10",
|
|
63
|
+
"@types/npm-packlist": "7.0.3",
|
|
64
|
+
"@types/npmcli__arborist": "6.3.1",
|
|
65
|
+
"@types/semver": "^7.7.0",
|
|
66
|
+
"@types/tar": "^6.1.13",
|
|
67
|
+
"@types/update-notifier": "6.0.8",
|
|
68
|
+
"cross-env": "^7.0.3",
|
|
69
|
+
"esbuild-plugin-file-path-extensions": "2.1.4",
|
|
70
|
+
"rimraf": "6.0.1",
|
|
71
|
+
"vite": "^5.4.19"
|
|
72
|
+
},
|
|
73
|
+
"scripts": {
|
|
74
|
+
"build": "tsup",
|
|
75
|
+
"typecheck": "tsc --noEmit"
|
|
76
|
+
}
|
|
77
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
log_format apm '"$time_local" client=$remote_addr '
|
|
2
|
+
'method=$request_method request="$request" '
|
|
3
|
+
'request_length=$request_length '
|
|
4
|
+
'status=$status bytes_sent=$bytes_sent '
|
|
5
|
+
'body_bytes_sent=$body_bytes_sent '
|
|
6
|
+
'referer=$http_referer '
|
|
7
|
+
'user_agent="$http_user_agent" '
|
|
8
|
+
'upstream_addr=$upstream_addr '
|
|
9
|
+
'upstream_status=$upstream_status '
|
|
10
|
+
'request_time=$request_time '
|
|
11
|
+
'upstream_response_time=$upstream_response_time '
|
|
12
|
+
'upstream_connect_time=$upstream_connect_time '
|
|
13
|
+
'upstream_header_time=$upstream_header_time';
|
|
14
|
+
|
|
15
|
+
server {
|
|
16
|
+
listen 80;
|
|
17
|
+
server_name _;
|
|
18
|
+
root {{cwd}}/node_modules/@tachybase/app/dist/client;
|
|
19
|
+
index index.html;
|
|
20
|
+
client_max_body_size 1000M;
|
|
21
|
+
access_log /var/log/nginx/tachybase.log apm;
|
|
22
|
+
|
|
23
|
+
gzip on;
|
|
24
|
+
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
|
|
25
|
+
|
|
26
|
+
# 不缓存 HTML 文件
|
|
27
|
+
# location ~ \.html$ {
|
|
28
|
+
# if_modified_since off;
|
|
29
|
+
# expires off;
|
|
30
|
+
# etag off;
|
|
31
|
+
# }
|
|
32
|
+
|
|
33
|
+
# # 缓存 JavaScript 和 CSS 文件
|
|
34
|
+
# location ~* \.(js|css)$ {
|
|
35
|
+
# expires 365d;
|
|
36
|
+
# add_header Cache-Control "public";
|
|
37
|
+
# }
|
|
38
|
+
|
|
39
|
+
location {{publicPath}}storage/uploads/ {
|
|
40
|
+
alias {{cwd}}/storage/uploads/;
|
|
41
|
+
add_header Cache-Control "public";
|
|
42
|
+
access_log off;
|
|
43
|
+
autoindex off;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
location {{publicPath}} {
|
|
47
|
+
alias {{cwd}}/node_modules/@tachybase/app/dist/client/;
|
|
48
|
+
try_files $uri $uri/ /index.html;
|
|
49
|
+
add_header Last-Modified $date_gmt;
|
|
50
|
+
add_header Cache-Control 'no-store, no-cache';
|
|
51
|
+
if_modified_since off;
|
|
52
|
+
expires off;
|
|
53
|
+
etag off;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
location ^~ {{publicPath}}api/ {
|
|
57
|
+
proxy_pass http://127.0.0.1:{{apiPort}}{{publicPath}}api/;
|
|
58
|
+
proxy_http_version 1.1;
|
|
59
|
+
proxy_set_header Upgrade $http_upgrade;
|
|
60
|
+
proxy_set_header Connection 'upgrade';
|
|
61
|
+
proxy_set_header Host $host;
|
|
62
|
+
proxy_cache_bypass $http_upgrade;
|
|
63
|
+
proxy_connect_timeout 600;
|
|
64
|
+
proxy_send_timeout 600;
|
|
65
|
+
proxy_read_timeout 600;
|
|
66
|
+
send_timeout 600;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
location ^~ {{publicPath}}static/plugins/ {
|
|
70
|
+
proxy_pass http://127.0.0.1:{{apiPort}}{{publicPath}}static/plugins/;
|
|
71
|
+
proxy_http_version 1.1;
|
|
72
|
+
proxy_set_header Upgrade $http_upgrade;
|
|
73
|
+
proxy_set_header Connection 'upgrade';
|
|
74
|
+
proxy_set_header Host $host;
|
|
75
|
+
proxy_cache_bypass $http_upgrade;
|
|
76
|
+
proxy_connect_timeout 600;
|
|
77
|
+
proxy_send_timeout 600;
|
|
78
|
+
proxy_read_timeout 600;
|
|
79
|
+
send_timeout 600;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
location {{publicPath}}ws {
|
|
83
|
+
proxy_pass http://127.0.0.1:{{apiPort}}{{publicPath}}ws;
|
|
84
|
+
proxy_http_version 1.1;
|
|
85
|
+
proxy_set_header Upgrade $http_upgrade;
|
|
86
|
+
proxy_set_header Connection "Upgrade";
|
|
87
|
+
proxy_set_header Host $host;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# {{{packageName}}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('./dist/client/index.js');
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "{{{packageName}}}",
|
|
3
|
+
"version": "{{{packageVersion}}}",
|
|
4
|
+
"main": "dist/server/index.js",
|
|
5
|
+
"dependencies": {},
|
|
6
|
+
"peerDependencies": {
|
|
7
|
+
"@tachybase/client": "workspace:*",
|
|
8
|
+
"@tachybase/server": "workspace:*",
|
|
9
|
+
"@tachybase/test": "workspace:*"
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('./dist/server/index.js');
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './plugin';
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './plugin';
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Plugin } from '@tachybase/server';
|
|
2
|
+
|
|
3
|
+
export class {{{pascalCaseName}}}Server extends Plugin {
|
|
4
|
+
async afterAdd() {}
|
|
5
|
+
|
|
6
|
+
async beforeLoad() {}
|
|
7
|
+
|
|
8
|
+
async load() {}
|
|
9
|
+
|
|
10
|
+
async install() {}
|
|
11
|
+
|
|
12
|
+
async afterEnable() {}
|
|
13
|
+
|
|
14
|
+
async afterDisable() {}
|
|
15
|
+
|
|
16
|
+
async remove() {}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export default {{{pascalCaseName}}}Server;
|