alemonjs 1.0.20 → 1.0.21

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/build.d.ts ADDED
@@ -0,0 +1 @@
1
+ export declare function commandBuild(): Promise<void>
@@ -1,22 +1,20 @@
1
- #!/usr/bin/env node
2
-
3
- import { compilationTools } from 'alemon-rollup'
4
- ;(async function run() {
5
- const ars = process.argv.slice(2)
6
- let Options = {
7
- input: 'apps/**/*.ts',
8
- output: 'alemon.app.js'
9
- }
10
- const i = ars.indexOf('--i')
11
- if (i != -1) {
12
- Options.input = ars[i + 1]
13
- }
14
- const o = ars.indexOf('--o')
15
- if (ars.indexOf('--o') != -1) {
16
- Options.output = ars[o + 1]
17
- }
18
- await compilationTools({
19
- aInput: Options.input,
20
- aOutput: Options.output
21
- })
22
- })()
1
+ import { compilationTools } from 'alemon-rollup'
2
+ export async function commandBuild() {
3
+ const ars = process.argv.slice(2)
4
+ const Options = {
5
+ input: 'apps/**/*.ts',
6
+ output: 'alemon.app.js'
7
+ }
8
+ const i = ars.indexOf('--i')
9
+ if (i != -1) {
10
+ Options.input = ars[i + 1]
11
+ }
12
+ const o = ars.indexOf('--o')
13
+ if (ars.indexOf('--o') != -1) {
14
+ Options.output = ars[o + 1]
15
+ }
16
+ await compilationTools({
17
+ aInput: Options.input,
18
+ aOutput: Options.output
19
+ })
20
+ }
package/lib/build.js ADDED
@@ -0,0 +1,20 @@
1
+ import { compilationTools } from 'alemon-rollup';
2
+ export async function commandBuild() {
3
+ const ars = process.argv.slice(2);
4
+ const Options = {
5
+ input: 'apps/**/*.ts',
6
+ output: 'alemon.app.js'
7
+ };
8
+ const i = ars.indexOf('--i');
9
+ if (i != -1) {
10
+ Options.input = ars[i + 1];
11
+ }
12
+ const o = ars.indexOf('--o');
13
+ if (ars.indexOf('--o') != -1) {
14
+ Options.output = ars[o + 1];
15
+ }
16
+ await compilationTools({
17
+ aInput: Options.input,
18
+ aOutput: Options.output
19
+ });
20
+ }
package/lib/core/apps.js CHANGED
@@ -24,8 +24,7 @@ export function getAppName(url) {
24
24
  * @returns
25
25
  */
26
26
  export function createApps(url) {
27
- const AppName = getAppPath(url);
28
- return createApp(AppName);
27
+ return createApp(getAppPath(url));
29
28
  }
30
29
  /**
31
30
  * 创建应用对象
package/lib/run.js ADDED
@@ -0,0 +1,25 @@
1
+ import { spawn } from 'child_process';
2
+ import { existsSync } from 'fs';
3
+ import { join } from 'path';
4
+ export function commandRun(ars) {
5
+ const msg = ars.join(' ');
6
+ const files = msg.match(/(\S+\.js|\S+\.ts)/g) ?? ['alemon.config.ts'];
7
+ const argsWithoutFiles = msg.replace(/(\S+\.js|\S+\.ts)/g, '');
8
+ for (const item of files) {
9
+ if (!existsSync(join(process.cwd(), item))) {
10
+ console.log('[NO FILE]', item);
11
+ continue;
12
+ }
13
+ const isTypeScript = item.endsWith('.ts');
14
+ const command = isTypeScript ? 'npx ts-node' : 'node';
15
+ const cmd = `${command} ${item} ${argsWithoutFiles}`;
16
+ console.log('[alemonjs]', cmd);
17
+ const childProcess = spawn(cmd, { shell: true });
18
+ childProcess.stdout.on('data', data => {
19
+ process.stdout.write(data.toString());
20
+ });
21
+ childProcess.stderr.on('data', data => {
22
+ process.stderr.write(data.toString());
23
+ });
24
+ }
25
+ }
package/package.json CHANGED
@@ -1,13 +1,11 @@
1
1
  {
2
2
  "name": "alemonjs",
3
- "version": "1.0.20",
3
+ "version": "1.0.21",
4
4
  "description": "阿柠檬框架",
5
5
  "author": "ningmengchongshui",
6
6
  "license": "GPL-2.0",
7
7
  "type": "module",
8
8
  "scripts": {
9
- "app": "alemonjs",
10
- "dev": "alemonjs dev",
11
9
  "tsc": "npx tsc",
12
10
  "format": "prettier --write .",
13
11
  "lint": "eslint . --ext .js,.ts --fix --ignore-path .gitignore"
@@ -50,20 +48,27 @@
50
48
  "lib",
51
49
  "types",
52
50
  "run.js",
53
- "run.d.ts"
51
+ "run.d.ts",
52
+ "build.js",
53
+ "build.d.ts"
54
54
  ],
55
55
  "exports": {
56
56
  ".": "./lib/index.js",
57
57
  "./run": {
58
58
  "import": "./run.js",
59
59
  "types": "./run.d.ts"
60
+ },
61
+ "./build": {
62
+ "import": "./build.js",
63
+ "types": "./build.d.ts"
64
+ },
65
+ "./core": {
66
+ "import": "./core.js",
67
+ "types": "./core.d.ts"
60
68
  }
61
69
  },
62
70
  "bin": {
63
- "alemonjs": "bin/main.js",
64
- "alemonjs-start": "bin/start.js",
65
- "alemonjs-build": "bin/build.js",
66
- "alemonjs-dev": "bin/dev.js"
71
+ "alemonjs": "bin/main.js"
67
72
  },
68
73
  "publishConfig": {
69
74
  "registry": "https://registry.npmjs.org"
@@ -0,0 +1 @@
1
+ export declare function commandBuild(): Promise<void>;
package/types/run.d.ts ADDED
@@ -0,0 +1 @@
1
+ export declare function commandRun(ars: string[]): void;
package/bin/dev.js DELETED
@@ -1,25 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- import { spawn } from 'child_process'
4
- import { existsSync } from 'fs'
5
- import { join } from 'path'
6
- const ars = process.argv.slice(2).push('dev')
7
- const msg = ars.join(' ')
8
- const files = msg.match(/(\S+\.js|\S+\.ts)/g) ?? ['alemon.config.ts']
9
- const argsWithoutFiles = msg.replace(/(\S+\.js|\S+\.ts)/g, '')
10
- for (const item of files) {
11
- if (!existsSync(join(process.cwd(), item))) {
12
- console.log('[NO FILE]', item)
13
- continue
14
- }
15
- // nodemon alemon.config.ts dev
16
- const cmd = `npx nodemon ${item} ${argsWithoutFiles}`
17
- console.log('[alemonjs]', cmd)
18
- const childProcess = spawn(cmd, { shell: true })
19
- childProcess.stdout.on('data', data => {
20
- process.stdout.write(data.toString())
21
- })
22
- childProcess.stderr.on('data', data => {
23
- process.stderr.write(data.toString())
24
- })
25
- }
package/bin/start.js DELETED
@@ -1,25 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- import { spawn } from 'child_process'
4
- import { existsSync } from 'fs'
5
- import { join } from 'path'
6
- const ars = process.argv.slice(2)
7
- const msg = ars.join(' ')
8
- const files = msg.match(/(\S+\.js|\S+\.ts)/g) ?? ['pm2.config.cjs']
9
- const argsWithoutFiles = msg.replace(/(\S+\.js|\S+\.ts)/g, '')
10
- for (const item of files) {
11
- if (!existsSync(join(process.cwd(), item))) {
12
- console.log('[NO FILE]', item)
13
- continue
14
- }
15
- // pm2 startOrRestart pm2.config.cjs
16
- const cmd = `npx pm2 startOrRestart ${item} ${argsWithoutFiles}`
17
- console.log('[alemonjs]', cmd)
18
- const childProcess = spawn(cmd, { shell: true })
19
- childProcess.stdout.on('data', data => {
20
- process.stdout.write(data.toString())
21
- })
22
- childProcess.stderr.on('data', data => {
23
- process.stderr.write(data.toString())
24
- })
25
- }