create-alemonjs 0.0.1 → 0.0.3
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/bin/index.js +24 -25
- package/bin/str-git.d.ts +1 -1
- package/bin/str-npm.d.ts +1 -1
- package/bin/str-npmr.d.ts +1 -1
- package/package.json +1 -1
- package/template/alemonjs/.puppeteerrc.cjs +1 -1
- package/template/alemonjs/alemon.config.yaml +4 -0
- package/template/alemonjs/app.ts +8 -0
- package/template/alemonjs/index.js +1 -1
- package/template/alemonjs/package.json +5 -3
- package/template/alemonjs/pm2.config.cjs +1 -1
- package/template/alemonjs/postcss.config.mjs +1 -1
- package/template/alemonjs/src/assets/main.css +1 -1
- package/template/alemonjs/src/assets/root.css +1 -1
- package/template/alemonjs/src/index.ts +12 -16
- package/template/alemonjs/src/response/hello.ts +32 -0
- package/template/alemonjs/src/response/help.ts +34 -0
- package/template/alemonjs/src/response/mw.ts +4 -3
- package/template/alemonjs/src/response/hello/res.ts +0 -8
- package/template/alemonjs/src/response/help/res.ts +0 -20
package/bin/index.js
CHANGED
|
@@ -11,30 +11,29 @@ const currentFilePath = fileURLToPath(import.meta.url);
|
|
|
11
11
|
const currentDirPath = dirname(currentFilePath);
|
|
12
12
|
const alemonjsCliPath = resolve(currentDirPath);
|
|
13
13
|
function createTemplate(name) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
14
|
+
const dirPath = `./${name}`;
|
|
15
|
+
if (existsSync(dirPath)) {
|
|
16
|
+
console.error('Robot name already exists!');
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
console.info('\n');
|
|
20
|
+
try {
|
|
21
|
+
const data = join(alemonjsCliPath, '../', 'package.json');
|
|
22
|
+
const pkg = readFileSync(data, 'utf-8');
|
|
23
|
+
const version = JSON.parse(pkg).version;
|
|
24
|
+
const templatePath = join(alemonjsCliPath, '../', 'template', name);
|
|
25
|
+
console.info(`[V${version}] Copying template...`);
|
|
26
|
+
cpSync(templatePath, dirPath, { recursive: true });
|
|
27
|
+
writeFileSync(join(dirPath, '.npmrc'), NpmrcBody);
|
|
28
|
+
writeFileSync(join(dirPath, '.gitignore'), GitBody);
|
|
29
|
+
writeFileSync(join(dirPath, '.npmignore'), NpmPublish);
|
|
30
|
+
process.chdir(dirPath);
|
|
31
|
+
console.info('------------------------------------');
|
|
32
|
+
console.info(`cd ${name}`);
|
|
33
|
+
console.info('npm i yarn -g && yarn');
|
|
34
|
+
console.info('------------------------------------');
|
|
35
|
+
} catch (error) {
|
|
36
|
+
console.info(`${name} ${error}`);
|
|
37
|
+
}
|
|
39
38
|
}
|
|
40
39
|
void createTemplate('alemonjs');
|
package/bin/str-git.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default:
|
|
1
|
+
declare const _default: 'node_modules\n/data\n/public\n/logs\n/lib\n/log\n*.logs\n*.log\nyarn.lock\n.cache\n';
|
|
2
2
|
export default _default;
|
package/bin/str-npm.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default:
|
|
1
|
+
declare const _default: '# \u5FFD\u7565\u6240\u6709\n/* \n# \u4E0D\u5FFD\u7565\n!/assets\n!/lib\n!/public\n';
|
|
2
2
|
export default _default;
|
package/bin/str-npmr.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default:
|
|
1
|
+
declare const _default: '# \u4E3A\u9879\u76EE\u5355\u72EC\u8BBE\u7F6E\u955C\u50CF\nregistry=https://registry.npmmirror.com\n# canvas\ncanvas_binary_host_mirror=https://ghproxy.com/https://github.com/Automattic/node-canvas/releases/download/\n# node-sass\nsass_binary_site=https://npmmirror.com/mirrors/node-sass/\n# sqlite3\nnode_sqlite3_binary_host_mirror=https://npmmirror.com/mirrors/sqlite3\n# TFJS\nTFJS_NODE_CDN_STORAGE=https://cdn.npmmirror.com/binaries/\n# pup\nPUPPETER_DOWNLOAD_BASE_URL=https://npmmirror.com/mirrors/chrome-for-testing\n# \u4E0D\u751F\u6210lock\npackage-lock=false\n# \u6539\u4E3A npm \u4F9D\u8D56\u5B89\u88C5\u65B9\u5F0F\nnode-linker=hoisted\n# \u53EF\u803B\u7684\u63D0\u5347\nshamefully-hoist=true\n# \u4E25\u683C\u7684\u5BF9\u7B49\u4F9D\u8D56\u5173\u7CFB\nstrict-peer-dependencies=false';
|
|
2
2
|
export default _default;
|
package/package.json
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {start} from 'alemonjs';
|
|
2
2
|
start();
|
|
@@ -5,7 +5,9 @@
|
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"scripts": {
|
|
8
|
-
"
|
|
8
|
+
"app": "node index.js",
|
|
9
|
+
"dev": "npx lvy app.ts",
|
|
10
|
+
"view": "npx lvy app.ts --jsxp",
|
|
9
11
|
"build": "npx lvy build",
|
|
10
12
|
"review": "npx alemonc start",
|
|
11
13
|
"start": "npx pm2 startOrRestart pm2.config.cjs",
|
|
@@ -19,11 +21,11 @@
|
|
|
19
21
|
"devDependencies": {
|
|
20
22
|
"@types/node": "^22",
|
|
21
23
|
"@alemonjs/db": "^0.0.13",
|
|
22
|
-
"alemonjs": "2.1.
|
|
24
|
+
"alemonjs": "2.1.35",
|
|
23
25
|
"jsxp": "1.2.4",
|
|
24
26
|
"tailwindcss": "3",
|
|
25
27
|
"cssnano": "^7",
|
|
26
|
-
"lvyjs": "^0.2
|
|
28
|
+
"lvyjs": "^0.3.0-alpha.2",
|
|
27
29
|
"pm2": "^5"
|
|
28
30
|
},
|
|
29
31
|
"publishConfig": {
|
|
@@ -1,19 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { defineRouter, logger, lazy } from 'alemonjs';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
const response = defineResponse([
|
|
3
|
+
const responseRouter = defineRouter([
|
|
5
4
|
{
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
handler: lazy(() => import('./response/help/res')),
|
|
15
|
-
}
|
|
16
|
-
]
|
|
5
|
+
regular: /hello/,
|
|
6
|
+
selects: ['message.create'],
|
|
7
|
+
handler: lazy(() => import('./response/hello'))
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
regular: /help/,
|
|
11
|
+
selects: ['message.create'],
|
|
12
|
+
handler: lazy(() => import('./response/help'))
|
|
17
13
|
}
|
|
18
14
|
]);
|
|
19
15
|
|
|
@@ -21,8 +17,8 @@ export default defineChildren({
|
|
|
21
17
|
// 注册内容
|
|
22
18
|
register() {
|
|
23
19
|
return {
|
|
24
|
-
|
|
25
|
-
}
|
|
20
|
+
responseRouter
|
|
21
|
+
};
|
|
26
22
|
},
|
|
27
23
|
// 当注册完成时
|
|
28
24
|
onCreated() {
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { useMention, useMessage, Format, createEvent } from 'alemonjs';
|
|
2
|
+
|
|
3
|
+
export default async e => {
|
|
4
|
+
// 创建事件
|
|
5
|
+
const event = createEvent({
|
|
6
|
+
event: e,
|
|
7
|
+
selects: ['message.create']
|
|
8
|
+
// regular: /hello/,
|
|
9
|
+
// prefix: '/',
|
|
10
|
+
// exact: '/hello'
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
const [message] = useMessage(event);
|
|
14
|
+
const [mention] = useMention(event);
|
|
15
|
+
|
|
16
|
+
const userRes = await mention.findOne();
|
|
17
|
+
if (!userRes.count || !userRes.data) {
|
|
18
|
+
// 没有找到用户
|
|
19
|
+
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
const user = userRes.data;
|
|
23
|
+
|
|
24
|
+
const format = Format.create();
|
|
25
|
+
|
|
26
|
+
format.addText(`hello, ${user.UserName || user.UserId}!`);
|
|
27
|
+
|
|
28
|
+
// 发送消息
|
|
29
|
+
message.send({
|
|
30
|
+
format
|
|
31
|
+
});
|
|
32
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { renderComponentToBuffer } from 'jsxp';
|
|
2
|
+
import { useMessage, createEvent, Format } from 'alemonjs';
|
|
3
|
+
import Help from '@src/image/component/help';
|
|
4
|
+
|
|
5
|
+
export default async (e, next) => {
|
|
6
|
+
// 创建事件
|
|
7
|
+
const event = createEvent({
|
|
8
|
+
event: e,
|
|
9
|
+
selects: ['message.create']
|
|
10
|
+
});
|
|
11
|
+
// 事件不匹配
|
|
12
|
+
if (!event.selects) {
|
|
13
|
+
next();
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
const [message] = useMessage(event);
|
|
17
|
+
const format = Format.create();
|
|
18
|
+
// pic
|
|
19
|
+
const img = await renderComponentToBuffer('/help', Help, {
|
|
20
|
+
data: 'AlemonJS 跨平台开发框架'
|
|
21
|
+
});
|
|
22
|
+
// send
|
|
23
|
+
if (typeof img != 'boolean') {
|
|
24
|
+
format.addImage(img);
|
|
25
|
+
message.send({
|
|
26
|
+
format
|
|
27
|
+
});
|
|
28
|
+
} else {
|
|
29
|
+
format.addText('图片加载失败');
|
|
30
|
+
message.send({
|
|
31
|
+
format: format
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
};
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { renderComponentToBuffer } from 'jsxp';
|
|
2
|
-
import { Text, Image, useMessage } from 'alemonjs';
|
|
3
|
-
|
|
4
|
-
import Help from '@src/image/component/help';
|
|
5
|
-
|
|
6
|
-
export const selects = onSelects(['message.create']);
|
|
7
|
-
|
|
8
|
-
export default onResponse(selects, async event => {
|
|
9
|
-
const [message] = useMessage(event);
|
|
10
|
-
// pic
|
|
11
|
-
const img = await renderComponentToBuffer('/help', Help, {
|
|
12
|
-
data: 'AlemonJS 跨平台开发框架'
|
|
13
|
-
});
|
|
14
|
-
// send
|
|
15
|
-
if (typeof img != 'boolean') {
|
|
16
|
-
message.send(format(Image(img)));
|
|
17
|
-
} else {
|
|
18
|
-
message.send(format(Text('图片加载失败')));
|
|
19
|
-
}
|
|
20
|
-
});
|