@qse/edu-scripts 0.0.0-beta.2 → 0.0.0-beta.4

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.
Files changed (81) hide show
  1. package/babel.config.json +4 -1
  2. package/dist/cli.d.mts +1 -0
  3. package/dist/cli.mjs +1440 -0
  4. package/dist/index.d.mts +89 -0
  5. package/dist/index.mjs +13 -0
  6. package/eslint.config.mjs +1 -1
  7. package/package.json +16 -10
  8. package/src/{auto-refactor.js → auto-refactor.ts} +6 -10
  9. package/src/{build.js → build.ts} +15 -7
  10. package/src/{cli.js → cli.ts} +14 -13
  11. package/src/{commit-dist.js → commit-dist.ts} +24 -15
  12. package/src/config/{paths.js → paths.ts} +17 -2
  13. package/src/config/plugins/mock-server/{index.js → index.ts} +15 -17
  14. package/src/config/plugins/{postcss-safe-area.js → postcss-safe-area.ts} +4 -2
  15. package/src/config/webpackConfig.js +37 -14
  16. package/src/config/webpackDevServerConfig.js +2 -3
  17. package/src/{deploy.js → deploy.ts} +23 -15
  18. package/src/{generator.js → generator.ts} +2 -10
  19. package/src/index.ts +2 -2
  20. package/src/{start.js → start.ts} +11 -6
  21. package/src/utils/FileSizeReporter.js +2 -2
  22. package/src/utils/{appConfig.js → appConfig.ts} +1 -1
  23. package/src/utils/{beforeStart.js → beforeStart.ts} +14 -5
  24. package/src/utils/changeDeployVersion.js +3 -3
  25. package/src/utils/defineConfig.ts +4 -4
  26. package/src/utils/{exec.js → exec.ts} +1 -1
  27. package/src/utils/{getConfig.js → getConfig.ts} +6 -4
  28. package/src/utils/{getOverride.js → getOverride.ts} +6 -8
  29. package/tsconfig.json +2 -3
  30. package/tsdown.config.ts +5 -0
  31. package/docs/.vitepress/config.ts +0 -35
  32. package/docs/changelog.md +0 -1
  33. package/docs/debug.md +0 -17
  34. package/docs/deploy.md +0 -54
  35. package/docs/faq.md +0 -144
  36. package/docs/feat.md +0 -167
  37. package/docs/grayscale.md +0 -31
  38. package/docs/index.md +0 -15
  39. package/docs/install.md +0 -1
  40. package/docs/mode.md +0 -42
  41. package/docs/override.md +0 -193
  42. package/docs/refactor-react-16.md +0 -37
  43. package/docs/refactor.md +0 -67
  44. package/docs/static.md +0 -24
  45. package/es/auto-refactor.js +0 -153
  46. package/es/build.js +0 -58
  47. package/es/cli.js +0 -65
  48. package/es/commit-dist.js +0 -83
  49. package/es/config/paths.js +0 -39
  50. package/es/config/plugins/mock-server/defineMock.d.ts +0 -6
  51. package/es/config/plugins/mock-server/defineMock.js +0 -7
  52. package/es/config/plugins/mock-server/index.js +0 -122
  53. package/es/config/plugins/postcss-safe-area.js +0 -22
  54. package/es/config/plugins/ws-utils-createSocketURL.js +0 -98
  55. package/es/config/webpackConfig.js +0 -421
  56. package/es/config/webpackDevServerConfig.js +0 -73
  57. package/es/deploy.js +0 -148
  58. package/es/generator.js +0 -52
  59. package/es/index.d.ts +0 -2
  60. package/es/index.js +0 -7
  61. package/es/start.js +0 -45
  62. package/es/utils/FileSizeReporter.js +0 -107
  63. package/es/utils/appConfig.js +0 -35
  64. package/es/utils/beforeStart.js +0 -51
  65. package/es/utils/changeDeployVersion.js +0 -85
  66. package/es/utils/defineConfig.d.ts +0 -83
  67. package/es/utils/defineConfig.js +0 -7
  68. package/es/utils/exec.js +0 -10
  69. package/es/utils/getConfig.js +0 -23
  70. package/es/utils/getOverride.js +0 -28
  71. package/src/asset/dll/libcommon3-manifest.json +0 -181
  72. package/src/asset/template/edu-app-env.d.ts.tpl +0 -20
  73. package/src/asset/template/edu-scripts.override.js.tpl +0 -7
  74. package/src/asset/template/tailwind.config.js.tpl +0 -11
  75. package/src/asset/template/tsconfig.json.tpl +0 -24
  76. /package/{es/asset → asset}/dll/libcommon3-manifest.json +0 -0
  77. /package/{es/asset → asset}/template/edu-app-env.d.ts.tpl +0 -0
  78. /package/{es/asset → asset}/template/edu-scripts.override.js.tpl +0 -0
  79. /package/{es/asset → asset}/template/tailwind.config.js.tpl +0 -0
  80. /package/{es/asset → asset}/template/tsconfig.json.tpl +0 -0
  81. /package/{src/config/plugins → asset}/ws-utils-createSocketURL.js +0 -0
