lupine.api 1.1.58 → 1.1.60
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/README.md +3 -3
- package/admin/admin-about.tsx +12 -16
- package/admin/admin-config.tsx +47 -44
- package/admin/admin-css.tsx +3 -3
- package/admin/admin-db.tsx +75 -75
- package/admin/admin-frame-helper.tsx +364 -364
- package/admin/admin-frame.tsx +164 -164
- package/admin/admin-index.tsx +65 -65
- package/admin/admin-login.tsx +111 -111
- package/admin/admin-menu-edit.tsx +637 -637
- package/admin/admin-menu-list.tsx +87 -87
- package/admin/admin-page-edit.tsx +564 -564
- package/admin/admin-page-list.tsx +83 -83
- package/admin/admin-performance.tsx +28 -28
- package/admin/admin-release.tsx +427 -426
- package/admin/admin-resources.tsx +382 -382
- package/admin/admin-shell.tsx +89 -89
- package/admin/admin-table-data.tsx +146 -146
- package/admin/admin-table-list.tsx +230 -230
- package/admin/admin-test-animations.tsx +395 -395
- package/admin/admin-test-component.tsx +823 -808
- package/admin/admin-test-edit.tsx +319 -319
- package/admin/admin-test-themes.tsx +56 -56
- package/admin/admin-tokens.tsx +338 -338
- package/admin/design/admin-design.tsx +174 -174
- package/admin/design/block-grid.tsx +36 -36
- package/admin/design/block-grid1.tsx +21 -21
- package/admin/design/block-paragraph.tsx +19 -19
- package/admin/design/block-title.tsx +19 -19
- package/admin/design/design-block-box.tsx +140 -140
- package/admin/design/drag-data.tsx +24 -24
- package/admin/index.ts +9 -9
- package/admin/package.json +15 -15
- package/admin/tsconfig.json +127 -127
- package/dev/copy-folder.js +32 -32
- package/dev/cp-index-html.js +69 -69
- package/dev/file-utils.js +12 -12
- package/dev/index.js +18 -19
- package/dev/package.json +12 -12
- package/dev/plugin-ifelse.js +168 -168
- package/dev/plugin-ifelse.test.js +37 -37
- package/dev/run-cmd.js +14 -14
- package/dev/send-request.js +12 -12
- package/package.json +55 -55
- package/src/admin-api/admin-api-helper.ts +210 -205
- package/src/admin-api/admin-api.ts +65 -65
- package/src/admin-api/admin-auth.ts +152 -146
- package/src/admin-api/admin-config.ts +94 -84
- package/src/admin-api/admin-csv.ts +94 -94
- package/src/admin-api/admin-db.ts +269 -269
- package/src/admin-api/admin-menu.ts +135 -135
- package/src/admin-api/admin-page.ts +135 -135
- package/src/admin-api/admin-performance.ts +128 -128
- package/src/admin-api/admin-release.ts +706 -700
- package/src/admin-api/admin-resources.ts +318 -318
- package/src/admin-api/admin-token-helper.ts +82 -79
- package/src/admin-api/admin-tokens.ts +90 -90
- package/src/admin-api/index.ts +2 -2
- package/src/admin-api/web-config-api.ts +19 -19
- package/src/api/api-cache.ts +103 -103
- package/src/api/api-helper.ts +44 -44
- package/src/api/api-module.ts +67 -60
- package/src/api/api-router.ts +177 -177
- package/src/api/api-shared-storage.ts +64 -64
- package/src/api/async-storage.ts +5 -5
- package/src/api/debug-service.ts +56 -56
- package/src/api/encode-html.ts +27 -27
- package/src/api/handle-status.ts +75 -75
- package/src/api/index.ts +15 -16
- package/src/api/mini-web-socket.ts +270 -270
- package/src/api/server-content-type.ts +82 -82
- package/src/api/server-render.ts +235 -215
- package/src/api/shell-service.ts +74 -74
- package/src/api/simple-storage.ts +80 -80
- package/src/api/static-server.ts +128 -125
- package/src/api/to-client-delivery.ts +26 -26
- package/src/app/app-cache.ts +55 -55
- package/src/app/app-helper.ts +62 -62
- package/src/app/app-message.ts +109 -109
- package/src/app/app-shared-storage.ts +363 -363
- package/src/app/app-start.ts +136 -136
- package/src/app/cleanup-exit.ts +16 -16
- package/src/app/host-to-path.ts +38 -38
- package/src/app/index.ts +11 -11
- package/src/app/process-dev-requests.ts +130 -130
- package/src/app/web-listener.ts +294 -294
- package/src/app/web-processor.ts +47 -42
- package/src/app/web-server.ts +100 -100
- package/src/common-js/web-env.js +104 -104
- package/src/index.ts +7 -7
- package/src/lang/api-lang-en.ts +26 -26
- package/src/lang/api-lang-zh-cn.ts +27 -27
- package/src/lang/index.ts +2 -2
- package/src/lang/lang-helper.ts +76 -76
- package/src/lang/lang-props.ts +6 -6
- package/src/lib/db/db-helper.ts +23 -23
- package/src/lib/db/db-mysql.ts +249 -250
- package/src/lib/db/db-sqlite.ts +101 -101
- package/src/lib/db/db.spec.ts +28 -28
- package/src/lib/db/db.ts +325 -325
- package/src/lib/db/index.ts +5 -5
- package/src/lib/index.ts +3 -3
- package/src/lib/logger.spec.ts +214 -214
- package/src/lib/logger.ts +281 -281
- package/src/lib/runtime-require.ts +37 -37
- package/src/lib/utils/cookie-util.ts +34 -34
- package/src/lib/utils/crypto.ts +58 -58
- package/src/lib/utils/date-utils.ts +317 -317
- package/src/lib/utils/deep-merge.ts +37 -37
- package/src/lib/utils/delay.ts +12 -12
- package/src/lib/utils/file-setting.ts +55 -55
- package/src/lib/utils/format-bytes.ts +11 -11
- package/src/lib/utils/fs-utils.ts +158 -158
- package/src/lib/utils/get-env.ts +27 -27
- package/src/lib/utils/index.ts +12 -12
- package/src/lib/utils/is-type.ts +48 -48
- package/src/lib/utils/load-env.ts +14 -14
- package/src/lib/utils/pad.ts +6 -6
- package/src/models/api-base.ts +5 -5
- package/src/models/api-module-props.ts +10 -11
- package/src/models/api-router-props.ts +26 -26
- package/src/models/app-cache-props.ts +33 -33
- package/src/models/app-data-props.ts +10 -10
- package/src/models/app-helper-props.ts +6 -6
- package/src/models/app-shared-storage-props.ts +38 -38
- package/src/models/app-start-props.ts +18 -18
- package/src/models/async-storage-props.ts +13 -13
- package/src/models/db-config.ts +30 -30
- package/src/models/host-to-path-props.ts +12 -12
- package/src/models/index.ts +16 -16
- package/src/models/json-object.ts +8 -8
- package/src/models/locals-props.ts +36 -36
- package/src/models/logger-props.ts +84 -84
- package/src/models/simple-storage-props.ts +13 -14
- package/src/models/to-client-delivery-props.ts +6 -6
- package/tsconfig.json +115 -115
- package/dev/plugin-gen-versions.js +0 -20
package/dev/plugin-ifelse.js
CHANGED
|
@@ -1,168 +1,168 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Esbuild plugin for conditional code logic
|
|
3
|
-
|
|
4
|
-
A sample:
|
|
5
|
-
#if TEST || DEBUG
|
|
6
|
-
console.log('test');
|
|
7
|
-
#elseif PROD
|
|
8
|
-
console.log('prod');
|
|
9
|
-
#else
|
|
10
|
-
console.log('not test');
|
|
11
|
-
#endif
|
|
12
|
-
|
|
13
|
-
*/
|
|
14
|
-
const fs = require('fs/promises');
|
|
15
|
-
const path = require('path');
|
|
16
|
-
|
|
17
|
-
const _saved = {
|
|
18
|
-
vars: [],
|
|
19
|
-
baseDir: '',
|
|
20
|
-
exclude: [],
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
const LINE_FLAG = {
|
|
24
|
-
code: 0,
|
|
25
|
-
if: 1,
|
|
26
|
-
else: 2,
|
|
27
|
-
endif: 3,
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
const ifRegExp = /^\/\/\s*#if\s*(.*)$/;
|
|
31
|
-
const elseifRegExp = /^\/\/\s*#elseif\s*(.*)$/;
|
|
32
|
-
const elseRegExp = /^\/\/\s*#else\s*(.*)$/;
|
|
33
|
-
const endifRegExp = /^\/\/\s*#endif$/;
|
|
34
|
-
const ifdefRegExpMultiLine = new RegExp(`^${ifRegExp.source}`, 'gm');
|
|
35
|
-
|
|
36
|
-
// if a variable is not defined, exception will be thrown
|
|
37
|
-
// if a variable is '', 0, false, undefined, null, NaN, it will be considered as false
|
|
38
|
-
/*
|
|
39
|
-
var vars = {
|
|
40
|
-
TEST1: '', // false
|
|
41
|
-
TEST2: '2',
|
|
42
|
-
}
|
|
43
|
-
evalExpression(vars, 'TEST1'); // false
|
|
44
|
-
evalExpression(vars, 'TEST2'); // true
|
|
45
|
-
try {
|
|
46
|
-
evalExpression(vars, 'TEST3'); // exception
|
|
47
|
-
} catch {}
|
|
48
|
-
evalExpression(vars, "TEST2===`2` && TEST2==='2'"); // true, can't use ["] in the exception
|
|
49
|
-
evalExpression(vars, "TEST1 || TEST2"); // true
|
|
50
|
-
|
|
51
|
-
TODO: define variables if it's not defined?
|
|
52
|
-
function extractVariables(expression) {
|
|
53
|
-
// Match words that are not numbers or keywords
|
|
54
|
-
const variableRegex = /\b([a-zA-Z_][a-zA-Z0-9_]*)\b/g;
|
|
55
|
-
return [...new Set(expression.match(variableRegex) || [])];
|
|
56
|
-
}
|
|
57
|
-
*/
|
|
58
|
-
const evalExpression = (vars, expression) => {
|
|
59
|
-
const variables = Object.freeze({ ...vars });
|
|
60
|
-
const fn = new Function(...Object.keys(variables), 'return eval("' + expression + '")');
|
|
61
|
-
const result = !!fn(...Object.values(variables));
|
|
62
|
-
console.log(`Expression [${expression}], result: ${result}`);
|
|
63
|
-
return result;
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
const processOneFile = async (vars, fpath) => {
|
|
67
|
-
let text = await fs.readFile(fpath, 'utf8');
|
|
68
|
-
if (!ifdefRegExpMultiLine.test(text)) {
|
|
69
|
-
return null;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
let lines = text.replace(/\r\n/g, '\n').replace(/\r/g, '\n').split('\n');
|
|
73
|
-
let line = '';
|
|
74
|
-
let expression = '';
|
|
75
|
-
let keepLine = true;
|
|
76
|
-
let lineType = LINE_FLAG.code;
|
|
77
|
-
const saveLines = [];
|
|
78
|
-
for (let i = 0; i < lines.length; i++) {
|
|
79
|
-
line = lines[i];
|
|
80
|
-
|
|
81
|
-
let matchIf = line.match(ifRegExp);
|
|
82
|
-
let matchElseIf = line.match(elseifRegExp);
|
|
83
|
-
if (matchIf) {
|
|
84
|
-
lineType = LINE_FLAG.if;
|
|
85
|
-
expression = matchIf[1].trim();
|
|
86
|
-
} else if (matchElseIf) {
|
|
87
|
-
lineType = LINE_FLAG.if;
|
|
88
|
-
expression = matchElseIf[1].trim();
|
|
89
|
-
} else if (line.match(elseRegExp)) {
|
|
90
|
-
lineType = LINE_FLAG.else;
|
|
91
|
-
} else if (line.match(endifRegExp)) {
|
|
92
|
-
lineType = LINE_FLAG.endif;
|
|
93
|
-
} else {
|
|
94
|
-
lineType = LINE_FLAG.code;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
if (lineType === LINE_FLAG.if) {
|
|
98
|
-
keepLine = true;
|
|
99
|
-
const result = evalExpression(vars, expression);
|
|
100
|
-
if (!result) {
|
|
101
|
-
keepLine = false;
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
if (lineType === LINE_FLAG.else) {
|
|
105
|
-
console.log(`Expression else`);
|
|
106
|
-
keepLine = !keepLine;
|
|
107
|
-
}
|
|
108
|
-
if (lineType === LINE_FLAG.code) {
|
|
109
|
-
if (keepLine) {
|
|
110
|
-
saveLines.push(line);
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
if (lineType === LINE_FLAG.endif) {
|
|
114
|
-
keepLine = true;
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
text = saveLines.join('\n');
|
|
119
|
-
return text;
|
|
120
|
-
};
|
|
121
|
-
|
|
122
|
-
async function pluginOnLoad(args) {
|
|
123
|
-
let fPath = path.relative(_saved.baseDir, args.path);
|
|
124
|
-
let skip = false;
|
|
125
|
-
|
|
126
|
-
for (let filter of _saved.exclude) {
|
|
127
|
-
if (fPath.startsWith(filter)) {
|
|
128
|
-
skip = true;
|
|
129
|
-
break;
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
if (skip) {
|
|
134
|
-
return null;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
const text = await processOneFile(_saved.vars, args.path);
|
|
138
|
-
if (text) {
|
|
139
|
-
return {
|
|
140
|
-
contents: text,
|
|
141
|
-
loader: path.extname(args.path).substring(1),
|
|
142
|
-
};
|
|
143
|
-
} else {
|
|
144
|
-
return null;
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
const DEFAULT_EXCLUDE_LIST = ['dist', 'node_modules'];
|
|
149
|
-
const DEFAULT_EXTENSION_LIST = ['.js', '.jsx', '.ts', '.tsx'];
|
|
150
|
-
module.exports = (
|
|
151
|
-
vars,
|
|
152
|
-
baseDir = process.cwd(),
|
|
153
|
-
exclude = DEFAULT_EXCLUDE_LIST,
|
|
154
|
-
extension = DEFAULT_EXTENSION_LIST
|
|
155
|
-
) => {
|
|
156
|
-
_saved.vars = vars;
|
|
157
|
-
_saved.baseDir = baseDir;
|
|
158
|
-
_saved.exclude = exclude;
|
|
159
|
-
const filter = {
|
|
160
|
-
filter: new RegExp(`(${extension.join('|')})$`),
|
|
161
|
-
};
|
|
162
|
-
return {
|
|
163
|
-
name: 'plugin-ifdef',
|
|
164
|
-
setup(build) {
|
|
165
|
-
build.onLoad(filter, pluginOnLoad);
|
|
166
|
-
},
|
|
167
|
-
};
|
|
168
|
-
};
|
|
1
|
+
/*
|
|
2
|
+
Esbuild plugin for conditional code logic
|
|
3
|
+
|
|
4
|
+
A sample:
|
|
5
|
+
#if TEST || DEBUG
|
|
6
|
+
console.log('test');
|
|
7
|
+
#elseif PROD
|
|
8
|
+
console.log('prod');
|
|
9
|
+
#else
|
|
10
|
+
console.log('not test');
|
|
11
|
+
#endif
|
|
12
|
+
|
|
13
|
+
*/
|
|
14
|
+
const fs = require('fs/promises');
|
|
15
|
+
const path = require('path');
|
|
16
|
+
|
|
17
|
+
const _saved = {
|
|
18
|
+
vars: [],
|
|
19
|
+
baseDir: '',
|
|
20
|
+
exclude: [],
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const LINE_FLAG = {
|
|
24
|
+
code: 0,
|
|
25
|
+
if: 1,
|
|
26
|
+
else: 2,
|
|
27
|
+
endif: 3,
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const ifRegExp = /^\/\/\s*#if\s*(.*)$/;
|
|
31
|
+
const elseifRegExp = /^\/\/\s*#elseif\s*(.*)$/;
|
|
32
|
+
const elseRegExp = /^\/\/\s*#else\s*(.*)$/;
|
|
33
|
+
const endifRegExp = /^\/\/\s*#endif$/;
|
|
34
|
+
const ifdefRegExpMultiLine = new RegExp(`^${ifRegExp.source}`, 'gm');
|
|
35
|
+
|
|
36
|
+
// if a variable is not defined, exception will be thrown
|
|
37
|
+
// if a variable is '', 0, false, undefined, null, NaN, it will be considered as false
|
|
38
|
+
/*
|
|
39
|
+
var vars = {
|
|
40
|
+
TEST1: '', // false
|
|
41
|
+
TEST2: '2',
|
|
42
|
+
}
|
|
43
|
+
evalExpression(vars, 'TEST1'); // false
|
|
44
|
+
evalExpression(vars, 'TEST2'); // true
|
|
45
|
+
try {
|
|
46
|
+
evalExpression(vars, 'TEST3'); // exception
|
|
47
|
+
} catch {}
|
|
48
|
+
evalExpression(vars, "TEST2===`2` && TEST2==='2'"); // true, can't use ["] in the exception
|
|
49
|
+
evalExpression(vars, "TEST1 || TEST2"); // true
|
|
50
|
+
|
|
51
|
+
TODO: define variables if it's not defined?
|
|
52
|
+
function extractVariables(expression) {
|
|
53
|
+
// Match words that are not numbers or keywords
|
|
54
|
+
const variableRegex = /\b([a-zA-Z_][a-zA-Z0-9_]*)\b/g;
|
|
55
|
+
return [...new Set(expression.match(variableRegex) || [])];
|
|
56
|
+
}
|
|
57
|
+
*/
|
|
58
|
+
const evalExpression = (vars, expression) => {
|
|
59
|
+
const variables = Object.freeze({ ...vars });
|
|
60
|
+
const fn = new Function(...Object.keys(variables), 'return eval("' + expression + '")');
|
|
61
|
+
const result = !!fn(...Object.values(variables));
|
|
62
|
+
console.log(`Expression [${expression}], result: ${result}`);
|
|
63
|
+
return result;
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
const processOneFile = async (vars, fpath) => {
|
|
67
|
+
let text = await fs.readFile(fpath, 'utf8');
|
|
68
|
+
if (!ifdefRegExpMultiLine.test(text)) {
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
let lines = text.replace(/\r\n/g, '\n').replace(/\r/g, '\n').split('\n');
|
|
73
|
+
let line = '';
|
|
74
|
+
let expression = '';
|
|
75
|
+
let keepLine = true;
|
|
76
|
+
let lineType = LINE_FLAG.code;
|
|
77
|
+
const saveLines = [];
|
|
78
|
+
for (let i = 0; i < lines.length; i++) {
|
|
79
|
+
line = lines[i];
|
|
80
|
+
|
|
81
|
+
let matchIf = line.match(ifRegExp);
|
|
82
|
+
let matchElseIf = line.match(elseifRegExp);
|
|
83
|
+
if (matchIf) {
|
|
84
|
+
lineType = LINE_FLAG.if;
|
|
85
|
+
expression = matchIf[1].trim();
|
|
86
|
+
} else if (matchElseIf) {
|
|
87
|
+
lineType = LINE_FLAG.if;
|
|
88
|
+
expression = matchElseIf[1].trim();
|
|
89
|
+
} else if (line.match(elseRegExp)) {
|
|
90
|
+
lineType = LINE_FLAG.else;
|
|
91
|
+
} else if (line.match(endifRegExp)) {
|
|
92
|
+
lineType = LINE_FLAG.endif;
|
|
93
|
+
} else {
|
|
94
|
+
lineType = LINE_FLAG.code;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
if (lineType === LINE_FLAG.if) {
|
|
98
|
+
keepLine = true;
|
|
99
|
+
const result = evalExpression(vars, expression);
|
|
100
|
+
if (!result) {
|
|
101
|
+
keepLine = false;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
if (lineType === LINE_FLAG.else) {
|
|
105
|
+
console.log(`Expression else`);
|
|
106
|
+
keepLine = !keepLine;
|
|
107
|
+
}
|
|
108
|
+
if (lineType === LINE_FLAG.code) {
|
|
109
|
+
if (keepLine) {
|
|
110
|
+
saveLines.push(line);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
if (lineType === LINE_FLAG.endif) {
|
|
114
|
+
keepLine = true;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
text = saveLines.join('\n');
|
|
119
|
+
return text;
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
async function pluginOnLoad(args) {
|
|
123
|
+
let fPath = path.relative(_saved.baseDir, args.path);
|
|
124
|
+
let skip = false;
|
|
125
|
+
|
|
126
|
+
for (let filter of _saved.exclude) {
|
|
127
|
+
if (fPath.startsWith(filter)) {
|
|
128
|
+
skip = true;
|
|
129
|
+
break;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
if (skip) {
|
|
134
|
+
return null;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
const text = await processOneFile(_saved.vars, args.path);
|
|
138
|
+
if (text) {
|
|
139
|
+
return {
|
|
140
|
+
contents: text,
|
|
141
|
+
loader: path.extname(args.path).substring(1),
|
|
142
|
+
};
|
|
143
|
+
} else {
|
|
144
|
+
return null;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
const DEFAULT_EXCLUDE_LIST = ['dist', 'node_modules'];
|
|
149
|
+
const DEFAULT_EXTENSION_LIST = ['.js', '.jsx', '.ts', '.tsx'];
|
|
150
|
+
module.exports = (
|
|
151
|
+
vars,
|
|
152
|
+
baseDir = process.cwd(),
|
|
153
|
+
exclude = DEFAULT_EXCLUDE_LIST,
|
|
154
|
+
extension = DEFAULT_EXTENSION_LIST
|
|
155
|
+
) => {
|
|
156
|
+
_saved.vars = vars;
|
|
157
|
+
_saved.baseDir = baseDir;
|
|
158
|
+
_saved.exclude = exclude;
|
|
159
|
+
const filter = {
|
|
160
|
+
filter: new RegExp(`(${extension.join('|')})$`),
|
|
161
|
+
};
|
|
162
|
+
return {
|
|
163
|
+
name: 'plugin-ifdef',
|
|
164
|
+
setup(build) {
|
|
165
|
+
build.onLoad(filter, pluginOnLoad);
|
|
166
|
+
},
|
|
167
|
+
};
|
|
168
|
+
};
|
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
/*
|
|
2
|
-
(async () => {
|
|
3
|
-
var vars = {
|
|
4
|
-
TEST: undefined,
|
|
5
|
-
TEST1: '', // false
|
|
6
|
-
TEST2: '2',
|
|
7
|
-
PROD: false,
|
|
8
|
-
}
|
|
9
|
-
const x = await processOneFile(vars, 'test.js');
|
|
10
|
-
console.log(x);
|
|
11
|
-
process.exit(0);
|
|
12
|
-
})();
|
|
13
|
-
*/
|
|
14
|
-
console.log('test start');
|
|
15
|
-
console.log('test start');
|
|
16
|
-
// #if TEST
|
|
17
|
-
console.log('test');
|
|
18
|
-
// #elseif PROD
|
|
19
|
-
console.log('prod');
|
|
20
|
-
// #else
|
|
21
|
-
console.log('not test');
|
|
22
|
-
// #endif
|
|
23
|
-
console.log('test end');
|
|
24
|
-
console.log('test end');
|
|
25
|
-
// #if TEST1 && TEST2
|
|
26
|
-
console.log('test1 and test2');
|
|
27
|
-
// #endif
|
|
28
|
-
|
|
29
|
-
// #if TEST1 || TEST2
|
|
30
|
-
console.log('test1 or test2');
|
|
31
|
-
// #endif
|
|
32
|
-
|
|
33
|
-
// #if TEST2
|
|
34
|
-
console.log('test2');
|
|
35
|
-
// #endif
|
|
36
|
-
console.log('test end');
|
|
37
|
-
console.log('test end');
|
|
1
|
+
/*
|
|
2
|
+
(async () => {
|
|
3
|
+
var vars = {
|
|
4
|
+
TEST: undefined,
|
|
5
|
+
TEST1: '', // false
|
|
6
|
+
TEST2: '2',
|
|
7
|
+
PROD: false,
|
|
8
|
+
}
|
|
9
|
+
const x = await processOneFile(vars, 'test.js');
|
|
10
|
+
console.log(x);
|
|
11
|
+
process.exit(0);
|
|
12
|
+
})();
|
|
13
|
+
*/
|
|
14
|
+
console.log('test start');
|
|
15
|
+
console.log('test start');
|
|
16
|
+
// #if TEST
|
|
17
|
+
console.log('test');
|
|
18
|
+
// #elseif PROD
|
|
19
|
+
console.log('prod');
|
|
20
|
+
// #else
|
|
21
|
+
console.log('not test');
|
|
22
|
+
// #endif
|
|
23
|
+
console.log('test end');
|
|
24
|
+
console.log('test end');
|
|
25
|
+
// #if TEST1 && TEST2
|
|
26
|
+
console.log('test1 and test2');
|
|
27
|
+
// #endif
|
|
28
|
+
|
|
29
|
+
// #if TEST1 || TEST2
|
|
30
|
+
console.log('test1 or test2');
|
|
31
|
+
// #endif
|
|
32
|
+
|
|
33
|
+
// #if TEST2
|
|
34
|
+
console.log('test2');
|
|
35
|
+
// #endif
|
|
36
|
+
console.log('test end');
|
|
37
|
+
console.log('test end');
|
package/dev/run-cmd.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
const cp = require('child_process');
|
|
2
|
-
|
|
3
|
-
exports.runCmd = (cmd) => {
|
|
4
|
-
const child = cp.spawn(`npm run ${cmd}`, { shell: true });
|
|
5
|
-
console.log(`[dev-server] Run: ${cmd}`);
|
|
6
|
-
// child.stdout.on('data', (data) => {
|
|
7
|
-
// process.stdout.write(`${data}`);
|
|
8
|
-
// });
|
|
9
|
-
// child.stderr.on('data', (data) => {
|
|
10
|
-
// process.stdout.write(`${data}`);
|
|
11
|
-
// });
|
|
12
|
-
child.stdout.pipe(process.stdout);
|
|
13
|
-
child.stderr.pipe(process.stderr);
|
|
14
|
-
};
|
|
1
|
+
const cp = require('child_process');
|
|
2
|
+
|
|
3
|
+
exports.runCmd = (cmd) => {
|
|
4
|
+
const child = cp.spawn(`npm run ${cmd}`, { shell: true });
|
|
5
|
+
console.log(`[dev-server] Run: ${cmd}`);
|
|
6
|
+
// child.stdout.on('data', (data) => {
|
|
7
|
+
// process.stdout.write(`${data}`);
|
|
8
|
+
// });
|
|
9
|
+
// child.stderr.on('data', (data) => {
|
|
10
|
+
// process.stdout.write(`${data}`);
|
|
11
|
+
// });
|
|
12
|
+
child.stdout.pipe(process.stdout);
|
|
13
|
+
child.stderr.pipe(process.stderr);
|
|
14
|
+
};
|
package/dev/send-request.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
exports.sendRequest = async (url, waitSeconds) => {
|
|
2
|
-
try {
|
|
3
|
-
// need node 18
|
|
4
|
-
const ret = await fetch(url, {
|
|
5
|
-
signal: AbortSignal.timeout(waitSeconds * 1000),
|
|
6
|
-
});
|
|
7
|
-
waitSeconds > 0 && (await new Promise((r) => setTimeout(r, waitSeconds * 1000)));
|
|
8
|
-
return ret;
|
|
9
|
-
} catch (err) {
|
|
10
|
-
console.error('sendRequest error: ', err);
|
|
11
|
-
}
|
|
12
|
-
};
|
|
1
|
+
exports.sendRequest = async (url, waitSeconds) => {
|
|
2
|
+
try {
|
|
3
|
+
// need node 18
|
|
4
|
+
const ret = await fetch(url, {
|
|
5
|
+
signal: AbortSignal.timeout(waitSeconds * 1000),
|
|
6
|
+
});
|
|
7
|
+
waitSeconds > 0 && (await new Promise((r) => setTimeout(r, waitSeconds * 1000)));
|
|
8
|
+
return ret;
|
|
9
|
+
} catch (err) {
|
|
10
|
+
console.error('sendRequest error: ', err);
|
|
11
|
+
}
|
|
12
|
+
};
|
package/package.json
CHANGED
|
@@ -1,55 +1,55 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "lupine.api",
|
|
3
|
-
"version": "1.1.
|
|
4
|
-
"license": "MIT",
|
|
5
|
-
"author": "uuware.com",
|
|
6
|
-
"homepage": "https://github.com/uuware/lupine.js",
|
|
7
|
-
"repository": {
|
|
8
|
-
"type": "git",
|
|
9
|
-
"url": "https://github.com/uuware/lupine.js.git",
|
|
10
|
-
"directory": "packages/lupine.api"
|
|
11
|
-
},
|
|
12
|
-
"description": "lupine.api is a fast, lightweight, and flexible node.js based server, working with lupine.web to provide SSR and modern JavaScript features for web applications and APIs.",
|
|
13
|
-
"main": "src/index.ts",
|
|
14
|
-
"source": "src/index.ts",
|
|
15
|
-
"types": "src/index.ts",
|
|
16
|
-
"engines": {
|
|
17
|
-
"node": ">= 20"
|
|
18
|
-
},
|
|
19
|
-
"exports": {
|
|
20
|
-
".": {
|
|
21
|
-
"types": "./src/index.ts",
|
|
22
|
-
"umd": "./src/index.ts",
|
|
23
|
-
"import": "./src/index.ts",
|
|
24
|
-
"require": "./src/index.ts"
|
|
25
|
-
},
|
|
26
|
-
"./admin": {
|
|
27
|
-
"types": "./admin/index.ts",
|
|
28
|
-
"import": "./admin/index.ts",
|
|
29
|
-
"require": "./admin/index.ts"
|
|
30
|
-
},
|
|
31
|
-
"./dev": {
|
|
32
|
-
"require": "./dev/index.js"
|
|
33
|
-
}
|
|
34
|
-
},
|
|
35
|
-
"keywords": [
|
|
36
|
-
"backend-end",
|
|
37
|
-
"lightweight"
|
|
38
|
-
],
|
|
39
|
-
"scripts": {
|
|
40
|
-
"note": "echo 'build is not needed as the typescript code is supposed to be referred directly from other projects'",
|
|
41
|
-
"npm-publish": "npm publish --access public",
|
|
42
|
-
"build": "tsc"
|
|
43
|
-
},
|
|
44
|
-
"dependencies": {
|
|
45
|
-
"better-sqlite3": "^11.9.1",
|
|
46
|
-
"lupine.web": "^1.0.0",
|
|
47
|
-
"lupine.components": "^1.0.0"
|
|
48
|
-
},
|
|
49
|
-
"optionalDependencies": {
|
|
50
|
-
"mysql2": "^3.0.0"
|
|
51
|
-
},
|
|
52
|
-
"devDependencies": {
|
|
53
|
-
"@types/better-sqlite3": "^7.6.12"
|
|
54
|
-
}
|
|
55
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "lupine.api",
|
|
3
|
+
"version": "1.1.60",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"author": "uuware.com",
|
|
6
|
+
"homepage": "https://github.com/uuware/lupine.js",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/uuware/lupine.js.git",
|
|
10
|
+
"directory": "packages/lupine.api"
|
|
11
|
+
},
|
|
12
|
+
"description": "lupine.api is a fast, lightweight, and flexible node.js based server, working with lupine.web to provide SSR and modern JavaScript features for web applications and APIs.",
|
|
13
|
+
"main": "src/index.ts",
|
|
14
|
+
"source": "src/index.ts",
|
|
15
|
+
"types": "src/index.ts",
|
|
16
|
+
"engines": {
|
|
17
|
+
"node": ">= 20"
|
|
18
|
+
},
|
|
19
|
+
"exports": {
|
|
20
|
+
".": {
|
|
21
|
+
"types": "./src/index.ts",
|
|
22
|
+
"umd": "./src/index.ts",
|
|
23
|
+
"import": "./src/index.ts",
|
|
24
|
+
"require": "./src/index.ts"
|
|
25
|
+
},
|
|
26
|
+
"./admin": {
|
|
27
|
+
"types": "./admin/index.ts",
|
|
28
|
+
"import": "./admin/index.ts",
|
|
29
|
+
"require": "./admin/index.ts"
|
|
30
|
+
},
|
|
31
|
+
"./dev": {
|
|
32
|
+
"require": "./dev/index.js"
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
"keywords": [
|
|
36
|
+
"backend-end",
|
|
37
|
+
"lightweight"
|
|
38
|
+
],
|
|
39
|
+
"scripts": {
|
|
40
|
+
"note": "echo 'build is not needed as the typescript code is supposed to be referred directly from other projects'",
|
|
41
|
+
"npm-publish": "npm publish --access public",
|
|
42
|
+
"build": "tsc"
|
|
43
|
+
},
|
|
44
|
+
"dependencies": {
|
|
45
|
+
"better-sqlite3": "^11.9.1",
|
|
46
|
+
"lupine.web": "^1.0.0",
|
|
47
|
+
"lupine.components": "^1.0.0"
|
|
48
|
+
},
|
|
49
|
+
"optionalDependencies": {
|
|
50
|
+
"mysql2": "^3.0.0"
|
|
51
|
+
},
|
|
52
|
+
"devDependencies": {
|
|
53
|
+
"@types/better-sqlite3": "^7.6.12"
|
|
54
|
+
}
|
|
55
|
+
}
|