@exlg/cli-mod
Advanced tools
+32
-30
| { | ||
| "name": "@exlg/cli-mod", | ||
| "version": "1.2.4", | ||
| "description": "Command line interface for rapid exlg module development", | ||
| "bin": { | ||
| "exlg-mod": "bin/index.js" | ||
| }, | ||
| "type": "commonjs", | ||
| "keywords": [ | ||
| "exlg", | ||
| "cli" | ||
| ], | ||
| "author": "extend-luogu", | ||
| "license": "ISC", | ||
| "devDependencies": { | ||
| "@types/inquirer": "^8.2.1", | ||
| "@types/dedent": "^0.7.0", | ||
| "@types/node": "^18.0.0", | ||
| "esbuild": "^0.14.48" | ||
| }, | ||
| "dependencies": { | ||
| "commander": "^9.3.0", | ||
| "dedent": "^0.7.0", | ||
| "inquirer": "^8.0.0", | ||
| "esbuild": "^0.14.48" | ||
| }, | ||
| "scripts": { | ||
| "test": "ts-node src/index.ts", | ||
| "build": "esbuild src/index.ts --minify --bundle --platform=node --external:esbuild --outfile=bin/index.js" | ||
| } | ||
| } | ||
| "name": "@exlg/cli-mod", | ||
| "version": "1.3.0", | ||
| "description": "Command line interface for rapid exlg module development", | ||
| "bin": { | ||
| "exlg-mod": "bin/index.js" | ||
| }, | ||
| "type": "commonjs", | ||
| "scripts": { | ||
| "test": "ts-node src/index.ts", | ||
| "build": "esbuild src/index.ts --minify --bundle --platform=node --external:esbuild --external:esbuild-plugin-vue3 --outfile=bin/index.js", | ||
| "prepublishOnly": "npm run build" | ||
| }, | ||
| "keywords": [ | ||
| "exlg", | ||
| "cli" | ||
| ], | ||
| "author": "extend-luogu", | ||
| "license": "ISC", | ||
| "devDependencies": { | ||
| "@types/dedent": "^0.7.0", | ||
| "@types/inquirer": "^8.2.1", | ||
| "@types/node": "^18.0.0", | ||
| "esbuild": "^0.14.48" | ||
| }, | ||
| "dependencies": { | ||
| "commander": "^9.3.0", | ||
| "dedent": "^0.7.0", | ||
| "esbuild": "^0.14.48", | ||
| "esbuild-plugin-vue3": "^0.3.0", | ||
| "inquirer": "^8.0.0" | ||
| } | ||
| } |
+125
-38
@@ -59,6 +59,7 @@ #!/usr/bin/env node | ||
| let typescript: boolean | void | ||
| let useVue: boolean | void | ||
| let useSchema: boolean | void | ||
| if (useScript) { | ||
| ;({ typescript, useSchema } = await inquirer.prompt([ | ||
| ;({ typescript, useVue, useSchema } = await inquirer.prompt([ | ||
| { | ||
@@ -71,2 +72,8 @@ type: 'confirm', | ||
| type: 'confirm', | ||
| name: 'useVue', | ||
| message: '是否使用 Vue?', | ||
| default: false | ||
| }, | ||
| { | ||
| type: 'confirm', | ||
| name: 'useSchema', | ||
@@ -103,3 +110,3 @@ message: '是否使用 Schema?' | ||
| ((options.official && 'workspace:^') || | ||
| '^1.1.0')) || | ||
| '^1.3.0')) || | ||
| undefined, | ||
@@ -109,7 +116,8 @@ schemastery: useSchema ? '^3.4.3' : undefined | ||
| devDependencies: { | ||
| '@exlg/cli-mod': '^1.1.1' | ||
| '@exlg/cli-mod': '^1.1.1', | ||
| vue: useVue ? '^3.2.37' : undefined | ||
| } | ||
| }, | ||
| null, | ||
| 2 | ||
| 4 | ||
| ) | ||
@@ -135,9 +143,9 @@ ) | ||
| dedent` | ||
| import Schema from 'schemastery' | ||
| import Schema from 'schemastery' | ||
| export default Schema.object({ | ||
| // your static schema here | ||
| // see <https://github.com/shigma/schemastery> | ||
| hello: Schema.string().default('world') | ||
| }) | ||
| export default Schema.object({ | ||
| // your static schema here | ||
| // see <https://github.com/shigma/schemastery> | ||
| hello: Schema.string().default('world') | ||
| }) | ||
| ` + '\n' | ||
@@ -160,2 +168,38 @@ ) | ||
| if (useVue) { | ||
| imports.push("import App from './App.vue'") | ||
| main.push( | ||
| '', | ||
| 'const { Vue } = window.exlgDash', | ||
| 'const { createApp } = Vue', | ||
| "createApp(App).mount('#id') // mount the app to the element you want" | ||
| ) | ||
| await fs.writeFile( | ||
| path.resolve(name, 'src', 'App.vue'), | ||
| dedent` | ||
| <script setup${typescript ? ' lang="ts"' : ''}> | ||
| import '@exlg/core/types' | ||
| const { Vue } = window.exlgDash | ||
| const { ref } = Vue | ||
| const count = ref(0) | ||
| </script> | ||
| <template> | ||
| <div> | ||
| <p>You clicked {{ count }} times</p> | ||
| <button class="exlg-button" @click="count++">+1s</button> | ||
| </div> | ||
| </template> | ||
| <style> | ||
| /* style is OK, but not scoped */ | ||
| </style> | ||
| ` | ||
| ) | ||
| } | ||
| await fs.writeFile( | ||
@@ -170,17 +214,54 @@ path.resolve(name, 'src', `index.${scriptExt}`), | ||
| JSON.stringify( | ||
| { | ||
| compilerOptions: { | ||
| target: 'es6', | ||
| lib: ['esnext', 'dom'], | ||
| module: 'commonjs', | ||
| esModuleInterop: true, | ||
| forceConsistentCasingInFileNames: true, | ||
| strict: true | ||
| }, | ||
| include: ['./src/'] | ||
| }, | ||
| useVue | ||
| ? { | ||
| compilerOptions: { | ||
| target: 'es6', | ||
| useDefineForClassFields: true, | ||
| module: 'esnext', | ||
| moduleResolution: 'node', | ||
| strict: true, | ||
| jsx: 'preserve', | ||
| sourceMap: true, | ||
| resolveJsonModule: true, | ||
| isolatedModules: true, | ||
| esModuleInterop: true, | ||
| lib: ['esnext', 'dom'], | ||
| skipLibCheck: true | ||
| }, | ||
| include: [ | ||
| 'src/**/*.ts', | ||
| 'src/**/*.d.ts', | ||
| 'src/**/*.tsx', | ||
| 'src/**/*.vue' | ||
| ] | ||
| } | ||
| : { | ||
| compilerOptions: { | ||
| target: 'es6', | ||
| lib: ['esnext', 'dom'], | ||
| module: 'commonjs', | ||
| esModuleInterop: true, | ||
| forceConsistentCasingInFileNames: true, | ||
| strict: true | ||
| }, | ||
| include: ['./src/'] | ||
| }, | ||
| null, | ||
| 2 | ||
| 4 | ||
| ) | ||
| ) | ||
| if (useVue) { | ||
| await fs.writeFile( | ||
| path.resolve(name, 'src', 'env.d.ts'), | ||
| dedent` | ||
| declare module '*.vue' { | ||
| import type { DefineComponent } from 'vue' | ||
| // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/ban-types | ||
| const component: DefineComponent<{}, {}, any> | ||
| export default component | ||
| } | ||
| ` | ||
| ) | ||
| } | ||
| } | ||
@@ -230,4 +311,16 @@ } | ||
| const useTs = await fileOk('./src/index.ts') | ||
| const useCss = await fileOk('./src/index.css') | ||
| if (useJs || useTs) { | ||
| const useVue = await fileOk('./src/App.vue') | ||
| const plugins = [] | ||
| if (useVue) { | ||
| const vuePlugin = await import('esbuild-plugin-vue3') | ||
| plugins.push(vuePlugin.default() as esbuild.Plugin) | ||
| } | ||
| const entryPoints = [`./src/index.${useTs ? 'ts' : 'js'}`] | ||
| if (useCss) entryPoints.push('./src/index.css') | ||
| await esbuild.build({ | ||
@@ -238,6 +331,15 @@ entryPoints: [`./src/index.${useTs ? 'ts' : 'js'}`], | ||
| bundle: true, | ||
| minify: true, | ||
| // minify: true, | ||
| plugins, | ||
| outfile: 'dist/bundle.js' | ||
| }) | ||
| if (await fileOk('./dist/bundle.css')) | ||
| exports.push([ | ||
| 'style', | ||
| JSON.stringify( | ||
| await fs.readFile('./dist/bundle.css', 'utf-8') | ||
| ) | ||
| ]) | ||
| exports.push([ | ||
@@ -272,17 +374,2 @@ 'entry', | ||
| const useCss = await fileOk('./src/index.css') | ||
| if (useCss) { | ||
| const minifiedCss = ( | ||
| await esbuild.transform( | ||
| await fs.readFile('./src/index.css', 'utf-8'), | ||
| { | ||
| loader: 'css', | ||
| charset: 'utf8', | ||
| minify: true | ||
| } | ||
| ) | ||
| ).code | ||
| exports.push(['style', JSON.stringify(minifiedCss)]) | ||
| } | ||
| if (!useJs && !useTs && !useCss) { | ||
@@ -289,0 +376,0 @@ return console.error('💥 未找到任何脚本或样式入口点,构建失败') |
Sorry, the diff of this file is too big to display
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 14 instances in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 14 instances in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
943896
0.66%4041
2.59%5
25%+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added