@@ -1,4 +1,4 @@
1
- import setupMockServer from './plugins/mock-server/index.js'
1
+ import setupMockServer from './plugins/mock-server'
2
2
 
3
3
  function createProxy(context, target, origin) {
4
4
  const url = new URL(origin || target)
@@ -17,7 +17,7 @@ function createProxy(context, target, origin) {
17
17
 
18
18
  /**
19
19
  * @param {*} args
20
- * @param {import('../utils/defineConfig').Config} override
20
+ * @param {import('../utils/defineConfig.js').Configuration} override
21
21
  */
22
22
  export default function getWebpackDevServerConfig(args, override) {
23
23
  const host = process.env.HOST || '0.0.0.0'
@@ -27,7 +27,6 @@ export default function getWebpackDevServerConfig(args, override) {
27
27
  allowedHosts: 'all',
28
28
  historyApiFallback: true,
29
29
  port: args.port,
30
- open: args.open,
31
30
  host,
32
31
  client: {
33
32
  webSocketURL: 'auto://0.0.0.0:0/ws',
@@ -1,9 +1,10 @@
1
+ // @ts-ignore
1
2
  import { sshSftp } from '@qse/ssh-sftp'
2
- import path from 'path'
3
3
  import paths from './config/paths.js'
4
4
  import chalk from 'chalk'
5
5
  import fs from 'fs-extra'
6
- import changeDeployVersion from './utils/changeDeployVersion.js'
6
+ // @ts-ignore
7
+ import changeDeployVersion from './utils/changeDeployVersion'
7
8
  import ora from 'ora'
8
9
  import appConfig from './utils/appConfig.js'
9
10
  import { format } from 'prettier'
@@ -19,8 +20,8 @@ const baseConfig = {
19
20
  noWarn: true,
20
21
  }
21
22
 
22
- async function normalDeploy(args) {
23
- const resolve = (...pathSegments) => path.resolve(process.cwd(), ...pathSegments)
23
+ async function normalDeploy(args: DeployArgs) {
24
+ const resolve = paths.resolveApp
24
25
 
25
26
  /**
26
27
  * 生成路径
@@ -30,7 +31,7 @@ async function normalDeploy(args) {
30
31
  * @name tmpBase 本地临时文件夹 到`__tmp__`层
31
32
  * @param {string} remoteFilePath 远程文件相对`opts.remotePath`地址
32
33
  */
33
- function getLocalAndRemoteFilePath(remoteFilePath, opts) {
34
+ function getLocalAndRemoteFilePath(remoteFilePath: string, opts: any) {
34
35
  const splited = remoteFilePath.split('/')
35
36
  const fileName = splited[splited.length - 1]
36
37
  const tmpBase = resolve(opts.localPath, '__tmp__')
@@ -47,13 +48,13 @@ async function normalDeploy(args) {
47
48
  date = new Date(date.getTime() - date.getTimezoneOffset() * 60000)
48
49
  return date.toISOString().replace(/T/, ' ').replace(/\..+/, '')
49
50
  }
50
- function updateLogContent(content, info) {
51
+ function updateLogContent(content: string, info: any) {
51
52
  const lines = content.trim().split('\n')
52
53
  lines.push(`[${dateTime()}] ${JSON.stringify(info)}\n`)
53
54
  return lines.slice(-50).join('\n')
54
55
  }
55
56
 
56
- async function upload(opts) {
57
+ async function upload(opts: any) {
57
58
  // 上传dist文件
58
59
  const { sftp, opts: fullOpts } = await sshSftp(opts)
59
60
 
@@ -95,14 +96,14 @@ async function normalDeploy(args) {
95
96
  try {
96
97
  await sftp.fastGet(remoteLogFile, tmpLogFile)
97
98
  content = await fs.readFile(tmpLogFile, 'utf-8')
98
- } catch (error) {}
99
+ } catch (_error: any) {}
99
100
  content = updateLogContent(content, info)
100
101
  await fs.writeFile(tmpLogFile, content)
101
102
  await sftp.fastPut(tmpLogFile, remoteLogFile)
102
103
  }
103
104
 
104
105
  spinner.succeed('已更新 ver.js 版本配置')
105
- } catch (e) {
106
+ } catch (e: any) {
106
107
  spinner.fail(`自动修改 ver.js 失败,请手动修改`)
107
108
  console.log(chalk.bgRed(e.message))
108
109
  } finally {
@@ -123,19 +124,19 @@ async function normalDeploy(args) {
123
124
  },
124
125
  }
125
126
  const uploadSftpConfigs = []
126
- if (args.b) {
127
+ if (args.bureau) {
127
128
  uploadSftpConfigs.push(presetConfig.b)
128
129
  }
129
- if (args.s) {
130
+ if (args.school) {
130
131
  uploadSftpConfigs.push(presetConfig.s)
131
132
  }
132
- if (args.d) {
133
+ if (args.documentshelves) {
133
134
  uploadSftpConfigs.push(presetConfig.d)
134
135
  }
135
- if (args.c) {
136
+ if (args.compositionshelves) {
136
137
  uploadSftpConfigs.push(presetConfig.c)
137
138
  }
138
- if (args.cd) {
139
+ if (args.compositionshelvesDingtalk) {
139
140
  uploadSftpConfigs.push(presetConfig.cd)
140
141
  }
141
142
  if (uploadSftpConfigs.length === 0) {
@@ -173,7 +174,14 @@ async function singleDeploy() {
173
174
  sshSftp(config)
174
175
  }
175
176
 
176
- export default function deploy(args) {
177
+ interface DeployArgs {
178
+ school?: boolean
179
+ bureau?: boolean
180
+ documentshelves?: boolean
181
+ compositionshelves?: boolean
182
+ compositionshelvesDingtalk?: boolean
183
+ }
184
+ export default function deploy(args: DeployArgs) {
177
185
  if (appConfig.single) {
178
186
  singleDeploy()
179
187
  } else {
@@ -1,16 +1,8 @@
1
- import path from 'path'
2
1
  import fs from 'fs-extra'
3
- import paths from './config/paths.js'
2
+ import paths from './config/paths'
4
3
  import chalk from 'chalk'
5
- import { fileURLToPath } from 'node:url'
6
4
 
7
- const __dirname = path.dirname(fileURLToPath(import.meta.url))
8
-
9
- /**
10
- * @param {string[]} args
11
- * @returns {string}
12
- */
13
- const getTmpPath = (...args) => path.resolve(__dirname, 'asset', 'template', ...args)
5
+ const getTmpPath = (...args: string[]) => paths.resolveOwn('asset', 'template', ...args)
14
6
 
15
7
  async function generatorOverride() {
16
8
  if (fs.existsSync(paths.override)) {
package/src/index.ts CHANGED
@@ -1,2 +1,2 @@
1
- export { defineConfig } from './utils/defineConfig.js'
2
- export { defineMock } from './config/plugins/mock-server/defineMock.js'
1
+ export { defineConfig } from './utils/defineConfig'
2
+ export { defineMock } from './config/plugins/mock-server/defineMock'
@@ -3,13 +3,17 @@ import { RspackDevServer } from '@rspack/dev-server'
3
3
  import getConfig from './utils/getConfig.js'
4
4
  import chalk from 'chalk'
5
5
 
6
- export default async function start(args) {
6
+ interface StartArgs {
7
+ port?: string
8
+ }
9
+ export default async function start(args: StartArgs) {
7
10
  process.env.NODE_ENV = 'development'
8
11
  process.env.BABEL_ENV = 'development'
9
12
  process.env.BROWSERSLIST = 'chrome >= 70'
10
13
  process.env.WEBPACK_DEV_SERVER_BASE_PORT = '3000'
11
14
 
12
15
  const basePort = process.env.WEBPACK_DEV_SERVER_BASE_PORT
16
+ // @ts-ignore
13
17
  const port = await RspackDevServer.getFreePort(args.port || process.env.PORT)
14
18
  if (!(args.port || process.env.PORT) && +port !== +basePort) {
15
19
  console.log(chalk.bgYellow(`${basePort} 端口已被占用,现切换到 ${port} 端口运行`))
@@ -17,19 +21,20 @@ export default async function start(args) {
17
21
  args.port = port
18
22
  process.env.PORT = port
19
23
 
20
- const compiler = rspack(getConfig(args))
24
+ const config = getConfig(args)
25
+ const compiler = rspack(config)
21
26
  const middleware = rspack.lazyCompilationMiddleware(compiler)
22
- const oldSetupMiddlewares = compiler.options.devServer.setupMiddlewares
23
- compiler.options.devServer.setupMiddlewares = (middlewares, devServer) => {
27
+ const oldSetupMiddlewares = config.devServer.setupMiddlewares
28
+ config.devServer.setupMiddlewares = (middlewares: any, devServer: any) => {
24
29
  if (oldSetupMiddlewares) {
25
30
  middlewares = oldSetupMiddlewares(middlewares, devServer)
26
31
  }
27
32
  middlewares.unshift(middleware)
28
33
  return middlewares
29
34
  }
30
- const devServer = new RspackDevServer(compiler.options.devServer, compiler)
35
+ const devServer = new RspackDevServer(config.devServer, compiler)
31
36
  devServer.start()
32
- ;[('SIGINT', 'SIGTERM')].forEach(function (sig) {
37
+ ;['SIGINT', 'SIGTERM'].forEach(function (sig) {
33
38
  process.on(sig, function () {
34
39
  devServer.stop()
35
40
  process.exit()
@@ -5,7 +5,7 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
 
8
- import fs from 'fs'
8
+ import fs from 'fs-extra'
9
9
  import path from 'path'
10
10
  import chalk from 'chalk'
11
11
  import filesize from 'filesize'
@@ -58,7 +58,7 @@ function printFileSizesAfterBuild(
58
58
  assets.sort((a, b) => b.size - a.size)
59
59
 
60
60
  // move main file to first
61
- var mainAssetIdx = assets.findIndex((asset) => /_\d+\.\d+\.\d+\./.test(asset.name))
61
+ var mainAssetIdx = assets.findIndex((asset) => /_\d+\.\d+\.\d+/.test(asset.name))
62
62
  assets.unshift(assets.splice(mainAssetIdx, 1)[0])
63
63
 
64
64
  var longestSizeLabelLength = Math.max.apply(
@@ -1,4 +1,4 @@
1
- import paths from '../config/paths.js'
1
+ import paths from '../config/paths'
2
2
  import fs from 'fs-extra'
3
3
 
4
4
  const appPkg = fs.readJsonSync(paths.package)
@@ -1,12 +1,10 @@
1
1
  import fs from 'fs-extra'
2
- import paths from '../config/paths.js'
2
+ import paths from '../config/paths'
3
3
  import chalk from 'chalk'
4
4
  import semver from 'semver'
5
- import appConfig from './appConfig.js'
6
- import { fileURLToPath } from 'node:url'
7
-
8
- const pkg = fs.readJsonSync(fileURLToPath(import.meta.resolve('../../package.json')))
5
+ import appConfig from './appConfig'
9
6
 
7
+ const pkg = fs.readJsonSync(paths.resolveOwn('package.json'))
10
8
  const appPkg = fs.readJsonSync(paths.package)
11
9
 
12
10
  if (semver.valid(appPkg.version) === null) {
@@ -53,3 +51,14 @@ if (appPkg.browserslist) {
53
51
  delete appPkg.browserslist
54
52
  fs.writeFileSync(paths.package, JSON.stringify(appPkg, null, 2), 'utf-8')
55
53
  }
54
+
55
+ if (appPkg.eslintConfig) {
56
+ console.log(
57
+ chalk.yellow('package.json 中 eslintConfig 已废弃,请改用 @qse/eslint-config 进行配置')
58
+ )
59
+ console.log(chalk.yellow('npm i eslint @qse/eslint-config -D'))
60
+ console.log()
61
+ console.log(chalk.gray('新建 eslint.config.mjs 文件,内容如下:'))
62
+ console.log(chalk.yellow('import config from "@qse/eslint-config"'))
63
+ console.log(chalk.yellow('export default config'))
64
+ }
@@ -8,9 +8,9 @@ function changeDeployVersion(code, pkg) {
8
8
  const { name, version, grayscale } = pkg
9
9
  let ast
10
10
  try {
11
- ast = parse(code)
11
+ ast = parse(code, { filename: 'ver.js' })
12
12
  } catch (error) {
13
- throw new Error(`代码解析错误: ${error.message}`)
13
+ throw new Error(`代码解析错误: ${error.message}`, { cause: error })
14
14
  }
15
15
  const keyName = grayscale ? 'grayscale' : 'main'
16
16
 
@@ -113,7 +113,7 @@ function changeDeployVersion(code, pkg) {
113
113
  }
114
114
  deleteModuleComments(targetPath)
115
115
 
116
- return transformFromAstSync(ast, undefined, { minified: true }).code
116
+ return transformFromAstSync(ast, undefined, { filename: 'ver.js', minified: true }).code
117
117
  }
118
118
 
119
119
  export default changeDeployVersion
@@ -1,5 +1,5 @@
1
1
  import type { Chalk } from 'chalk'
2
- import type { Compiler, Configuration } from '@rspack/core'
2
+ import type { Compiler, Configuration as RspackConfiguration } from '@rspack/core'
3
3
  import type { Configuration as DevServerConfiguration } from '@rspack/dev-server'
4
4
 
5
5
  type ProxyConfigArray = NonNullable<DevServerConfiguration['proxy']>
@@ -11,8 +11,8 @@ export type BabelImportPlugin = {
11
11
  style?: boolean | 'css' | string
12
12
  }
13
13
 
14
- export type Config = {
15
- webpack?: (config: Configuration) => Configuration | undefined
14
+ export type Configuration = {
15
+ webpack?: (config: RspackConfiguration) => RspackConfiguration | undefined
16
16
  devServer?: (config: DevServerConfiguration) => DevServerConfiguration | undefined
17
17
  /**
18
18
  * webpack alias 配置,会与内置 alias 合并
@@ -83,6 +83,6 @@ export type Config = {
83
83
  */
84
84
  import?: BabelImportPlugin[]
85
85
  }
86
- export function defineConfig(config: Config) {
86
+ export function defineConfig(config: Configuration) {
87
87
  return config
88
88
  }
@@ -1,5 +1,5 @@
1
1
  import cp from 'child_process'
2
- const exec = (cmd) => {
2
+ const exec = (cmd: string) => {
3
3
  console.log(`> ${cmd}`)
4
4
  return cp.execSync(cmd, { stdio: 'inherit', encoding: 'utf-8' })
5
5
  }
@@ -1,8 +1,10 @@
1
- import getWebpackConfig from '../config/webpackConfig.js'
2
- import getWebpackDevServerConfig from '../config/webpackDevServerConfig.js'
3
- import getOverride from './getOverride.js'
1
+ // @ts-ignore
2
+ import getWebpackConfig from '../config/webpackConfig'
3
+ // @ts-ignore
4
+ import getWebpackDevServerConfig from '../config/webpackDevServerConfig'
5
+ import getOverride from './getOverride'
4
6
 
5
- function getConfig(args) {
7
+ function getConfig(args: any) {
6
8
  const override = getOverride()
7
9
 
8
10
  let webpackConfig = getWebpackConfig(args, override)
@@ -1,10 +1,11 @@
1
1
  import fs from 'fs-extra'
2
- import paths from '../config/paths.js'
2
+ import paths from '../config/paths'
3
3
  import { createRequire } from 'node:module'
4
+ import { type Configuration } from './defineConfig'
5
+
4
6
  const require = createRequire(import.meta.url)
5
7
 
6
- /** @type {import('./defineConfig').Config} */
7
- const defaultOverride = {
8
+ const defaultOverride: Configuration = {
8
9
  minify: true,
9
10
  proxy: [],
10
11
  extraPostCSSPlugins: [],
@@ -12,12 +13,9 @@ const defaultOverride = {
12
13
  pure_funcs: ['console.log'],
13
14
  }
14
15
 
15
- let override = null
16
+ let override: Configuration | null = null
16
17
 
17
- /**
18
- * @return {import('./defineConfig').Config}
19
- */
20
- export default function getOverride() {
18
+ export default function getOverride(): Configuration {
21
19
  if (override) return override
22
20
 
23
21
  override = Object.assign({}, defaultOverride)
package/tsconfig.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "compilerOptions": {
3
3
  "target": "esnext",
4
- "module": "node16",
5
- "moduleResolution": "node16",
4
+ "module": "preserve",
5
+ "moduleResolution": "bundler",
6
6
  "importHelpers": true,
7
7
  "jsx": "react",
8
8
  "esModuleInterop": true,
@@ -11,7 +11,6 @@
11
11
  "strict": true,
12
12
  "paths": {
13
13
  "@/*": ["src/*"],
14
- "@@/*": ["src/.umi/*"]
15
14
  },
16
15
  "allowSyntheticDefaultImports": true,
17
16
  "skipLibCheck": true,
@@ -0,0 +1,5 @@
1
+ import { defineConfig } from 'tsdown'
2
+
3
+ export default defineConfig({
4
+ entry: ['src/index.ts', 'src/cli.js'],
5
+ })
@@ -1,35 +0,0 @@
1
- import { defineConfig } from 'vitepress'
2
- import fs from 'fs-extra'
3
- import path from 'path'
4
-
5
- const mds = fs.readdirSync(path.resolve(import.meta.dirname, '..')).filter((s) => s.endsWith('.md'))
6
-
7
- const sidebarItems = mds
8
- .map((file) => {
9
- const md = fs.readFileSync(path.resolve(import.meta.dirname, '..', file), 'utf-8')
10
- const title = md.split('\n')[0].match(/#\s+(.+)/)?.[1]
11
- if (title) {
12
- return { text: title, link: `/${file.replace('.md', '')}` }
13
- }
14
- return null
15
- })
16
- .filter((o) => !!o)
17
-
18
- // https://vitepress.dev/reference/site-config
19
- export default defineConfig({
20
- title: '@qse/edu-scripts',
21
- description: '教育工程化基础框架',
22
- base: '/qsxxwapdev/edu-scripts/',
23
- themeConfig: {
24
- // https://vitepress.dev/reference/default-theme-config
25
- nav: [],
26
-
27
- sidebar: [
28
- { text: '快速开始', link: '/install' },
29
- { text: '更新日志', link: '/changelog' },
30
- { text: '教程', items: sidebarItems },
31
- ],
32
-
33
- socialLinks: [{ icon: 'github', link: 'https://github.com/vuejs/vitepress' }],
34
- },
35
- })
package/docs/changelog.md DELETED
@@ -1 +0,0 @@
1
- <!-- @include: ../CHANGELOG.md -->
package/docs/debug.md DELETED
@@ -1,17 +0,0 @@
1
- # 代码调试
2
-
3
- ## 使用 `React Developer Tools` 调试
4
-
5
- 1. 安装 `React Developer Tools` 插件
6
- 2. 打开控制台(F12)
7
- 3. 切换到 `Component` 标签页
8
- 4. 选中需要查看的组件,可以看到 `state/props/hooks` 等信息
9
-
10
- ## 使用 vscode 调试代码
11
-
12
- 1. 打开 `JavaScript Debug Terminal` 终端,输入 `npm run start` 命令启动项目。
13
-
14
- ![](https://p0.meituan.net/dpplatform/78a65449d74d1fbd61cc47e98c419a011041253.gif)
15
-
16
- 2. 按住 `ctrl/command` 点击 `http://localhost:port` 打开链接
17
- 3. 代码里打断点,网页点击触发断点
package/docs/deploy.md DELETED
@@ -1,54 +0,0 @@
1
- # 部署 v1
2
-
3
- 项目使用 [@qse/ssh-sftp][1] 部署代码到 v1 环境
4
-
5
- ## 教育模式
6
-
7
- 支持 局端/校端/公文 部署。无需额外的配置即可使用
8
-
9
- ```bash
10
- # 局端
11
- npx edu-scripts deploy -b
12
-
13
- # 校端
14
- npx edu-scripts deploy -s
15
-
16
- # 公文
17
- npx edu-scripts deploy -d
18
- ```
19
-
20
- ## 独立模式
21
-
22
- ### 默认部署
23
-
24
- 默认会部署到 `/qsxxwapdev/${package.name}` 路径下
25
-
26
- ```bash
27
- npx edu-scripts deploy
28
- ```
29
-
30
- ### 自定义部署
31
-
32
- 自定义配置部署路径
33
-
34
- ```bash
35
- # 生成配置文件
36
- npx ssh-sftp init
37
- ```
38
-
39
- 编辑配置文件
40
-
41
- ```json
42
- {
43
- "$schema": "http://www.zhidianbao.cn:8088/qsxxwapdev/edu-ssh-sftp/sftprc.schema.json",
44
- "preset": {
45
- "context": "qsxxwapdev"
46
- }
47
- }
48
- ```
49
-
50
- 可以使用预设配置,`npx ssh-sftp show-config` 查看最终的配置
51
-
52
- 其余配置请看 [@qse/ssh-sftp][1]
53
-
54
- [1]: http://www.zhidianbao.cn:8088/qsxxwapdev/edu-ssh-sftp/
package/docs/faq.md DELETED
@@ -1,144 +0,0 @@
1
- # 错误处理
2
-
3
- ## moment 没有 external 掉
4
-
5
- 全局搜索 `moment/locale/zh-cn`,把这些引入都删除掉即可
6
-
7
- ## ueditor 提示 css 文件加载不到
8
-
9
- 移动 `src/ueditor` 到 `public/ueditor`, 导入地址也修改下
10
-
11
- 例子: `require('../../../public/ueditor/<something>')`
12
-
13
- ## style 文件报错
14
-
15
- ```js
16
- import * as style from './index.less'
17
- //=> 改成
18
- import style from './index.less'
19
- ```
20
-
21
- ## 如果判断是缺少 `alias` 配置,使用 `npx edu-scripts g override` 生成配置文件,并且配置 `alias` 参数
22
-
23
- ```js
24
- const { defineConfig } = require('@qse/edu-scripts')
25
- const path = require('path')
26
-
27
- module.exports = defineConfig({
28
- alias: {
29
- pages: path.resolve('src/pages'),
30
- },
31
- })
32
- ```
33
-
34
- ## 动态导入 `import`,webpack4 以后 `import` 默认导出改成 `default`
35
-
36
- ```js
37
- // 以前写法
38
- import('lodash/get').then((get) => {
39
- get()
40
- })
41
-
42
- // 现在写法
43
- import('lodash/get').then(({ default: get }) => {
44
- get()
45
- })
46
- ```
47
-
48
- ## `react` 组件热更新失效
49
-
50
- 把上面的 `CDN` 加入到首页(index\*.html)中
51
-
52
- 其中 `process.env.NODE_ENV` 那段代码是关键
53
-
54
- 热更新需要 react16,请阅读[升级指南](/refactor-react-16)
55
-
56
- ## 主文件过大,代码分割失效
57
-
58
- 检查是否有 `require('./chunkfile').default` 这种写法,这会导致代码分割失效,直接打进 main 中
59
-
60
- ```js
61
- export default (callback) => {
62
- require.ensure([], (require) => {
63
- // 错误例子
64
- callback(require('./chunkfile').default)
65
-
66
- // 正确写法
67
- const mod = require('./chunkfile')
68
- callback(mod.default)
69
- })
70
- }
71
- ```
72
-
73
- 另外,webpack2 开始就不推荐使用 `require.ensure` 做代码分割了。现在可以使用 `import` 方式代码分割
74
-
75
- ```js
76
- export default (callback) => {
77
- import(/* webpackChunkName: 'chunkfileName' */ './chunkfile').then((mod) => {
78
- callback(mod.default)
79
- })
80
- }
81
- ```
82
-
83
- ## 子工程不能含有 public/static,现已自动删除
84
-
85
- 子工程不能含有 static 是因为 新建子工程 如果拷贝了主工程代码,那 static 也复制了,打包部署 v1 后可能会覆盖主工程的 static。而且子工程本身就不应该有 static,不可以引入本地外部资源
86
-
87
- ## qsbAntd is not defiend
88
-
89
- 子工程项目如果出现这个错误,引入下面的静态资源
90
-
91
- ```html
92
- <!-- 确保已经引入 react moment antd -->
93
- <script src="//www.zhidianbao.cn:8088/qsxxwapdev/edu-scripts/react-dev-preset.js"></script>
94
- <script src="//www.zhidianbao.cn:8088/qsxxwapdev/edu-scripts/moment2.29.1.js"></script>
95
- <script src="//www.zhidianbao.cn:8088/qsxxwapdev/edu-scripts/antd3.26.20.js"></script>
96
-
97
- <!-- 引入 @qsb/antd -->
98
- <script src="//www.zhidianbao.cn:8088/qsxxwapdev/edu-scripts/qsb-antd.min.js"></script>
99
- ```
100
-
101
- ## 钉钉遇到页面打开白屏
102
-
103
- 这种情况多半是链接中带了 hash,导致页面跳转失败。(复制出来可能是新的链接,但页面其实是老的并未跳转)
104
-
105
- 将下面两段代码分别加入对应的文件中,必须保证其位置在所有 `script` 最前面
106
-
107
- 原理: 将 hash 转存至 localStorage,跳转后再取出
108
-
109
- ```html
110
- <!-- index.html -->
111
- <script>
112
- ;(function () {
113
- var searchString = location.search
114
- if (!/(\?|&)S=/.test(searchString)) {
115
- var randomHexString = Math.random().toString(32).substring(2)
116
- searchString = searchString.substring(1)
117
- searchString = '?S=' + randomHexString + (searchString.length > 0 ? '&' + searchString : '')
118
- }
119
- if (location.hash) {
120
- localStorage.setItem('qse:H', location.hash)
121
- }
122
- var pathnameArr = location.pathname.split('/')
123
- var pathname = pathnameArr.slice(0, -1).concat('index1.html').join('/')
124
- var __tmp_URL = location.origin + pathname + searchString
125
- history.replaceState(null, document.title, __tmp_URL)
126
- location.reload()
127
- })()
128
- </script>
129
- ```
130
-
131
- ```html
132
- <!-- index1.html -->
133
- <script>
134
- ;(function () {
135
- var hash = localStorage.getItem('qse:H')
136
- if (hash) {
137
- localStorage.removeItem('qse:H')
138
- hash = /^#/.test(hash) ? hash : '#' + hash
139
- var url = location.origin + location.pathname + location.search + hash
140
- history.replaceState(history.state, null, url)
141
- }
142
- })()
143
- </script>
144
- ```