create-alemonjs 0.0.2 → 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.d.ts +2 -0
- package/bin/index.js +39 -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 +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/src/response/hello.ts +1 -1
package/bin/index.d.ts
ADDED
package/bin/index.js
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
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
|
+
} catch (error) {
|
|
36
|
+
console.info(`${name} ${error}`);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
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
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": {
|