create-alemonjs 0.0.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/README.md +7 -0
- package/bin/index.d.ts +2 -0
- package/bin/index.js +40 -0
- package/bin/str-git.d.ts +2 -0
- package/bin/str-git.js +13 -0
- package/bin/str-npm.d.ts +2 -0
- package/bin/str-npm.js +9 -0
- package/bin/str-npmr.d.ts +2 -0
- package/bin/str-npmr.js +22 -0
- package/package.json +32 -0
- package/template/alemonjs/.puppeteerrc.cjs +4 -0
- package/template/alemonjs/.vscode/launch.json +22 -0
- package/template/alemonjs/.vscode/tasks.json +13 -0
- package/template/alemonjs/alemon.config.yaml +7 -0
- package/template/alemonjs/index.js +2 -0
- package/template/alemonjs/jsxp.config.tsx +10 -0
- package/template/alemonjs/lvy.config.ts +18 -0
- package/template/alemonjs/package.json +33 -0
- package/template/alemonjs/pm2.config.cjs +14 -0
- package/template/alemonjs/postcss.config.mjs +10 -0
- package/template/alemonjs/src/assets/alemonjs.png +0 -0
- package/template/alemonjs/src/assets/main.css +8 -0
- package/template/alemonjs/src/assets/root.css +15 -0
- package/template/alemonjs/src/env.d.ts +2 -0
- package/template/alemonjs/src/image/component/Html.tsx +13 -0
- package/template/alemonjs/src/image/component/help.tsx +23 -0
- package/template/alemonjs/src/index.ts +31 -0
- package/template/alemonjs/src/response/hello/res.ts +8 -0
- package/template/alemonjs/src/response/help/res.ts +20 -0
- package/template/alemonjs/src/response/mw.ts +6 -0
- package/template/alemonjs/tailwind.config.js +6 -0
- package/template/alemonjs/tsconfig.json +9 -0
package/README.md
ADDED
package/bin/index.d.ts
ADDED
package/bin/index.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { existsSync, cpSync, writeFileSync } from 'fs';
|
|
3
|
+
import { dirname, resolve, join } from 'path';
|
|
4
|
+
import { fileURLToPath } from 'node:url';
|
|
5
|
+
import GitBody from './str-git.js';
|
|
6
|
+
import NpmPublish from './str-npm.js';
|
|
7
|
+
import NpmrcBody from './str-npmr.js';
|
|
8
|
+
import { readFileSync } from 'node:fs';
|
|
9
|
+
|
|
10
|
+
const currentFilePath = fileURLToPath(import.meta.url);
|
|
11
|
+
const currentDirPath = dirname(currentFilePath);
|
|
12
|
+
const alemonjsCliPath = resolve(currentDirPath);
|
|
13
|
+
function createTemplate(name) {
|
|
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
|
+
}
|
|
36
|
+
catch (error) {
|
|
37
|
+
console.info(`${name} ${error}`);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
void createTemplate('alemonjs');
|
package/bin/str-git.d.ts
ADDED
package/bin/str-git.js
ADDED
package/bin/str-npm.d.ts
ADDED
package/bin/str-npm.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
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
|
+
export default _default;
|
package/bin/str-npmr.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
var NpmrcBody = `# 为项目单独设置镜像
|
|
2
|
+
registry=https://registry.npmmirror.com
|
|
3
|
+
# canvas
|
|
4
|
+
canvas_binary_host_mirror=https://ghproxy.com/https://github.com/Automattic/node-canvas/releases/download/
|
|
5
|
+
# node-sass
|
|
6
|
+
sass_binary_site=https://npmmirror.com/mirrors/node-sass/
|
|
7
|
+
# sqlite3
|
|
8
|
+
node_sqlite3_binary_host_mirror=https://npmmirror.com/mirrors/sqlite3
|
|
9
|
+
# TFJS
|
|
10
|
+
TFJS_NODE_CDN_STORAGE=https://cdn.npmmirror.com/binaries/
|
|
11
|
+
# pup
|
|
12
|
+
PUPPETER_DOWNLOAD_BASE_URL=https://npmmirror.com/mirrors/chrome-for-testing
|
|
13
|
+
# 不生成lock
|
|
14
|
+
package-lock=false
|
|
15
|
+
# 改为 npm 依赖安装方式
|
|
16
|
+
node-linker=hoisted
|
|
17
|
+
# 可耻的提升
|
|
18
|
+
shamefully-hoist=true
|
|
19
|
+
# 严格的对等依赖关系
|
|
20
|
+
strict-peer-dependencies=false`;
|
|
21
|
+
|
|
22
|
+
export { NpmrcBody as default };
|
package/package.json
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "create-alemonjs",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "alemonjs dev template",
|
|
5
|
+
"author": "ningmengchongshui",
|
|
6
|
+
"main": "bin/index.js",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"scripts": {
|
|
9
|
+
"build": "npx lvyjs build"
|
|
10
|
+
},
|
|
11
|
+
"dependencies": {
|
|
12
|
+
"enquirer": "^2.4.1"
|
|
13
|
+
},
|
|
14
|
+
"devDependencies": {
|
|
15
|
+
"@types/node": "^18"
|
|
16
|
+
},
|
|
17
|
+
"bin": {
|
|
18
|
+
"create-alemonjs": "bin/index.js"
|
|
19
|
+
},
|
|
20
|
+
"keywords": [
|
|
21
|
+
"alemonjs"
|
|
22
|
+
],
|
|
23
|
+
"publishConfig": {
|
|
24
|
+
"registry": "https://registry.npmjs.org",
|
|
25
|
+
"access": "public"
|
|
26
|
+
},
|
|
27
|
+
"bugs": "https://github.com/lemonade-lab/alemonjs/issues",
|
|
28
|
+
"repository": {
|
|
29
|
+
"type": "git",
|
|
30
|
+
"url": "https://github.com/lemonade-lab/alemonjs.git"
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": "0.2.0",
|
|
3
|
+
"configurations": [
|
|
4
|
+
{
|
|
5
|
+
"name": "dev",
|
|
6
|
+
"type": "node",
|
|
7
|
+
"request": "launch",
|
|
8
|
+
"runtimeArgs": ["dev"],
|
|
9
|
+
"runtimeExecutable": "yarn",
|
|
10
|
+
"skipFiles": ["<node_internals>/**"]
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
"name": "view",
|
|
14
|
+
"type": "node",
|
|
15
|
+
"request": "launch",
|
|
16
|
+
"runtimeArgs": ["dev", "--view"],
|
|
17
|
+
"runtimeExecutable": "yarn",
|
|
18
|
+
"skipFiles": ["<node_internals>/**"],
|
|
19
|
+
"preLaunchTask": "open-browser"
|
|
20
|
+
}
|
|
21
|
+
]
|
|
22
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { defineConfig } from 'lvyjs';
|
|
2
|
+
import { fileURLToPath } from 'url';
|
|
3
|
+
import { dirname, join } from 'path';
|
|
4
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
5
|
+
const includes = (value: string) => process.argv.includes(value);
|
|
6
|
+
const alemonjs = () => import('alemonjs').then(res => res.start('src/index.ts'));
|
|
7
|
+
const jsxp = () => import('jsxp').then(res => res.createServer());
|
|
8
|
+
export default defineConfig({
|
|
9
|
+
plugins: [
|
|
10
|
+
() => {
|
|
11
|
+
if (includes('--view')) return jsxp;
|
|
12
|
+
return alemonjs;
|
|
13
|
+
}
|
|
14
|
+
],
|
|
15
|
+
alias: {
|
|
16
|
+
entries: [{ find: '@src', replacement: join(__dirname, 'src') }]
|
|
17
|
+
}
|
|
18
|
+
});
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "alemonjs-app",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "template app",
|
|
5
|
+
"main": "lib/index.js",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"dev": "npx lvy dev",
|
|
9
|
+
"build": "npx lvy build",
|
|
10
|
+
"review": "npx alemonc start",
|
|
11
|
+
"start": "npx pm2 startOrRestart pm2.config.cjs",
|
|
12
|
+
"stop": "npx pm2 stop pm2.config.cjs",
|
|
13
|
+
"delete": "npx pm2 delete pm2.config.cjs"
|
|
14
|
+
},
|
|
15
|
+
"exports": {
|
|
16
|
+
".": "./lib/index.js",
|
|
17
|
+
"./package": "./package.json"
|
|
18
|
+
},
|
|
19
|
+
"devDependencies": {
|
|
20
|
+
"@types/node": "^22",
|
|
21
|
+
"@alemonjs/db": "^0.0.13",
|
|
22
|
+
"alemonjs": "2.1.14",
|
|
23
|
+
"jsxp": "1.2.4",
|
|
24
|
+
"tailwindcss": "3",
|
|
25
|
+
"cssnano": "^7",
|
|
26
|
+
"lvyjs": "^0.2.25",
|
|
27
|
+
"pm2": "^5"
|
|
28
|
+
},
|
|
29
|
+
"publishConfig": {
|
|
30
|
+
"registry": "https://registry.npmjs.org",
|
|
31
|
+
"access": "public"
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const yaml = require('yaml');
|
|
3
|
+
|
|
4
|
+
// Read and parse the YAML configuration file
|
|
5
|
+
const data = fs.readFileSync('./alemon.config.yaml', 'utf8');
|
|
6
|
+
const config = yaml.parse(data);
|
|
7
|
+
|
|
8
|
+
// Extracting PM2 configuration
|
|
9
|
+
const pm2 = config?.pm2 ?? {};
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @type {{ apps: import("pm2").StartOptions[] }}
|
|
13
|
+
*/
|
|
14
|
+
module.exports = pm2;
|
|
Binary file
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
:root {
|
|
2
|
+
--bg-color: rgb(60 58 58 / 79%);
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
#root[data-theme='blue'] {
|
|
6
|
+
--bg-color: rgba(215, 218, 225, 0.73);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
#root[data-theme='purple'] {
|
|
10
|
+
--bg-color: rgb(164 178 205 / 92%);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
#root[data-theme='red'] {
|
|
14
|
+
--bg-color: rgba(238, 140, 140, 0.79);
|
|
15
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React, { PropsWithChildren } from 'react';
|
|
2
|
+
import css_output from '@src/assets/main.css';
|
|
3
|
+
import { LinkStyleSheet } from 'jsxp';
|
|
4
|
+
export default function Html({ children }: PropsWithChildren) {
|
|
5
|
+
return (
|
|
6
|
+
<html>
|
|
7
|
+
<head>
|
|
8
|
+
<LinkStyleSheet src={css_output} />
|
|
9
|
+
</head>
|
|
10
|
+
<body>{children}</body>
|
|
11
|
+
</html>
|
|
12
|
+
);
|
|
13
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { BackgroundImage } from 'jsxp';
|
|
3
|
+
import img_logo from '@src/assets/alemonjs.png';
|
|
4
|
+
import Html from './Html';
|
|
5
|
+
type Props = {
|
|
6
|
+
data: string;
|
|
7
|
+
theme?: string;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* @param param0
|
|
11
|
+
* @returns
|
|
12
|
+
*/
|
|
13
|
+
export default function App({ data, theme }: Props) {
|
|
14
|
+
return (
|
|
15
|
+
<Html>
|
|
16
|
+
<section id='root' data-theme={theme} className='flex flex-col'>
|
|
17
|
+
<BackgroundImage className='min-h-[31rem] w-full h-full flex items-end justify-center' url={img_logo} size={'100% auto'}>
|
|
18
|
+
<div className='text-blue-400 text-5xl'>{data}</div>
|
|
19
|
+
</BackgroundImage>
|
|
20
|
+
</section>
|
|
21
|
+
</Html>
|
|
22
|
+
);
|
|
23
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { defineChildren, defineResponse, logger, lazy } from 'alemonjs';
|
|
2
|
+
|
|
3
|
+
// 设置路由规则
|
|
4
|
+
const response = defineResponse([
|
|
5
|
+
{
|
|
6
|
+
handler: lazy(() => import('./response/mw')),
|
|
7
|
+
children: [
|
|
8
|
+
{
|
|
9
|
+
regular: /hello/,
|
|
10
|
+
handler: lazy(() => import('./response/hello/res')),
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
regular: /help/,
|
|
14
|
+
handler: lazy(() => import('./response/help/res')),
|
|
15
|
+
}
|
|
16
|
+
]
|
|
17
|
+
}
|
|
18
|
+
]);
|
|
19
|
+
|
|
20
|
+
export default defineChildren({
|
|
21
|
+
// 注册内容
|
|
22
|
+
register() {
|
|
23
|
+
return {
|
|
24
|
+
response
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
// 当注册完成时
|
|
28
|
+
onCreated() {
|
|
29
|
+
logger.info('本地测试启动');
|
|
30
|
+
}
|
|
31
|
+
});
|
|
@@ -0,0 +1,20 @@
|
|
|
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
|
+
});
|