@airiot/cli 1.0.1 → 1.0.2

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.
@@ -71,6 +71,9 @@ export default defineConfig([
71
71
  'import/no-self-import': 'error',
72
72
  'import/no-cycle': 'error',
73
73
  'import/no-useless-path-segments': 'error',
74
+ 'import/export': 'error',
75
+ 'import/named': 'error',
76
+ 'import/default': 'error',
74
77
 
75
78
  // 1. 变量先使用后定义问题
76
79
  'no-use-before-define': ['error', {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@airiot/cli",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "AIRIOT平台前端包管理工具",
5
5
  "type": "module",
6
6
  "scripts": {},
@@ -25,37 +25,37 @@
25
25
  "author": "",
26
26
  "license": "ISC",
27
27
  "dependencies": {
28
- "@eslint/js": "^9.38.0",
29
- "@vitejs/plugin-legacy": "^5.2.0",
30
- "@vitejs/plugin-react": "^4.2.0",
31
- "archiver": "^5.0.2",
32
- "axios": "^1.6.2",
33
- "chalk": "^4.1.0",
34
- "commander": "^6.2.0",
28
+ "@eslint/js": "^9.39.0",
29
+ "@vitejs/plugin-legacy": "^7.2.1",
30
+ "@vitejs/plugin-react": "^5.1.0",
31
+ "archiver": "^7.0.1",
32
+ "axios": "^1.13.1",
33
+ "chalk": "^5.6.2",
34
+ "commander": "^14.0.2",
35
35
  "connect-history-api-fallback": "^2.0.0",
36
36
  "cross-spawn": "^7.0.3",
37
- "eslint": "^9.38.0",
37
+ "eslint": "^9.39.0",
38
38
  "eslint-plugin-import": "^2.32.0",
39
39
  "eslint-plugin-react": "^7.37.5",
40
- "form-data": "^3.0.0",
40
+ "form-data": "^4.0.4",
41
41
  "globals": "^16.4.0",
42
42
  "i18next-scanner": "^4.4.0",
43
- "inquirer": "^7.3.3",
44
- "less": "^4.0.0",
43
+ "inquirer": "^12.10.0",
44
+ "less": "^4.4.2",
45
45
  "md5": "^2.3.0",
46
- "node-fetch": "^2.6.1",
47
- "npm-packlist": "^2.1.4",
48
- "pacote": "^11.3.0",
46
+ "node-fetch": "^3.3.2",
47
+ "npm-packlist": "^10.0.3",
48
+ "pacote": "^21.0.3",
49
49
  "path-browserify": "^1.0.1",
50
50
  "portfinder": "^1.0.28",
51
51
  "scp2": "^0.5.0",
52
52
  "svg-inline-loader": "^0.8.2",
53
53
  "terser": "^5.25.0",
54
54
  "vinyl-fs": "^4.0.0",
55
- "vite": "^5.0.0",
55
+ "vite": "^7.1.12",
56
56
  "vite-plugin-commonjs": "^0.10.1",
57
57
  "vite-plugin-css-injected-by-js": "^3.3.0",
58
- "vite-plugin-external": "^4.0.1",
58
+ "vite-plugin-external": "^6.2.2",
59
59
  "vite-plugin-require-transform": "^1.0.21"
60
60
  }
61
61
  }
@@ -33,8 +33,9 @@ console.log(chalk.green('[iot:envs] 请求 IOT_URL 为: ' + host));
33
33
  const server = await preview({
34
34
  configFile: false,
35
35
  root: paths.appPath,
36
- plugins: await plugins(),
36
+ plugins: await plugins('preview'),
37
37
  preview: {
38
+ host: true,
38
39
  proxy,
39
40
  port: DEFAULT_PORT,
40
41
  open: true
package/scripts/start.js CHANGED
@@ -33,7 +33,7 @@ console.log(chalk.green('[iot:envs] 请求 IOT_URL 为: ' + host));
33
33
  const server = await createServer({
34
34
  configFile: false,
35
35
  root: paths.appPath,
36
- plugins: await plugins(),
36
+ plugins: await plugins('dev'),
37
37
  server: {
38
38
  proxy,
39
39
  port: DEFAULT_PORT,
@@ -1,5 +1,4 @@
1
1
  import react from '@vitejs/plugin-react'
2
- import legacy from '@vitejs/plugin-legacy'
3
2
  import commonjs from 'vite-plugin-commonjs'
4
3
  import cssInjectedByJsPlugin from 'vite-plugin-css-injected-by-js'
5
4
 
@@ -38,21 +37,12 @@ const getPlugins = async (mode) => {
38
37
  }),
39
38
  jsInJsxPlugin(),
40
39
  svgInline(),
41
- airiotPlugin({}),
40
+ airiotPlugin(mode),
42
41
  lazyImportPlugin(),
43
42
  airiotHtmlPlugin(),
44
43
  buildinfoPlugin()
45
44
  ]
46
45
 
47
- if(mode == 'build') {
48
- // plugins.push(legacy({
49
- // targets: ['defaults', 'not IE 11'],
50
- // externalSystemJS: true
51
- // }))
52
- } else {
53
-
54
- }
55
-
56
46
  try {
57
47
  const appPlugin = await import(new URL(`file://${paths.appVitePlugin}`));
58
48
  plugins.push(appPlugin.default());
@@ -25,11 +25,12 @@ let frontScripts = (developConfig && typeof developConfig.scripts == 'function')
25
25
  && developConfig.scripts(basePath, 'front') || []
26
26
 
27
27
  let scriptsAppend = appPackage.name == '@airiot/core'
28
-
29
- let dllScript = basePath + ('/@airiot/dll/dist/iot.js')
28
+ let dllScript = basePath + '/@airiot/dll/dist/iot.min.js',
29
+ dllDevScript = basePath + '/@airiot/dll/dist/iot.js';
30
30
  const filterDll = s => {
31
31
  if(s.indexOf("@airiot/dll") >= 0) {
32
32
  dllScript = s
33
+ dllDevScript = s
33
34
  return false
34
35
  }
35
36
  return true
@@ -54,22 +55,22 @@ const addPublicPath = (path, publicPath) => {
54
55
  return publicPath + path
55
56
  }
56
57
 
57
- const getHtmlScripts = (html, isAdmin) => {
58
+ const getHtmlScripts = (html, isAdmin, mode) => {
58
59
  const appendScripts = isAdmin ? scripts : frontScripts
59
60
  return [
60
61
  { tag: 'script', attrs: { }, children: 'window._r = s => s; window._t1 = s => s', injectTo: 'body-prepend' },
61
- { tag: 'script', attrs: { src: dllScript }, injectTo: 'body' },
62
- ...appendScripts.map(script => ({ tag: 'script', attrs: { src: addPublicPath(script, ''), type: 'module' }, injectTo: 'body' })),
62
+ { tag: 'script', attrs: { src: mode == 'dev' ? dllDevScript : dllScript }, injectTo: 'body' },
63
+ ...appendScripts.map(script => ({ tag: 'script', attrs: { src: addPublicPath(script, '') }, injectTo: 'body' })),
63
64
  { tag: 'script', attrs: { type: 'module' }, children: '__app__.start()', injectTo: 'body' },
64
65
  ]
65
66
  }
66
67
 
67
- const airiotPlugin = () => {
68
+ const airiotPlugin = (mode) => {
68
69
  return {
69
70
  name: 'airiot',
70
71
  enforce: 'pre',
71
72
  transformIndexHtml(html, ctx) {
72
- return getHtmlScripts(html, ctx.path == '/admin.html')
73
+ return getHtmlScripts(html, ctx.path == '/admin.html', mode)
73
74
  },
74
75
  configurePreviewServer(server) {
75
76
  // 返回一个钩子,会在其他中间件安装完成后调用
@@ -77,7 +78,7 @@ const airiotPlugin = () => {
77
78
  server.middlewares.use((req, res, next) => {
78
79
  // 自定义处理请求 ...
79
80
  if(req.url == '/index.html') {
80
- let scripts = getHtmlScripts(htmlTpl, true)
81
+ let scripts = getHtmlScripts(htmlTpl, true, mode)
81
82
  scripts = [ ...scripts.slice(0, scripts.length - 1), {
82
83
  tag: 'script', attrs: { src: 'index.js', type: 'module' }, injectTo: 'body'
83
84
  }, scripts[scripts.length - 1] ]