├── .eslintignore
├── .eslintrc.js
├── .gitignore
├── CHANGELOG.md
├── CONTRIBUTING.md
├── README.md
├── doc
├── error-handling-on-gulp.md
├── eslint-guide.md
├── how-to-babel7.md
├── how-to-migrate-to-v1.md
├── how-to-ts.md
├── howto-css-in-creator.md
├── howto-devleop-webpack-loader.md
└── img
│ ├── eslint01.png
│ ├── tsinputempty.png
│ └── vue-component.png
├── docs
├── .vuepress
│ ├── components
│ │ ├── Foo
│ │ │ └── Bar.vue
│ │ ├── OtherComponent.vue
│ │ ├── UpgradePath.vue
│ │ └── demo-1.vue
│ ├── config.js
│ ├── public
│ │ ├── icons
│ │ │ ├── android-chrome-192x192.png
│ │ │ ├── android-chrome-512x512.png
│ │ │ ├── apple-touch-icon-120x120.png
│ │ │ ├── apple-touch-icon-152x152.png
│ │ │ ├── apple-touch-icon-180x180.png
│ │ │ ├── apple-touch-icon-60x60.png
│ │ │ ├── apple-touch-icon-76x76.png
│ │ │ ├── apple-touch-icon.png
│ │ │ ├── favicon-16x16.png
│ │ │ ├── favicon-32x32.png
│ │ │ ├── msapplication-icon-144x144.png
│ │ │ ├── mstile-150x150.png
│ │ │ └── safari-pinned-tab.svg
│ │ ├── logo.png
│ │ └── manifest.json
│ └── styles
│ │ ├── index.styl
│ │ └── palette.styl
├── README.md
├── config
│ └── README.md
└── guide
│ ├── README.md
│ ├── autofe-scripts.md
│ ├── browser-compatibility.md
│ ├── css.md
│ ├── dev-convention.md
│ ├── eslint.md
│ ├── folder-structure.md
│ ├── getting-started.md
│ ├── html.md
│ ├── images
│ └── tsinputempty.png
│ ├── javascript.md
│ ├── mode-and-env.md
│ ├── static-assets.md
│ ├── troubleshooting.md
│ ├── typescript.md
│ ├── updating-to-new-releases.md
│ ├── webpack.md
│ └── write.md
├── lerna.json
├── package.json
├── packages
├── autofe-polyfill
│ ├── README.md
│ ├── index.js
│ └── package.json
├── autofe-scripts
│ ├── .gitignore
│ ├── .npmignore
│ ├── README.md
│ ├── bin
│ │ └── autofe-scripts.js
│ ├── config
│ │ ├── env.js
│ │ ├── index.js
│ │ ├── paths.js
│ │ └── webpack.config.js
│ ├── gulpfile.js
│ │ ├── config.js
│ │ ├── index.js
│ │ ├── lib
│ │ │ └── svgmin.js
│ │ └── tasks
│ │ │ ├── clean.js
│ │ │ ├── html-bundle.js
│ │ │ ├── html.js
│ │ │ ├── js.js
│ │ │ ├── markdown.html
│ │ │ ├── markdown.js
│ │ │ └── webpack.js
│ ├── package.json
│ ├── scripts
│ │ ├── build.js
│ │ ├── eject.js
│ │ ├── init.js
│ │ ├── lib
│ │ │ └── runner.js
│ │ ├── start.js
│ │ └── test.js
│ ├── template
│ │ ├── .browserslistrc
│ │ ├── .env
│ │ ├── .env.development
│ │ ├── .env.production
│ │ ├── .eslintignore
│ │ ├── .eslintrc.js
│ │ ├── README.md
│ │ ├── babel.config.js
│ │ ├── creator.config.js
│ │ ├── eslintignore
│ │ ├── gitignore
│ │ ├── postcss.config.js
│ │ ├── public
│ │ │ └── favicon.ico
│ │ ├── src
│ │ │ ├── assets
│ │ │ │ └── share.png
│ │ │ ├── component
│ │ │ │ └── footer
│ │ │ │ │ ├── _index.html
│ │ │ │ │ └── logo.png
│ │ │ ├── fixtures
│ │ │ │ ├── index.html
│ │ │ │ └── js
│ │ │ │ │ ├── README.md
│ │ │ │ │ ├── commonjs
│ │ │ │ │ ├── counter.js
│ │ │ │ │ ├── index.entry.js
│ │ │ │ │ ├── modA.js
│ │ │ │ │ ├── modB.js
│ │ │ │ │ └── modC.js
│ │ │ │ │ ├── dynamic-import
│ │ │ │ │ ├── index.entry.js
│ │ │ │ │ ├── rank-commonjs.js
│ │ │ │ │ ├── rank-test.js
│ │ │ │ │ └── rank.js
│ │ │ │ │ ├── es2016plus
│ │ │ │ │ └── index.entry.js
│ │ │ │ │ ├── es5-code
│ │ │ │ │ └── index.entry.js
│ │ │ │ │ ├── es6-code
│ │ │ │ │ ├── arrow-function.js
│ │ │ │ │ ├── binary-octal.js
│ │ │ │ │ ├── class.js
│ │ │ │ │ ├── default-rest-spread.js
│ │ │ │ │ ├── destructuring.js
│ │ │ │ │ ├── enhanced-object.js
│ │ │ │ │ ├── for-of.js
│ │ │ │ │ ├── generators.js
│ │ │ │ │ ├── index.entry.js
│ │ │ │ │ ├── let-const.js
│ │ │ │ │ ├── named-function-expression.js
│ │ │ │ │ ├── parameters.js
│ │ │ │ │ ├── regexp.js
│ │ │ │ │ ├── template-string.js
│ │ │ │ │ └── unicode.js
│ │ │ │ │ ├── es6-modules
│ │ │ │ │ ├── counter.js
│ │ │ │ │ ├── index.entry.js
│ │ │ │ │ ├── math.js
│ │ │ │ │ ├── modA.js
│ │ │ │ │ └── modB.js
│ │ │ │ │ ├── main.entry.js
│ │ │ │ │ ├── stage
│ │ │ │ │ └── index.entry.js
│ │ │ │ │ └── vendor
│ │ │ │ │ └── es6-promise.auto.min.old.js
│ │ │ └── index
│ │ │ │ ├── README.md
│ │ │ │ ├── _part1.html
│ │ │ │ ├── _part2.html
│ │ │ │ ├── css
│ │ │ │ ├── _attr.scss
│ │ │ │ ├── _base.scss
│ │ │ │ ├── _part1.scss
│ │ │ │ ├── _part2.scss
│ │ │ │ ├── _reset.scss
│ │ │ │ ├── _test-ascii.scss
│ │ │ │ ├── _test-autoprefixer.scss
│ │ │ │ ├── _test-color.scss
│ │ │ │ ├── _test-iehack.scss
│ │ │ │ ├── _test-null.scss
│ │ │ │ ├── _test-postcss-assets.scss
│ │ │ │ ├── _test-root-alias.scss
│ │ │ │ ├── main.scss
│ │ │ │ ├── nest
│ │ │ │ │ ├── _test_nest.scss
│ │ │ │ │ └── nnest
│ │ │ │ │ │ ├── _test_nest2.css
│ │ │ │ │ │ └── _test_nest3.scss
│ │ │ │ ├── pure.css
│ │ │ │ └── sub
│ │ │ │ │ ├── _test-relative-url-pure.css
│ │ │ │ │ ├── _test-relative-url.scss
│ │ │ │ │ └── car.jpg
│ │ │ │ ├── font
│ │ │ │ ├── demo.css
│ │ │ │ ├── demo_index.html
│ │ │ │ ├── iconfont.css
│ │ │ │ ├── iconfont.eot
│ │ │ │ ├── iconfont.json
│ │ │ │ ├── iconfont.old.js
│ │ │ │ ├── iconfont.svg
│ │ │ │ ├── iconfont.ttf
│ │ │ │ ├── iconfont.woff
│ │ │ │ └── iconfont.woff2
│ │ │ │ ├── img
│ │ │ │ ├── bg.png
│ │ │ │ ├── car.jpg
│ │ │ │ ├── cursor-hand.cur
│ │ │ │ ├── postcss-assets.jpg
│ │ │ │ ├── postcss-assets.png
│ │ │ │ └── postcss-assets.svg
│ │ │ │ ├── index.html
│ │ │ │ ├── js
│ │ │ │ ├── hello.ts
│ │ │ │ ├── index.entry.js
│ │ │ │ ├── indexts.entry.ts
│ │ │ │ ├── main.old.js
│ │ │ │ ├── math.js
│ │ │ │ └── vendor
│ │ │ │ │ └── es6-promise.auto.min.old.js
│ │ │ │ └── pic
│ │ │ │ └── 01.jpg
│ │ └── tsconfig.json
│ └── util
│ │ ├── isAbsoluteUrl.js
│ │ ├── prepareProxy.js
│ │ ├── prepareURLs.js
│ │ └── resolveClientEnv.js
├── autofe-serve-index
│ ├── .editorconfig
│ ├── .gitignore
│ ├── LICENSE
│ ├── README.md
│ ├── index.js
│ ├── package.json
│ └── public
│ │ ├── directory.html
│ │ ├── icons
│ │ ├── application_xp.png
│ │ ├── application_xp_terminal.png
│ │ ├── box.png
│ │ ├── cd.png
│ │ ├── controller.png
│ │ ├── drive.png
│ │ ├── film.png
│ │ ├── folder.png
│ │ ├── font.png
│ │ ├── image.png
│ │ ├── map.png
│ │ ├── page.png
│ │ ├── page_add.png
│ │ ├── page_attach.png
│ │ ├── page_code.png
│ │ ├── page_copy.png
│ │ ├── page_delete.png
│ │ ├── page_edit.png
│ │ ├── page_error.png
│ │ ├── page_excel.png
│ │ ├── page_find.png
│ │ ├── page_gear.png
│ │ ├── page_go.png
│ │ ├── page_green.png
│ │ ├── page_key.png
│ │ ├── page_lightning.png
│ │ ├── page_link.png
│ │ ├── page_paintbrush.png
│ │ ├── page_paste.png
│ │ ├── page_red.png
│ │ ├── page_refresh.png
│ │ ├── page_save.png
│ │ ├── page_white.png
│ │ ├── page_white_acrobat.png
│ │ ├── page_white_actionscript.png
│ │ ├── page_white_add.png
│ │ ├── page_white_c.png
│ │ ├── page_white_camera.png
│ │ ├── page_white_cd.png
│ │ ├── page_white_code.png
│ │ ├── page_white_code_red.png
│ │ ├── page_white_coldfusion.png
│ │ ├── page_white_compressed.png
│ │ ├── page_white_copy.png
│ │ ├── page_white_cplusplus.png
│ │ ├── page_white_csharp.png
│ │ ├── page_white_cup.png
│ │ ├── page_white_database.png
│ │ ├── page_white_delete.png
│ │ ├── page_white_dvd.png
│ │ ├── page_white_edit.png
│ │ ├── page_white_error.png
│ │ ├── page_white_excel.png
│ │ ├── page_white_find.png
│ │ ├── page_white_flash.png
│ │ ├── page_white_freehand.png
│ │ ├── page_white_gear.png
│ │ ├── page_white_get.png
│ │ ├── page_white_go.png
│ │ ├── page_white_h.png
│ │ ├── page_white_horizontal.png
│ │ ├── page_white_key.png
│ │ ├── page_white_lightning.png
│ │ ├── page_white_link.png
│ │ ├── page_white_magnify.png
│ │ ├── page_white_medal.png
│ │ ├── page_white_office.png
│ │ ├── page_white_paint.png
│ │ ├── page_white_paintbrush.png
│ │ ├── page_white_paste.png
│ │ ├── page_white_php.png
│ │ ├── page_white_picture.png
│ │ ├── page_white_powerpoint.png
│ │ ├── page_white_put.png
│ │ ├── page_white_ruby.png
│ │ ├── page_white_stack.png
│ │ ├── page_white_star.png
│ │ ├── page_white_swoosh.png
│ │ ├── page_white_text.png
│ │ ├── page_white_text_width.png
│ │ ├── page_white_tux.png
│ │ ├── page_white_vector.png
│ │ ├── page_white_visualstudio.png
│ │ ├── page_white_width.png
│ │ ├── page_white_word.png
│ │ ├── page_white_world.png
│ │ ├── page_white_wrench.png
│ │ ├── page_white_zip.png
│ │ ├── page_word.png
│ │ └── page_world.png
│ │ └── style.css
├── autofe-shared-utils
│ ├── .gitignore
│ ├── README.md
│ ├── index.js
│ ├── lib
│ │ ├── css-url-relative-plugin
│ │ │ ├── css-replace.js
│ │ │ └── index.js
│ │ └── omit-js-for-css-only-plugin
│ │ │ ├── another.js
│ │ │ └── index.js
│ └── package.json
├── autofe-webpack
│ ├── .gitignore
│ ├── README.md
│ ├── package.json
│ └── src
│ │ ├── css-url-relative-plugin
│ │ ├── css-replace.js
│ │ └── index.js
│ │ ├── index.js
│ │ └── omit-js-for-css-only-plugin
│ │ ├── another.js
│ │ └── index.js
├── babel-preset-autofe-app
│ ├── README.md
│ ├── index.js
│ └── package.json
├── create-autofe-app
│ ├── README.md
│ ├── createApp.js
│ ├── index.js
│ └── package.json
└── eslint-config-autofe-app
│ ├── README.md
│ ├── index.js
│ ├── package.json
│ ├── rules
│ ├── best-practices.js
│ ├── errors.js
│ ├── es6.js
│ ├── imports.js
│ ├── node.js
│ ├── style.js
│ └── variables.js
│ └── typescript.js
└── tasks
├── cra.js
├── release.sh
├── releaseDoc.sh
└── replace-own-deps.js
/.eslintignore:
--------------------------------------------------------------------------------
1 | node_modules
2 | build
3 | my-app*
4 | packages/autofe-scripts/template
5 |
--------------------------------------------------------------------------------
/.eslintrc.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | root: true,
3 | extends: "eslint:recommended",
4 | env: {
5 | "browser": true,
6 | "commonjs": true,
7 | "node": true,
8 | "es6": true
9 | },
10 | parserOptions: {
11 | "ecmaVersion": 2018
12 | },
13 | rules: {
14 | "no-console": "off",
15 | "strict": "off",
16 | "curly": "warn"
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .idea/
2 | .vscode/
3 | node_modules/
4 | build
5 | .DS_Store
6 | *.tgz
7 | my-app*
8 | lerna-debug.log
9 | npm-debug.log*
10 | yarn-debug.log*
11 | yarn-error.log*
12 | /.changelog
13 | package-lock.json
14 | yarn.lock
15 |
16 | # docs
17 | /docs/.vuepress/dist
18 | .temp
19 |
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | ## autofe-scripts@1.3.13
2 |
3 | 该版本功能主要改动:
4 | * 使用 sass 替代 node-sass
5 |
6 | ## autofe-scripts@1.3.12
7 |
8 | 该版本功能主要改动:
9 | * 更新内部 babel 配置,修复报警
10 |
11 | ## autofe-scripts@1.3.10
12 |
13 | 该版本功能主要改动:
14 | * 支持 css 内嵌到 js 中,由 js 动态插入 style 到页面
15 |
16 | ## autofe-scripts@1.3.9
17 |
18 | 该版本功能主要改动:
19 | * 默认关闭 webpack-dev-server 的 Host 检查功能,方便开发
20 |
21 | ## autofe-scripts@1.3.8
22 |
23 | 该版本功能主要改动:
24 | 1. 使用 webpack-dev-server 取代 browsersync
25 | 2. 优化内部 watch 实现,并实现监听 public 目录
26 | 3. 支持在 creator.config.js 中配置 devServer
27 |
28 | ## autofe-scripts@1.3.5
29 |
30 | 该版本功能主要改动:
31 | * 基于 VuePress 搭建文档站点,并完善文档
32 | * 增加 Webpack 配置功能,两种方式 configureWebpack 和 chainWebpack
33 | * 增加环境变量配置功能,使用 dotenv 加载 .env 文件
34 | * 修复 Window 下打包目录问题,由于 gulp glob 不支持 windows 风格路径导致
35 | * 去掉由于 src 目录没有 ts 文件导致的错误日志
36 | * autofe-webpack 替换成 autofe-shared-utils
37 | * 增加 css.loaderOptions 配置能力
38 |
39 | ## autofe-scripts@1.3.4
40 |
41 | 该版本增加了 TypeScript 支持,升级请参考 [如果手动支持 TypeScript](./doc/how-to-ts.md)
42 |
43 | ## autofe-scripts@1.2.3
44 |
45 | 该版本把 gulp 从 v3 升级到 v4,因为 gulp v3 在 node 12 下不被支持。
46 |
47 | ## autofe-scripts@1.2.1
48 |
49 | 减少命令运行时,webpack 部分输出到控制台的日志,方便查找关键日志信息。
50 |
51 | ## 1.2.0
52 |
53 | 该版本功能主要改动:
54 | * 增强了 CSS 能力
55 | * PostCSS 可通过 `postcss.config.js` 自定义配置,比如 Autoprefixer
56 | * 自动打开浏览器时,使用 `external ip` 地址,替代原来的 `localhost` 地址
57 | * Babel 可通过 `babel.config.js` 自定义配置,增加了 polyfill 能力
58 | * 增加 `transpileDependencies` 选项来支持通过 Babel 处理 `node_modules` 里的特定包
59 | * ESLint 可通过 `.eslintrc.js` 和 `.eslintignore` 自定义配置
60 | * 目标浏览器可通过 `.browserslistrc` 自定义配置
61 | * 去掉了图片压缩功能,收益太小(SVG的压缩还保留着)
62 |
63 | 升级请参考 [如何迁移到 autofe-scripts v1 版本](./doc/how-to-migrate-to-v1.md)
64 |
65 | ## 0.6.2
66 |
67 | 1. 修复新增文件时,无法自动刷新浏览器的问题
68 | 2. 新增将特殊类型文件复制到 build 目录的功能,目前有 mp3,mp4,ogg,flv,swf,ico,cur,json,txt 。
69 |
70 | ## 0.6.1
71 |
72 | 1. 修复 windows 平台下无法自动打开 Chrome 浏览器的问题
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # 贡献
2 |
3 | 首先,你应当了解一下 [lerna](https://lernajs.io/) 和 [yarn](https://yarnpkg.com/)。
4 |
5 | ## 关于配置
6 |
7 | * 约定大于配置
8 | * 启发式大于配置,根据 ENV 设置配置,比如 `PORT`
9 | * 交互大于配置,比如 3000 端口被占用,会给出一个 prompt 来让用户输入其它的端口
10 |
11 | 有时候,我们也希望有一个配置项,仔细问问自己是否真的需要,如果是,那么就添加吧。
12 |
13 | ## 本地开发
14 |
15 | **注意:要求使用 `yarn` 而不是 `npm`,因为我们需要结合 yarn 的 workflow 的概念来进行开发。**
16 |
17 | ```
18 | git clone https://github.com/athm-fe/create-autofe-app
19 | cd create-autofe-app
20 | yarn
21 | ```
22 |
23 | 一旦上面的命名执行成功,你可以修改任何文件,并且运行 `yarn start`,`yarn build` 等来查看 Demo,它将运行位于 `packages/autofe-scripts/temlate` 目录下的应用。
24 |
25 | 如果想本地联调测试 `create-autofe-app` 和 `autofe-scripts`,可以按照下面的步骤来:
26 |
27 | ```
28 | yarn create-autofe-app my-app
29 | cd my-app
30 | ```
31 |
32 | 然后就运行 `yarn start` 或者 `yarn build` 了。
33 |
34 | ## 发布
35 |
36 | 1. 大多数情况下只有 `autofe-scripts` 需要发布。
37 | 2. 由于 `create-autofe-app` 是安装到全局的,所以尽量少修改它。还有,需要注意所有版本的 `create-autofe-app` 都要能够兼容最新版本的 `autofe-scripts`。
38 | 3. 发布前,请修改 `CHANGELOG.md`。
39 | 4. 不要直接使用 `npm publish` 来发布包。应当使用 `npm run publish` 来发布。
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Create AutoFE App
2 |
3 | > Thanks to [Create React App](https://create-react-app.dev/) and [Vue CLI](https://cli.vuejs.org/).
4 |
5 | > Create AutoFE App is the Recommended Tooling for AutoFE Development.
6 |
7 | ## Documentation
8 |
9 | Docs are available at [https://athm-fe.github.io/create-autofe-app/](https://athm-fe.github.io/create-autofe-app/) - we are still working on refining it and contributions are welcome!
10 |
11 | ## Contributing
12 |
13 | Please see [contributing guide](CONTRIBUTING.md).
14 |
15 | ## Feedback
16 |
17 | We are always open to [your feedback](https://github.com/athm-fe/create-autofe-app/issues).
18 |
19 | ## License
20 |
21 | MIT
--------------------------------------------------------------------------------
/doc/how-to-migrate-to-v1.md:
--------------------------------------------------------------------------------
1 | # 如何迁移到 autofe-scripts v1 版本
2 |
3 | 该版本功能主要改动:
4 | * 增强了 CSS 能力,依托于 Webpack 打包
5 | * PostCSS 可通过 `postcss.config.js` 自定义配置,比如 Autoprefixer
6 | * 自动打开浏览器时,使用 `external ip` 地址,替代原来的 `localhost` 地址
7 | * Babel 可通过 `babel.config.js` 自定义配置,增加了 Polyfills 能力
8 | * 增加 `transpileDependencies` 选项来支持通过 Babel 处理 `node_modules` 里的特定包
9 | * ESLint 可通过 `.eslintrc.js` 和 `.eslintignore` 自定义配置
10 | * 目标浏览器可通过 `.browserslistrc` 自定义配置
11 | * 去掉了图片压缩功能,收益太小(SVG的压缩还保留着)
12 |
13 | ## 创建全新项目
14 |
15 | ```
16 | npx create-autofe-app --scripts-version=autofe-scripts@next my-app
17 | ```
18 |
19 | ## 老项目迁移
20 |
21 | 这次升级比较大,虽然我尽可能的做了向后兼容,但是还是有一些迁移成本。
22 |
23 | **⚠️ 注意:目前 `autofe-scripts` 还未打上标签 `latest`。**
24 |
25 | **⚠️ 注意:`autofe-scripts` 暂不支持全局使用。**
26 |
27 | ### 安装必要的包
28 |
29 | ```
30 | npm uninstall --save-dev autofe-scripts
31 | npm install --save-dev autofe-scripts@next
32 | npm install --save-dev eslint@5 eslint-config-autofe-app eslint-plugin-import@2
33 | ```
34 |
35 | **注意:如果安装出现问题,可以先删除 `node_modules` 目录,再安装。**
36 |
37 | ### 在项目根目录创建一些配置文件
38 |
39 | 参考流行的做法,提供了一些配置文件来自定义配置。
40 |
41 | `.browserslistrc`
42 | ```
43 | > 0.2%
44 | last 2 versions
45 | Firefox ESR
46 | not dead
47 | iOS >= 9
48 | Android >= 4.4
49 | Explorer >= 9
50 | ```
51 |
52 | `.eslintignore`
53 | ```
54 | build
55 | **/*.old.js
56 | ```
57 |
58 | `.eslintrc.js`
59 | ```javascript
60 | module.exports = {
61 | root: true,
62 | extends: [
63 | 'eslint-config-autofe-app',
64 | ],
65 | globals: {
66 | AHAPP: 'readonly',
67 | },
68 | rules: {
69 | 'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
70 | 'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
71 | },
72 | };
73 | ```
74 |
75 | `babel.config.js`
76 | ```javascript
77 | module.exports = {
78 | presets: [
79 | ['autofe-app', {
80 | // debug: true,
81 | // useBuiltIns: 'usage',
82 | // helpers: false,
83 | }],
84 | ],
85 | };
86 | ```
87 |
88 | `creator.config.js`
89 | ```javascript
90 | module.exports = {
91 | externals: {
92 | jquery: 'jQuery',
93 | },
94 | transpileDependencies: [
95 | '@auto/img-crop',
96 | ],
97 | };
98 | ```
99 |
100 | `postcss.config.js`
101 | ```javascript
102 | module.exports = {
103 | plugins: {
104 | autoprefixer: {},
105 | },
106 | };
107 | ```
108 |
109 | ### 去掉 CSS 中的 `inline()`
110 |
111 | 原来的写法:
112 | ```css
113 | .test-inline {
114 | background: inline("../img/car.jpg") repeat;
115 | }
116 | ```
117 |
118 | 修改为如下写法:
119 | ```css
120 | .test-inline {
121 | background: url("../img/car.jpg?datauri") repeat;
122 | }
123 | ```
124 |
125 | ### Sass 中图片路径处理
126 |
127 | 原来的 Sass 中图片的路径是按照入口文件来寻找图片的,这次修改了这个逻辑,改为按照模块文件所在的位置来寻找图片。
128 |
129 | 假设你的目录结构是这样的:
130 |
131 | ```
132 | + main.scss
133 | + sub/
134 | + _sub.scss
135 | + sub.png
136 | ```
137 |
138 | 代码内容是这样的:
139 |
140 | `main.scss`
141 | ```scss
142 | @import "sub/sub";
143 | ```
144 |
145 | `sub/_sub.scss`
146 | ```scss
147 | .sub {
148 | background: url("./sub.png") no-repeat;
149 | }
150 | ```
151 |
152 | 原来的输出结果:
153 |
154 | ```css
155 | .sub {
156 | background: url("./sub.png") no-repeat;
157 | }
158 | ```
159 |
160 | 现在的输出结果是:
161 |
162 | ```css
163 | .sub {
164 | background: url("./sub/sub.png") no-repeat;
165 | }
166 | ```
167 |
168 | ## 新功能
169 |
170 | 到这里,就迁移完成了,请移步 [User Guide](https://github.com/athm-fe/create-autofe-app/blob/master/packages/autofe-scripts/template/README.md) 了解新功能。
171 |
--------------------------------------------------------------------------------
/doc/how-to-ts.md:
--------------------------------------------------------------------------------
1 | # TypeScript 使用
2 |
3 | Creator 从 `autofe-scripts@1.3.4` 开始支持 TypeScript。
4 |
5 | ## 手动升级
6 |
7 | 如果你是使用 `npx create-autofe-app my-app` 创建新项目,可以自动略过该部分。
8 |
9 | ### 更新核心包
10 |
11 | 首先,更新现有包:
12 |
13 | ```
14 | npm i --save-dev autofe-scripts@1.3.4
15 | npm i --save-dev eslint@5.16.0
16 | npm i --save-dev eslint-config-autofe-app@1.2.1 eslint-plugin-import@2.13.0
17 | ```
18 |
19 | ### 安装 Typescript 相关包
20 |
21 | 如果你需要 Typescript 支持,还需要安装如下包
22 |
23 | ```
24 | npm i --save-dev typescript@3
25 | npm i --save-dev @typescript-eslint/parser@2
26 | npm i --save-dev @typescript-eslint/eslint-plugin@2
27 | ```
28 |
29 | ## 更新配置
30 |
31 | `eslintrc.js` 需要添加对 TypeScript 的支持
32 |
33 | ```javascript
34 | module.exports = {
35 | // ...
36 | extends: [
37 | 'eslint-config-autofe-app',
38 | 'eslint-config-autofe-app/typescript',
39 | ],
40 | // ...
41 | };
42 | ```
43 |
44 | 另外,需要在项目根目录创建 `tsconfig.json`,具体内容请使用提前准备好的[配置](https://github.com/athm-fe/create-autofe-app/blob/master/packages/autofe-scripts/template/tsconfig.json)
45 |
46 | ## 开始使用
47 |
48 | 具体内容请移步 [TypeScript 使用](https://github.com/athm-fe/create-autofe-app/tree/master/packages/autofe-scripts/template#%E7%BC%96%E5%86%99-typescript)
49 |
50 | ## 问题
51 |
52 | 有可能你会遇到如下图中的报错:
53 |
54 | 
55 |
56 | 这是因为 `tsconfig.json` 中 `include` 字段的配置要求你至少有一个 `.ts` 文件,解决办法很简单,在 `src` 目录下新建你的文件即可,比如 `hello.ts`
--------------------------------------------------------------------------------
/doc/howto-devleop-webpack-loader.md:
--------------------------------------------------------------------------------
1 | # 如何开发自己的 Webpack Loader
2 |
3 | 流程:从右向左
4 | pitch:从左向右
5 |
6 | 0. function loader(content, sourceMap) {}
7 | 1. loaderUtils.getOptions(this)
8 | 2. validateOptions(), options.json
9 | 3. this.rootContext
10 | 4. this.resourcePath
11 | 5. loaderUtils.interpolateName()
12 | 6. __webpack_public_path__
13 | 7. this.emitFile(outputPath, content);
14 | 8. export default publicPath
15 | 9. module.exports = publicPath
16 |
17 | 异步方式 1
18 | const callback = this.async();
19 | callback(new Error());
20 | callback(null, content);
21 | callback(null, content, map);
22 |
23 | 添加到依赖树,可以提供给 watch 使用
24 | this.addDependency()
25 |
26 | 生成 sourcemap
27 | 1. postcss
28 | 2. sass
29 | 3. babel
30 | 4. source-map 库
31 |
32 | 同步
33 | this.emitWarning()
34 | this.emitError()
35 | return content;
--------------------------------------------------------------------------------
/doc/img/eslint01.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athm-fe/create-autofe-app/787a340370d98ac16ecf1297ecb8bc699e0f0422/doc/img/eslint01.png
--------------------------------------------------------------------------------
/doc/img/tsinputempty.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athm-fe/create-autofe-app/787a340370d98ac16ecf1297ecb8bc699e0f0422/doc/img/tsinputempty.png
--------------------------------------------------------------------------------
/doc/img/vue-component.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athm-fe/create-autofe-app/787a340370d98ac16ecf1297ecb8bc699e0f0422/doc/img/vue-component.png
--------------------------------------------------------------------------------
/docs/.vuepress/components/Foo/Bar.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 | {{ msg }}
4 |
5 |
6 |
7 |
16 |
--------------------------------------------------------------------------------
/docs/.vuepress/components/OtherComponent.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 | This is another component
4 |
5 |
6 |
12 |
--------------------------------------------------------------------------------
/docs/.vuepress/components/UpgradePath.vue:
--------------------------------------------------------------------------------
1 |
23 |
24 |
36 |
--------------------------------------------------------------------------------
/docs/.vuepress/components/demo-1.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 | {{ msg }}
4 |
5 |
6 |
7 |
16 |
--------------------------------------------------------------------------------
/docs/.vuepress/config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | base: '/create-autofe-app/',
3 | title: 'Create AutoFE App',
4 | description: 'Recommended Tooling for AutoFE Development',
5 | head: [
6 | ['link', { rel: 'icon', href: `/logo.png` }],
7 | ['link', { rel: 'manifest', href: '/manifest.json' }],
8 | ['meta', { name: 'theme-color', content: '#3eaf7c' }],
9 | ['meta', { name: 'apple-mobile-web-app-capable', content: 'yes' }],
10 | ['meta', { name: 'apple-mobile-web-app-status-bar-style', content: 'black' }],
11 | ['link', { rel: 'apple-touch-icon', href: `/icons/apple-touch-icon-152x152.png` }],
12 | ['link', { rel: 'mask-icon', href: '/icons/safari-pinned-tab.svg', color: '#3eaf7c' }],
13 | ['meta', { name: 'msapplication-TileImage', content: '/icons/msapplication-icon-144x144.png' }],
14 | ['meta', { name: 'msapplication-TileColor', content: '#000000' }]
15 | ],
16 | themeConfig: {
17 | repo: 'athm-fe/create-autofe-app',
18 | docsDir: 'docs',
19 | docsBranch: 'master',
20 | editLinks: true,
21 | lastUpdated: 'Last Updated',
22 | smoothScroll: true,
23 | sidebarDepth: 3,
24 | nav: [
25 | { text: '指南', link: '/guide/' },
26 | { text: '配置参考', link: '/config/' },
27 | { text: '更新记录', link: 'https://github.com/athm-fe/create-autofe-app/blob/master/CHANGELOG.md' },
28 | ],
29 | sidebar: {
30 | '/guide/': [
31 | '',
32 | {
33 | title: '基础',
34 | collapsable: false,
35 | children: [
36 | 'getting-started',
37 | 'folder-structure',
38 | 'autofe-scripts',
39 | 'dev-convention',
40 | 'updating-to-new-releases',
41 | ]
42 | },
43 | {
44 | title: '开发',
45 | collapsable: false,
46 | children: [
47 | 'static-assets',
48 | 'javascript',
49 | 'html',
50 | 'css',
51 | 'browser-compatibility',
52 | 'webpack',
53 | 'mode-and-env',
54 | 'eslint',
55 | 'typescript',
56 | 'troubleshooting',
57 | ]
58 | }
59 | ],
60 | },
61 | },
62 | plugins: [
63 | ['@vuepress/back-to-top', true],
64 | // ['@vuepress/pwa', {
65 | // serviceWorker: true,
66 | // updatePopup: true
67 | // }],
68 | ['@vuepress/medium-zoom', true],
69 | ['@vuepress/google-analytics', {
70 | ga: 'UA-167507084-1'
71 | }],
72 | ['container', {
73 | type: 'vue',
74 | before: '
',
75 | after: '
'
76 | }],
77 | ['container', {
78 | type: 'upgrade',
79 | before: info => ``,
80 | after: ''
81 | }],
82 | ['flowchart']
83 | ],
84 | extraWatchFiles: [],
85 | evergreen: true,
86 | };
87 |
--------------------------------------------------------------------------------
/docs/.vuepress/public/icons/android-chrome-192x192.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athm-fe/create-autofe-app/787a340370d98ac16ecf1297ecb8bc699e0f0422/docs/.vuepress/public/icons/android-chrome-192x192.png
--------------------------------------------------------------------------------
/docs/.vuepress/public/icons/android-chrome-512x512.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athm-fe/create-autofe-app/787a340370d98ac16ecf1297ecb8bc699e0f0422/docs/.vuepress/public/icons/android-chrome-512x512.png
--------------------------------------------------------------------------------
/docs/.vuepress/public/icons/apple-touch-icon-120x120.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athm-fe/create-autofe-app/787a340370d98ac16ecf1297ecb8bc699e0f0422/docs/.vuepress/public/icons/apple-touch-icon-120x120.png
--------------------------------------------------------------------------------
/docs/.vuepress/public/icons/apple-touch-icon-152x152.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athm-fe/create-autofe-app/787a340370d98ac16ecf1297ecb8bc699e0f0422/docs/.vuepress/public/icons/apple-touch-icon-152x152.png
--------------------------------------------------------------------------------
/docs/.vuepress/public/icons/apple-touch-icon-180x180.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athm-fe/create-autofe-app/787a340370d98ac16ecf1297ecb8bc699e0f0422/docs/.vuepress/public/icons/apple-touch-icon-180x180.png
--------------------------------------------------------------------------------
/docs/.vuepress/public/icons/apple-touch-icon-60x60.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athm-fe/create-autofe-app/787a340370d98ac16ecf1297ecb8bc699e0f0422/docs/.vuepress/public/icons/apple-touch-icon-60x60.png
--------------------------------------------------------------------------------
/docs/.vuepress/public/icons/apple-touch-icon-76x76.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athm-fe/create-autofe-app/787a340370d98ac16ecf1297ecb8bc699e0f0422/docs/.vuepress/public/icons/apple-touch-icon-76x76.png
--------------------------------------------------------------------------------
/docs/.vuepress/public/icons/apple-touch-icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athm-fe/create-autofe-app/787a340370d98ac16ecf1297ecb8bc699e0f0422/docs/.vuepress/public/icons/apple-touch-icon.png
--------------------------------------------------------------------------------
/docs/.vuepress/public/icons/favicon-16x16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athm-fe/create-autofe-app/787a340370d98ac16ecf1297ecb8bc699e0f0422/docs/.vuepress/public/icons/favicon-16x16.png
--------------------------------------------------------------------------------
/docs/.vuepress/public/icons/favicon-32x32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athm-fe/create-autofe-app/787a340370d98ac16ecf1297ecb8bc699e0f0422/docs/.vuepress/public/icons/favicon-32x32.png
--------------------------------------------------------------------------------
/docs/.vuepress/public/icons/msapplication-icon-144x144.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athm-fe/create-autofe-app/787a340370d98ac16ecf1297ecb8bc699e0f0422/docs/.vuepress/public/icons/msapplication-icon-144x144.png
--------------------------------------------------------------------------------
/docs/.vuepress/public/icons/mstile-150x150.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athm-fe/create-autofe-app/787a340370d98ac16ecf1297ecb8bc699e0f0422/docs/.vuepress/public/icons/mstile-150x150.png
--------------------------------------------------------------------------------
/docs/.vuepress/public/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athm-fe/create-autofe-app/787a340370d98ac16ecf1297ecb8bc699e0f0422/docs/.vuepress/public/logo.png
--------------------------------------------------------------------------------
/docs/.vuepress/public/manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "Create AutoFE App",
3 | "short_name": "Create AutoFE App",
4 | "icons": [
5 | {
6 | "src": "/create-autofe-app/icons/android-chrome-192x192.png",
7 | "sizes": "192x192",
8 | "type": "image/png"
9 | },
10 | {
11 | "src": "/create-autofe-app/icons/android-chrome-512x512.png",
12 | "sizes": "512x512",
13 | "type": "image/png"
14 | }
15 | ],
16 | "start_url": "/create-autofe-app/index.html",
17 | "display": "standalone",
18 | "background_color": "#fff",
19 | "theme_color": "#3eaf7c"
20 | }
21 |
--------------------------------------------------------------------------------
/docs/.vuepress/styles/index.styl:
--------------------------------------------------------------------------------
1 | // Automatically applied global style files,
2 | // generated at the ending of the CSS file,
3 | // have a higher priority than the default style.
4 |
5 | .home .hero img
6 | max-height 180px !important;
7 |
8 | {$contentClass}:not(.custom)
9 | p.demo
10 | border 1px dashed #f60
11 | border-radius 10px 0 10px 0
12 |
13 |
14 | pre.vue-container
15 | border-left-width: .5rem;
16 | border-left-style: solid;
17 | border-color: #42b983;
18 | border-radius: 0px;
19 | & > code
20 | font-size: 14px !important;
21 | & > p
22 | margin: -5px 0 -20px 0;
23 | code
24 | background-color: #42b983 !important;
25 | padding: 3px 5px;
26 | border-radius: 3px;
27 | color #000
28 | em
29 | color #808080
30 | font-weight light
31 |
32 | blockquote
33 | padding: 0.1rem 1.5rem
34 | border-left-width: 0.5rem
35 | border-left-style: solid
36 | margin: 1rem 0
37 | background-color: #f3f5f7
38 | border-color: #42b983
39 | & > p
40 | margin: 1em 0;
--------------------------------------------------------------------------------
/docs/.vuepress/styles/palette.styl:
--------------------------------------------------------------------------------
1 | // The palette is used to override the default color constants
2 | // and to set the color constants of Stylus.
--------------------------------------------------------------------------------
/docs/README.md:
--------------------------------------------------------------------------------
1 | ---
2 | home: true
3 | heroImage: /logo.png
4 | actionText: Get Started →
5 | actionLink: /guide/
6 | features:
7 | - title: Less to Learn
8 | details: You don't need to learn and configure many build tools. Instant reloads help you focus on development. When it's time to deploy, your bundles are optimized automatically.
9 | - title: Only One Dependency
10 | details: Your app only needs one build dependency. We test Create AutoFE App to make sure that all of its underlying pieces work together seamlessly – no complicated version mismatches.
11 | - title: No Need to Eject
12 | details: Create AutoFE App is fully configurable without the need for ejecting. This allows your project to stay up-to-date for the long run.
13 | footer: MIT Licensed | Copyright © 2020-present jpuncle
14 | ---
15 |
16 | ## Getting Started
17 |
18 | 快速创建项目 :tada:
19 |
20 | ```shell
21 | npx create-autofe-app my-app
22 |
23 | cd my-app
24 | npm start
25 | ```
26 |
27 | 或者先安装 `create-autofe-app`
28 |
29 | ```shell
30 | npm install -g create-autofe-app
31 | # OR
32 | yarn global add create-autofe-app
33 | ```
34 |
35 | 然后创建项目
36 |
37 | ```shell
38 | create-autofe-app my-app
39 |
40 | cd my-app
41 | npm start
42 | ```
43 |
44 | ::: tip
45 | 好好学习,天天向上。
46 | :::
--------------------------------------------------------------------------------
/docs/guide/README.md:
--------------------------------------------------------------------------------
1 | ---
2 | sidebarDepth: 0
3 | ---
4 |
5 | # 介绍
6 |
7 | > Thanks to [Create React App](https://create-react-app.dev/) and [Vue CLI](https://cli.vuejs.org/)
8 |
9 | Create AutoFE App 简称为 Creator,是一套基于 Webpack 搭建的前端静态页面开发工具,提供:
10 |
11 | * 通过 `create-autofe-app` 实现的~~交互式的~~项目脚手架。
12 | * ~~通过 `autofe-scripts-global` 实现的零配置原型开发。~~
13 | * 一个运行时依赖 (`autofe-scripts`),该依赖:
14 | * 可升级;
15 | * 基于 Webpack 构建,并带有合理的默认配置;
16 | * 可以通过项目内的配置文件进行配置;
17 | * ~~可以通过插件进行扩展。~~
18 | * ~~一个丰富的官方插件集合,~~ 集成了前端生态中最好的工具。
19 | * ~~一套完全图形化的创建和管理项目的用户界面。~~
20 |
21 | Creator 支持 macOS、Windows 以及 Linux。
22 | 如果发现什么问题,请[反馈](https://github.com/athm-fe/create-autofe-app/issues/new)给我们。
23 |
24 | ## 功能支持
25 |
26 | * 使用 ~~[Browsersync](http://browsersync.io/)~~ WebpackDevServer 开启本地服务器
27 | * 支持文件修改时自动刷新浏览器
28 | * 支持目录浏览
29 | * 自动打开浏览器 Chrome
30 | * 使用 [Nunjucks](https://mozilla.github.io/nunjucks/) 模版引擎来写 HTML
31 | * 使用 Sass 写 CSS
32 | * 使用 PostCSS 支持 Autoprefixer,不再需要自己处理 `-webkit-` 等浏览器前缀。
33 | * 使用 Babel 处理 ES6+
34 | * 使用 ESLint 检查 ES6+
35 | * 支持 TypeScript
36 | * 使用 Markdown 写文档,并生成 HTML 方便查看
37 | * 开发环境支持 SourceMap
38 | * 压缩前端资源,包括 CSS、JS 以及 SVG(由于压缩图片影响构建速度,暂不支持)。
39 |
40 | 所有这些功能不需要你耗费精力自行配置,Creator 帮你搞定一切。
41 |
42 | ## 该系统的组件
43 |
44 | Creator 有几个独立的部分——如果你看到了我们的[源代码](https://github.com/athm-fe/create-autofe-app/tree/master/packages),你会发现这个仓库里同时管理了多个单独发布的包。
45 |
46 | ### create-autofe-app
47 |
48 | `create-autofe-app` 是一个全局安装的 npm 包,提供了终端里的 `create-autofe-app` 命令。它可以通过 `create-autofe-app my-app` 快速搭建一个新项目。
49 |
50 | ### autofe-scripts
51 |
52 | `autofe-scripts` 是一个开发环境依赖。它是一个 npm 包,局部安装在每个 `create-autofe-app` 创建的项目中。
53 |
54 | 它是构建于 [webpack](http://webpack.js.org/) 之上的。它包含了:
55 |
56 | * 一个针对绝大部分应用优化过的内部的 webpack 配置;
57 | * 项目内部的 `autofe-scripts` 命令,提供 `start` 和 `build` 命令。
58 |
59 | ## 贡献代码
60 |
61 | We'd love to have your helping hand on `create-autofe-app`! See [CONTRIBUTING.md](https://github.com/athm-fe/create-autofe-app/blob/master/CONTRIBUTING.md) for more information on what we're looking for and how to get started.
62 |
--------------------------------------------------------------------------------
/docs/guide/autofe-scripts.md:
--------------------------------------------------------------------------------
1 | # 可用命令
2 |
3 | ## 使用命令
4 |
5 | Creator 提供了一个运行时依赖,即 `autofe-scripts`,在项目的 `package.json` 中可以看到:
6 |
7 | ```json
8 | {
9 | "scripts": {
10 | "start": "autofe-scripts start",
11 | "build": "autofe-scripts build"
12 | }
13 | }
14 | ```
15 |
16 | 你可以通过 npm 或 Yarn 调用这些 script:
17 |
18 | ```sh
19 | npm start
20 | npm run build
21 |
22 | # OR
23 |
24 | yarn start
25 | yarn build
26 | ```
27 |
28 | ## `autofe-scripts start`
29 |
30 | Runs the app in development mode.
31 | Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
32 |
33 | The page will reload if you make edits.
34 |
35 | ## `autofe-scripts build`
36 |
37 | Builds the app for production to the `build` folder.
38 | It correctly bundles assets in production mode and optimizes the build for the best performance.
39 |
40 | ~~The build is minified and the filenames include the hashes. If necessary, classnames and function names can be enabled for profiling purposes. See the production build section for more information.~~
41 |
42 | Your app is ready to be deployed!
43 |
44 | ## `autofe-scripts inspect`
45 |
46 | **暂未支持,待开发。**
--------------------------------------------------------------------------------
/docs/guide/dev-convention.md:
--------------------------------------------------------------------------------
1 | # 开发约定
2 |
3 | 约定优于配置。
4 |
5 | ## 基本规则
6 |
7 | * 主要面向多页开发
8 | * `src` 为源代码目录
9 | * `build` 为打包输出目录,**且不提交到 Git 仓库**
10 | * 代码模块化、文件碎片化
11 | * 自动寻找符合规则的入口文件打包
12 | * 图片拆分 `img` 和 `pic` 目录,区别是 `pic` 仅做 demo 展示用,上线完全不需要
13 | * 勤写文档,可以使用 Markdown 做好记录
14 |
15 | ## 打包策略
16 |
17 | 关于单页开发,Webpack 有一套非常成熟的打包策略,然而对于多页开发,就不是那么美好了,经过深思熟虑,Creator 提供了一套打包机制。
18 |
19 | ### JavaScript
20 |
21 | 有以下三种类型入口文件
22 |
23 | 1. ES5 `xxx.old.js` ---> UglifyJS ---> `xxx.js`
24 | 2. ES6+ `yyy.entry.js` ---> Webpack + Babel ---> `yyy.js`
25 | 3. TypeScript `zzz.entry.ts` ---> Webpack + Babel ---> `zzz.js`
26 |
27 | ### CSS
28 |
29 | 有以下两种类型入口文件
30 |
31 | * `xxx.css` ---> Webpack ---> `xxx.css`
32 | * `xxx.scss` ---> Webpack + Sass ---> `xxx.css`
33 |
34 | **以下划线开头命名的文件只能当作模块文件,不会被打包输出。**
35 |
36 | ### HTML
37 |
38 | 由于历史原因,HTML 并没有使用 Webpack 处理,仍然使用的是 Gulp,因此功能可能不是那么强大,后续再想怎么实现吧。
39 |
40 | * `xxx.html` ---> Gulp + Nunjucks ---> `xxx.html`
41 |
42 | **以下划线开头命名的文件只能当作模块文件,不会被打包输出。**
43 |
44 | ### Markdown
45 |
46 | 勤写文档,做好记录
47 |
48 | * `xxx.md` ---> Gulp + [markedjs/marked](https://marked.js.org/) ---> `xxx.html`
--------------------------------------------------------------------------------
/docs/guide/eslint.md:
--------------------------------------------------------------------------------
1 | # ESLint
2 |
3 | 可修改 `.eslintignore` 和 `.eslintrc.js`。
4 |
5 | 详细的用法请参考[玩转 ESLint](https://github.com/athm-fe/create-autofe-app/blob/master/doc/eslint-guide.md)。
--------------------------------------------------------------------------------
/docs/guide/folder-structure.md:
--------------------------------------------------------------------------------
1 | # 目录结构
2 |
3 | 通过前文的命令,Creator 创建了一个名为 `my-app` 的项目文件夹,其目录结构大体是这样的:
4 |
5 | ```{5,6,7,8,9,10,11,12,13,14,15}
6 | my-app/
7 | README.md
8 | package.json
9 | node_modules/
10 | .gitignore
11 | .env
12 | .env.development
13 | .env.production
14 | .browserslistrc
15 | .eslintignore
16 | .eslintrc.js
17 | babel.config.js
18 | postcss.config.js
19 | creator.config.js
20 | tsconfig.json
21 | public/
22 | favicon.ico
23 | src/
24 | index/
25 | css/
26 | _base.scss
27 | _part1.scss
28 | _part2.scss
29 | _reset.scss
30 | main.scss
31 | img/
32 | bg.png
33 | js/
34 | vendor/
35 | es6-promise.auto.min.old.js
36 | index.entry.js
37 | main.old.js
38 | pic/
39 | 01.jpg
40 | _part1.html
41 | _part2.html
42 | index.html
43 | demo/
44 | index.html
45 | ```
46 |
47 | ::: tip 约定优于配置
48 | 相信很多人都听到过约定优于配置的说法,我们也遵从这个原则,约定优先,在这个项目中,我们做了很多约定,但是总会有需要自定义配置的时候,因此行业内产生了很多标准化的配置文件,我们也采用了这些标准,也就是你前面看到的那一部分高亮的文件名。
49 | :::
50 |
51 | 目前,你不需要关心这些高亮的文件,也不必修改它们。相信我,所有这些文件都是必要的,当你想自定义配置或者拓展功能的时候,会体会到它的好处。
52 |
53 | 只有 `src` 目录下的代码才会被 `autofe-scripts` 打包构建,因此你编写的所有代码都需要放在 该目录里。打包构建的文件会输出到 `build` 目录下。
54 |
55 | `public` 下的文件会被直接拷贝到 `build` 目录下,不做任何额外处理。
56 |
--------------------------------------------------------------------------------
/docs/guide/getting-started.md:
--------------------------------------------------------------------------------
1 | # 快速开始
2 |
3 | ::: tip Node 版本要求
4 | Creator 需要 [Node.js](https://nodejs.org/) 8.0 或更高版本。但暂时不要使用太新的版本,Node 12 是比较稳妥的选择。后续会考虑升级代码以支持更高版本 Node。@你可以使用 [nvm](https://github.com/creationix/nvm) 或 [nvm-windows](https://github.com/coreybutler/nvm-windows) 在同一台电脑中管理多个 Node 版本。
5 | :::
6 |
7 | 使用如下方式创建项目:
8 |
9 | ```sh
10 | npx create-autofe-app my-app
11 |
12 | cd my-app
13 | npm start
14 | ```
15 |
16 | ::: tip 推荐 npx
17 | 推荐使用 `npx` 命令,如果你之前使用 `npm install -g create-autofe-app` 安装过 `create-autofe-app` ,建议你使用 `npm uninstall -g create-autofe-app` 卸载。这样可以保证 `npx` 每次运行都使用最新版本的 `create-autofe-app`。
18 | :::
19 |
20 | ::: tip 提示
21 | npx 在 npm 5.2+ 及之上版本才支持。
22 | :::
23 |
24 | 如果你的 npm 不支持 npx,可以使用如下方式:
25 |
26 | ```sh
27 | npm install -g create-autofe-app
28 | create-autofe-app my-app
29 |
30 | cd my-app
31 | npm start
32 | ```
33 |
34 | 然后使用浏览器打开 [http://localhost:3000/](http://localhost:3000/) 即可看到你的应用。
35 | 如果你已经开发完成,可以使用 `npm run build` 命令打包,生成线上环境的资源文件。
36 |
--------------------------------------------------------------------------------
/docs/guide/images/tsinputempty.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athm-fe/create-autofe-app/787a340370d98ac16ecf1297ecb8bc699e0f0422/docs/guide/images/tsinputempty.png
--------------------------------------------------------------------------------
/docs/guide/javascript.md:
--------------------------------------------------------------------------------
1 | # JavaScript
2 |
3 | ## 路径能力
4 |
5 | * 相对路径
6 | * npm 依赖
7 | * @ 别名
8 |
9 | ## externals 配置
10 |
11 | 有时候,我们不想将某些 `import` 的依赖打包到 bundle 中,而是在运行时再去从外部获取这些扩展依赖。
12 |
13 | 例如,从 CDN 引入 jQuery,而不是把它打包:
14 |
15 | `index.html`
16 | ```html
17 |
18 |
19 | ```
20 |
21 | `index.entry.js`
22 | ```javascript
23 | const $ = import('jquery');
24 |
25 | $(function() {
26 | // do something...
27 | })
28 | ```
29 |
30 | 可以通过如下方式配置:
31 |
32 | `creator.config.js`
33 | ```javascript
34 | module.exports = {
35 | // ...
36 | externals: {
37 | jquery: 'jQuery',
38 | },
39 | // ...
40 | };
41 | ```
42 |
43 | 详细用法可以参考 [Webpack externals](https://webpack.js.org/configuration/externals/)。
44 |
45 | ## 全局变量
46 |
47 | 当使用一些全局变量的时候,ESLint 会报错,可以通过如下方式配置:
48 |
49 | `.eslintrc.js`
50 | ```javascript
51 | module.exports = {
52 | globals: {
53 | AHAPP: 'readonly',
54 | $: 'readonly',
55 | trackCustomEvent: 'readonly',
56 | },
57 | }
58 | ```
59 |
60 | ::: tip 提示
61 | 这个和 `externals` 配置不是一个概念,这个是直接使用 ES6 文件中不存在的全局变量。
62 | :::
63 |
64 | ## 内嵌样式
65 |
66 | 有时候,我们希望只提供一个脚本给使用方,该脚本负责动态插入样式,可以通过如下方式实现
67 |
68 | ```javascript
69 | import '../css/main.scss?inline';
70 | ```
71 |
72 | ::: warning
73 | 注意:如果使用 JS 来动态插入样式,样式内的图片路径有可能会出错,由于目前还没想好如何处理 `publicPath`,建议 CSS 中使用绝对路径来引用图片
74 | :::
--------------------------------------------------------------------------------
/docs/guide/mode-and-env.md:
--------------------------------------------------------------------------------
1 | # 环境变量和模式
2 |
3 | 你可以替换你的项目根目录中的下列文件来指定环境变量:
4 |
5 | ``` bash
6 | .env # 在所有的环境中被载入
7 | .env.local # 在所有的环境中被载入,但会被 git 忽略
8 | .env.[mode] # 只在指定的模式中被载入
9 | .env.[mode].local # 只在指定的模式中被载入,但会被 git 忽略
10 | ```
11 |
12 | 一个环境文件只包含环境变量的“键=值”对:
13 |
14 | ```
15 | FOO=bar
16 | APP_SECRET=secret
17 | ```
18 |
19 | 被载入的变量将会被 `autofe-scripts` 内部访问到。
20 |
21 | ::: tip 环境加载属性
22 |
23 | 为一个特定模式准备的环境文件的 (例如 `.env.production`) 将会比一般的环境文件 (例如 `.env`) 拥有更高的优先级。
24 |
25 | 此外,Creator 启动时已经存在的环境变量拥有最高优先级,并不会被 `.env` 文件覆写。
26 | :::
27 |
28 | ## 模式
29 |
30 | **模式**是 Creator 项目中一个重要的概念。默认情况下,一个 Creator 项目有两个模式:
31 |
32 | - `development` 模式用于 `autofe-scripts start`
33 | - `production` 模式用于 `autofe-scripts build`
34 |
35 | 注意模式不同于 `NODE_ENV`,一个模式可以包含多个环境变量。也就是说,每个模式都会将 `NODE_ENV` 的值设置为模式的名称——比如在 development 模式下 `NODE_ENV` 的值会被设置为 `"development"`。
36 |
37 | 你可以通过为 `.env` 文件增加后缀来设置某个模式下特有的环境变量。比如,如果你在项目根目录创建一个名为 `.env.development` 的文件,那么在这个文件里声明过的变量就只会在 development 模式下被载入。
38 |
39 | ## 在客户端侧代码中使用环境变量
40 |
41 | 只有以 `APP_` 开头的变量会被 `webpack.DefinePlugin` 静态嵌入到客户端侧的包中。你可以在应用的代码中这样访问它们:
42 |
43 | ``` js
44 | console.log(process.env.APP_SECRET)
45 | ```
46 |
47 | 在构建过程中,`process.env.APP_SECRET` 将会被相应的值所取代。在 `APP_SECRET=secret` 的情况下,它会被替换为 `"secret"`。
48 |
49 | 除了 `APP_*` 变量之外,在你的应用代码中始终可用的还有两个特殊的变量:
50 |
51 | - `NODE_ENV` - 会是 `"development"`、`"production"` 中的一个。具体的值取决于应用运行的[模式](#模式)。
52 | - `BASE_URL` - 会和 `creator.config.js` 中的 `publicPath` 选项相符,即你的应用会部署到的基础路径。
53 |
54 | 所有解析出来的环境变量也可以在 JavaScript、HTML 和 SASS 中使用。
55 |
56 | ::: tip 提示
57 | 你可以在 `creator.config.js` 文件中计算环境变量。它们仍然需要以 `APP_` 前缀开头。这可以用于版本信息 `process.env.APP_VERSION = require('./package.json').version`。
58 | :::
59 |
60 | ### JavaScript
61 |
62 | ```javascript
63 | console.log(process.env.BASE_URL);
64 | console.log(process.env.NODE_ENV);
65 | console.log(process.env.APP_TEST_ENV_FEATURE);
66 | ```
67 |
68 | ### HTML
69 |
70 | ```html
71 | {{ APP_TEST_ENV_FEATURE }}
72 |
73 | {% if NODE_ENV === 'development' %}
74 | 这是只出现在开发环境的内容
75 | {% else %}
76 | 这是只出现在生产环境的内容
77 | {% endif %}
78 | ```
79 |
80 | ### SASS
81 |
82 | ```scss
83 | .box {
84 | background-image: url(#{$BASE_URL}/img/logo.png);
85 | content: $APP_TEST_ENV_FEATURE;
86 | }
87 | ```
88 |
89 | ## 只在本地有效的变量
90 |
91 | 有的时候你可能有一些不应该提交到代码仓库中的变量,尤其是当你的项目托管在公共仓库时。这种情况下你应该使用一个 `.env.local` 文件取而代之。本地环境文件默认会被忽略,且出现在 `.gitignore` 中。
92 |
93 | `.local` 也可以加在指定模式的环境文件上,比如 `.env.development.local` 将会在 development 模式下被载入,且被 git 忽略。
94 |
--------------------------------------------------------------------------------
/docs/guide/static-assets.md:
--------------------------------------------------------------------------------
1 | # 静态资源
2 |
3 | 静态资源可以通过如下方式进行处理:
4 |
5 | * 在 JavaScript 被导入或 CSS 中通过相对路径被引用。这类引用会被 webpack 处理;
6 | * 其余资源将会直接被拷贝,而不会经过 webpack 的处理。包括:
7 | * 放置在 `public` 目录;
8 | * 通过绝对路径被引用;
9 | * 由于历史原因,没有被 JavaScript 和 CSS 引用的图片、字体、视频等文件也会被直接拷贝。
10 |
11 | 另外,需要注意:
12 | * HTML 中的资源路径也不会被解析,你写的是什么,它就是什么;
13 | * `xxx.old.js` 规则的 JavaScript 文件中的资源路径也不会被解析。
14 |
15 | ## 从相对路径导入
16 |
17 | 当你在 JavaScript、CSS 中使用非绝对路径引用一个静态资源时,该资源将会被包含进入 webpack 的依赖图中。在其编译过程中,所有诸如 `background: url(...)` 和 CSS `@import` 的资源 URL **都会被解析为一个模块依赖**。
18 |
19 | 例如,`url(./image.png)` 会被翻译为 `require('./image.png')`。
20 |
21 | 在其内部,我们通过 `file-loader` 用版本哈希值和正确的公共基础路径来决定最终的文件路径,再用 `url-loader` 将小于 1kb 的资源内联,以减少 HTTP 请求的数量。
22 |
23 | ## datauri
24 |
25 | 除了 `url-loader` 会自动将小于 1kb 的资源内联外,我们还开发了明确的指令 `?datauri`,通过该方式可以不考虑文件大小,直接实现资源内联:
26 |
27 | ```scss
28 | .datauri-example {
29 | background: url("./car.jpg?datauri") no-repeat;
30 | }
31 | ```
32 |
33 | ## svg inline
34 |
35 | 对于 SVG 文件,我们有时候也需要获取其内容,可以通过指令 `?inline` 做到:
36 |
37 | ```javascript
38 | import svgContent from '../img/postcss-assets.svg?inline';
39 | ```
40 |
41 | ::: tip 提示
42 | 请思考 `one.svg?inline` 和 `one.svg?datauri` 的区别。
43 | :::
44 |
45 | ## 路径规则
46 |
47 | JavaScript 和 CSS 在路径上略有不同,详情请参考:
48 |
49 | * [JavaScript 路径能力](./javascript.html#路径能力)
50 | * [CSS 路径能力](./css.html#路径能力)
51 |
52 | 简单罗列如下:
53 |
54 | `index.entry.js`
55 | ```javascript
56 | // 相对路径
57 | import bg1 from './bg.png';
58 | import bg2 from '../img/bg.png';
59 |
60 | // 内嵌 Datauri
61 | import bg3 from '../img/bg.png?datauri';
62 | import svgDatauri from '../img/postcss-assets.svg?datauri';
63 |
64 | // 获取 SVG 内容
65 | import svgContent from '../img/postcss-assets.svg?inline';
66 |
67 | // npm 依赖
68 | import sharePic from 'a-pkg-from-npm/share.png';
69 |
70 | // @ 别名
71 | import logo from '@/assets/logo.png';
72 | ```
73 |
74 | `index.scss`
75 | ```scss
76 | // 相对路径
77 | @import "./base.css";
78 | @import "base.css";
79 |
80 | // npm 依赖
81 | @import "~normalize.css";
82 |
83 | // @ 别名
84 | @import "@/common/reset.css";
85 | @import "~@/common/reset.css";
86 |
87 | .path-example {
88 | // 相对路径
89 | background: url("./car.jpg") no-repeat;
90 | background: url("car.jpg") no-repeat;
91 |
92 | // npm 依赖
93 | background: url("~a-pkg-from-npm/share.png") no-repeat;
94 |
95 | // @ 别名
96 | background: url("~@/index/img/car.jpg") no-repeat;
97 | // not working
98 | // background: url("@/index/img/car.jpg") no-repeat;
99 | }
100 | ```
101 |
102 | ## `public` 文件夹
103 |
104 | 任何放置在 `public` 文件夹的静态资源都会被简单的复制,而不经过 webpack。你需要通过绝对路径来引用它们。
105 |
--------------------------------------------------------------------------------
/docs/guide/troubleshooting.md:
--------------------------------------------------------------------------------
1 | ---
2 | sidebarDepth: 0
3 | ---
4 |
5 | # Troubleshooting
6 |
7 | This document covers some common issues and how to resolve them. You should always follow these steps before opening a new issue.
8 |
9 | ## TypeScript No inputs were found in config file
10 |
11 | **该问题已经修复**
12 |
13 | 有可能你会遇到如下图中的报错:
14 |
15 | 
16 |
17 | 这是因为 `tsconfig.json` 中 `include` 字段的配置要求你至少有一个 `.ts` 文件,解决办法很简单,在 `src` 目录下新建一个文件即可,比如 `hello.ts` 。
--------------------------------------------------------------------------------
/docs/guide/typescript.md:
--------------------------------------------------------------------------------
1 | # TypeScript
2 |
3 | 假设你已经有 TypeScript 的基础,创建 `xxx.entry.ts` 即可作为入口文件,`yyy.ts` 作为模块文件,被入口文件使用。
4 |
5 | ## TS 使用 jQuery
6 |
7 | TypeScript 使用的是自己的模块系统,没有使用 Webpack 的,所以你之前配置的 `externals` 并不会起作用。
8 |
9 | `creator.config.js`
10 | ```javascript
11 | module.exports = {
12 | // ...
13 | externals: {
14 | jquery: 'jQuery',
15 | },
16 | // ...
17 | };
18 | ```
19 |
20 | 如果你已经了解 TypeScript 的话,你就会知道,只要安装如下包,就可以达到类似 Webpack 的 `externals` 的效果:
21 |
22 | ```sh
23 | npm i --save-dev @types/jquery
24 | ```
--------------------------------------------------------------------------------
/docs/guide/updating-to-new-releases.md:
--------------------------------------------------------------------------------
1 | # 更新版本
2 |
3 | Creator 分成两个包:
4 | * `create-autofe-app` 是一个全局命令行工具,可以用来创建项目,之后就基本用不到。
5 | * `autofe-scripts` 是上面创建的项目在开发过程中所需要的一个运行时依赖包,一般情况下,也只需要这个包就够了。
6 |
7 | ## 升级 create-autofe-app
8 |
9 | ::: tip 提示
10 | 关于 create-autofe-app 的安装和使用请移步[快速开始](./getting-started)。
11 | :::
12 |
13 | 前面讲到过,如果想要创建项目,执行如下命令即可:
14 |
15 | ```sh
16 | npx create-autofe-app my-app
17 | ```
18 |
19 | 当运行 `create-autofe-app` 来创建新项目的时候,它总是会去 npm 下载 `autofe-scripts@latest`,所以你能够自动获得最新发布的功能或者优化。
20 |
21 | ## 升级 autofe-scripts
22 |
23 | 如果你已经有了一个项目,并且想把该项目的 `autofe-scripts` 升级到新版本。请先[打开版本修改日志](https://github.com/athm-fe/create-autofe-app/blob/master/CHANGELOG.md),找到你的当前版本(在 `package.json` 可以找到)和新版本之间的差异。有可能新版本和老版本不兼容,需要你按照 `CHANGELOG.md` 的说明来修改你的代码。
24 |
25 | 但是我们会尽量保证 `autofe-scripts` 新老版本之间的兼容,做到不需要你修改代码,或者仅仅是修改少量的代码,即可迁移成功。
26 |
27 | 所以,大多数情况下,执行如下命令即可:
28 |
29 | ```sh
30 | npm i --save-dev autofe-scripts@latest
31 | ```
32 |
33 | 该命令会自动产生如下改动:
34 |
35 | ```diff
36 | // package.json
37 | {
38 | "devDependencies": {
39 | - "autofe-scripts": "^1.2.0",
40 | + "autofe-scripts": "^1.3.4",
41 | },
42 | }
43 | ```
44 |
45 | 如果想安装指定版本,只要手动修改 `package.json` 文件里的 `autofe-scripts` 的版本号,然后重新 `npm install` 即可。
46 |
47 | ## 重大变更
48 |
49 | * `autofe-script@1.3.4` 主要基于 Webpack 实现,仅残留部分 Gulp 实现。极大增强 CSS 能力,并增强了配置能力。
50 | * [如何迁移到 autofe-scripts v1 版本](https://github.com/athm-fe/create-autofe-app/blob/master/doc/how-to-migrate-to-v1.md)
51 | * [如果手动支持 TypeScript](https://github.com/athm-fe/create-autofe-app/blob/master/doc/how-to-ts.md)
52 | * `autofe-script@0.x` 主要基于 Gulp 实现,仅仅 ES6+ 部分使用 Webpack 实现
53 |
54 | 详情请参考[更新记录](https://github.com/athm-fe/create-autofe-app/blob/master/CHANGELOG.md)
--------------------------------------------------------------------------------
/docs/guide/webpack.md:
--------------------------------------------------------------------------------
1 | # webpack 相关
2 |
3 | ## 简单的配置方式
4 |
5 | 调整 webpack 配置最简单的方式就是在 `creator.config.js` 中的 `configureWebpack` 选项提供一个对象:
6 |
7 | ``` js
8 | // creator.config.js
9 | module.exports = {
10 | configureWebpack: {
11 | plugins: [
12 | new MyAwesomeWebpackPlugin()
13 | ]
14 | }
15 | }
16 | ```
17 |
18 | 该对象将会被 [webpack-merge](https://github.com/survivejs/webpack-merge) 合并入最终的 webpack 配置。
19 |
20 | ::: warning 警告
21 | 有些 webpack 选项是基于 `creator.config.js` 中的值设置的,所以不能直接修改。例如你应该修改 `creator.config.js` 中的 `publicPath` 选项而不是修改 `output.publicPath`。这样做是因为 `creator.config.js` 中的值会被用在配置里的多个地方,以确保所有的部分都能正常工作在一起。
22 | :::
23 |
24 | 如果你需要基于环境有条件地配置行为,或者想要直接修改配置,那就换成一个函数 (该函数会在环境变量被设置之后懒执行)。该方法的第一个参数会收到已经解析好的配置。在函数内,你可以直接修改配置,或者返回一个将会被合并的对象:
25 |
26 | ``` js
27 | // creator.config.js
28 | module.exports = {
29 | configureWebpack: config => {
30 | if (process.env.NODE_ENV === 'production') {
31 | // 为生产环境修改配置...
32 | } else {
33 | // 为开发环境修改配置...
34 | }
35 | }
36 | }
37 | ```
38 |
39 | ## 链式操作 (高级)
40 |
41 | Creator 内部的 webpack 配置是通过 [webpack-chain](https://github.com/mozilla-neutrino/webpack-chain) 维护的。这个库提供了一个 webpack 原始配置的上层抽象,使其可以定义具名的 loader 规则和具名插件,并有机会在后期进入这些规则并对它们的选项进行修改。
42 |
43 | 它允许我们更细粒度的控制其内部配置。接下来有一些常见的在 `creator.config.js` 中的 `chainWebpack` 修改的例子。
44 |
45 | ::: tip 提示
46 | 当你打算链式访问特定的 loader 时,[autofe-scripts inspect](#审查项目的-webpack-配置) 会非常有帮助。
47 | :::
48 |
49 | ### 修改 Loader 选项
50 |
51 | ``` js
52 | // creator.config.js
53 | module.exports = {
54 | chainWebpack: config => {
55 | config.module
56 | .rule('css')
57 | .use('css-loader')
58 | .loader('css-loader')
59 | .tap(options => {
60 | // 修改它的选项...
61 | return options
62 | })
63 | }
64 | }
65 | ```
66 |
67 | ::: tip 提示
68 | 对于 CSS 相关 loader 来说,我们推荐使用 [css.loaderOptions](../config/#css-loaderoptions) 而不是直接链式指定 loader。这是因为每种 CSS 文件类型都有多个规则,而 `css.loaderOptions` 可以确保你通过一个地方影响所有的规则。
69 | :::
70 |
71 | ### 添加一个新的 Loader
72 |
73 | ``` js
74 | // creator.config.js
75 | module.exports = {
76 | chainWebpack: config => {
77 | // GraphQL Loader
78 | config.module
79 | .rule('graphql')
80 | .test(/\.graphql$/)
81 | .use('graphql-tag/loader')
82 | .loader('graphql-tag/loader')
83 | .end()
84 | }
85 | }
86 | ```
87 |
88 | ### 修改插件选项
89 |
90 | ``` js
91 | // creator.config.js
92 | module.exports = {
93 | chainWebpack: config => {
94 | config
95 | .plugin('fork-ts-checker')
96 | .tap(args => {
97 | return [/* 传递给 fork-ts-checker-webpack-plugin's 构造函数的新参数 */]
98 | })
99 | }
100 | }
101 | ```
102 |
103 | 你需要熟悉 [webpack-chain 的 API](https://github.com/mozilla-neutrino/webpack-chain#getting-started) 以便了解如何最大程度利用好这个选项,但是比起直接修改 webpack 配置,它的表达能力更强,也更为安全。
104 |
105 | 比方说你想要将 `index.html` 默认的路径从 */U
106 | 你可以通过接下来要讨论的工具 **`autofe-scripts inspect`** 来确认变更。
107 |
108 | ## 审查项目的 webpack 配置
109 |
110 | 因为 `autofe-scripts` 对 webpack 配置进行了抽象,所以理解配置中包含的东西会比较困难,尤其是当你打算自行对其调整的时候。
111 |
112 | `autofe-scripts` 暴露了 `inspect` 命令用于审查解析好的 webpack 配置。
113 |
114 | 该命令会将解析出来的 webpack 配置、包括链式访问规则和插件的提示打印到 stdout。
115 |
116 | 你可以将其输出重定向到一个文件以便进行查阅:
117 |
118 | ``` bash
119 | autofe-scripts inspect > output.js
120 | ```
121 |
122 | 注意它输出的并不是一个有效的 webpack 配置文件,而是一个用于审查的被序列化的格式。
123 |
124 | 你也可以通过指定一个路径来审查配置的一小部分:
125 |
126 | ``` bash
127 | # 只审查第一条规则
128 | autofe-scripts inspect module.rules.0
129 | ```
130 |
131 | 或者指向一个规则或插件的名字:
132 |
133 | ``` bash
134 | autofe-scripts inspect --rule vue
135 | autofe-scripts inspect --plugin html
136 | ```
137 |
138 | 最后,你可以列出所有规则和插件的名字:
139 |
140 | ``` bash
141 | autofe-scripts inspect --rules
142 | autofe-scripts inspect --plugins
143 | ```
144 |
145 | ## 以一个文件的方式使用解析好的配置
146 |
147 | 有些外部工具可能需要通过一个文件访问解析好的 webpack 配置,比如那些需要提供 webpack 配置路径的 IDE 或 CLI。在这种情况下你可以使用如下路径:
148 |
149 | ```
150 | /node_modules/autofe-scripts/webpack.config.js
151 | ```
152 |
153 | 该文件会动态解析并输出 `autofe-scripts` 命令中使用的相同的 webpack 配置。
154 |
--------------------------------------------------------------------------------
/lerna.json:
--------------------------------------------------------------------------------
1 | {
2 | "lerna": "2.11.0",
3 | "npmClient": "yarn",
4 | "useWorkspaces": true,
5 | "version": "independent",
6 | "packages": [
7 | "packages/*"
8 | ]
9 | }
10 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "private": true,
3 | "workspaces": [
4 | "packages/*"
5 | ],
6 | "scripts": {
7 | "start": "cd packages/autofe-scripts && node bin/autofe-scripts.js start",
8 | "build": "cd packages/autofe-scripts && node bin/autofe-scripts.js build",
9 | "test": "cd packages/autofe-scripts && node bin/autofe-scripts.js test",
10 | "create-autofe-app": "node tasks/cra.js",
11 | "publish": "tasks/release.sh",
12 | "docs": "vuepress dev docs --temp .temp",
13 | "docs:build": "vuepress build docs --temp .temp",
14 | "docs:release": "tasks/releaseDoc.sh"
15 | },
16 | "devDependencies": {
17 | "@vuepress/plugin-back-to-top": "^1.4.0",
18 | "@vuepress/plugin-google-analytics": "^1.4.0",
19 | "@vuepress/plugin-medium-zoom": "^1.4.0",
20 | "@vuepress/plugin-pwa": "^1.4.0",
21 | "eslint": "^7.1.0",
22 | "lerna": "^2.11.0",
23 | "vuepress": "^1.4.0",
24 | "vuepress-plugin-flowchart": "^1.4.3"
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/packages/autofe-polyfill/README.md:
--------------------------------------------------------------------------------
1 | # autofe-polyfill
2 |
3 | This package includes polyfills for various browsers.
4 | It includes minimum requirements and commonly used language features used by [Create AutoFE App](https://github.com/athm-fe/create-autofe-app) projects.
5 |
6 | ## Usage
7 |
8 | First, install the package using Yarn or npm:
9 |
10 | ```sh
11 | npm install autofe-polyfill
12 | ```
13 |
14 | or
15 |
16 | ```sh
17 | yarn add autofe-polyfill
18 | ```
19 |
20 | ## Polyfills
21 |
22 | * `Promise` (for `async` / `await` support)
23 | * `Object.assign` (a helper required for Object Spread, i.e. `{ ...a, ...b }`)
24 | * `Symbol` (a built-in object used by `for...of` syntax and friends)
25 | * `Array.from` (a built-in static method used by array spread, i.e. `[...arr]`)
26 |
27 | ## More Features
28 |
29 | If you need more features, see the [browser compatibility](https://athm-fe.github.io/create-autofe-app/guide/browser-compatibility.html)
30 |
--------------------------------------------------------------------------------
/packages/autofe-polyfill/index.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2015-present, Facebook, Inc.
3 | *
4 | * This source code is licensed under the MIT license found in the
5 | * LICENSE file in the root directory of this source tree.
6 | */
7 |
8 | if (typeof Promise === 'undefined') {
9 | // Rejection tracking prevents a common issue where React gets into an
10 | // inconsistent state due to an error, but it gets swallowed by a Promise,
11 | // and the user has no idea what causes React's erratic future behavior.
12 | require('promise/lib/rejection-tracking').enable();
13 | self.Promise = require('promise/lib/es6-extensions.js');
14 | }
15 |
16 | // Object.assign() is commonly used with React.
17 | // It will use the native implementation if it's present and isn't buggy.
18 | Object.assign = require('object-assign');
19 |
20 | // Support for...of (a commonly used syntax feature that requires Symbols)
21 | require('core-js/features/symbol');
22 | // Support iterable spread (...Set, ...Map)
23 | require('core-js/features/array/from');
24 |
--------------------------------------------------------------------------------
/packages/autofe-polyfill/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "autofe-polyfill",
3 | "version": "1.2.0",
4 | "description": "Polyfills used by AutoFE apps",
5 | "repository": {
6 | "type": "git",
7 | "url": "https://github.com/athm-fe/create-autofe-app.git",
8 | "directory": "packages/autofe-polyfill"
9 | },
10 | "author": "jpuncle",
11 | "engines": {
12 | "node": ">=8"
13 | },
14 | "bugs": {
15 | "url": "https://github.com/athm-fe/create-autofe-app/issues"
16 | },
17 | "files": [
18 | "index.js"
19 | ],
20 | "dependencies": {
21 | "core-js": "^3.6.5",
22 | "object-assign": "^4.1.1",
23 | "promise": "^8.1.0"
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/packages/autofe-scripts/.gitignore:
--------------------------------------------------------------------------------
1 | template/build
--------------------------------------------------------------------------------
/packages/autofe-scripts/.npmignore:
--------------------------------------------------------------------------------
1 | template/build
2 | template/src/fixtures
3 | template/.eslintignore
4 | *.tgz
--------------------------------------------------------------------------------
/packages/autofe-scripts/README.md:
--------------------------------------------------------------------------------
1 | # autofe-scripts
2 |
3 | [Full Docs](https://athm-fe.github.io/create-autofe-app/)
4 |
--------------------------------------------------------------------------------
/packages/autofe-scripts/bin/autofe-scripts.js:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env node
2 |
3 | 'use strict';
4 |
5 | const spawn = require('cross-spawn');
6 |
7 | const script = process.argv[2];
8 | const args = process.argv.slice(3);
9 |
10 | switch (script) {
11 | case 'start':
12 | case 'build':
13 | case 'test':
14 | case 'eject': {
15 | const result = spawn.sync(
16 | 'node',
17 | [require.resolve(`../scripts/${script}`)].concat(args),
18 | { stdio: 'inherit' }
19 | );
20 | process.exit(result.status);
21 | break;
22 | }
23 | default:
24 | console.log(`Unknown script "${script}".`);
25 | console.log('Perhaps you need to update autofe-scripts?');
26 | break;
27 | }
28 |
--------------------------------------------------------------------------------
/packages/autofe-scripts/config/env.js:
--------------------------------------------------------------------------------
1 | const path = require('path');
2 | const logger = require('debug')('creator:env');
3 | const dotenv = require('dotenv');
4 | const dotenvExpand = require('dotenv-expand');
5 | const config = require('./index');
6 |
7 | function loadEnv(mode) {
8 | const basePath = path.resolve(config.appDirectory, `.env${mode ? `.${mode}` : ``}`)
9 | const localPath = `${basePath}.local`
10 |
11 | const load = envPath => {
12 | try {
13 | const env = dotenv.config({ path: envPath, debug: process.env.DEBUG })
14 | dotenvExpand(env)
15 | } catch (err) {
16 | logger.error(err);
17 | }
18 | }
19 |
20 | load(localPath)
21 | load(basePath)
22 | }
23 |
24 | module.exports = loadEnv;
25 |
--------------------------------------------------------------------------------
/packages/autofe-scripts/config/index.js:
--------------------------------------------------------------------------------
1 | const fs = require('fs-extra');
2 | const {
3 | appDirectory,
4 | appSrc,
5 | appBuild,
6 | appPublic,
7 | appConfig,
8 | isCreatorDev,
9 | } = require('./paths');
10 |
11 | const appDefaultConfig = {
12 | publicPath: '/',
13 | externals: {},
14 | transpileDependencies: [],
15 | configureWebpack: {},
16 | css: {
17 | loaderOptions: {},
18 | },
19 | };
20 |
21 | const config = {
22 | appDirectory,
23 | appSrc,
24 | appBuild,
25 | appPublic,
26 | isCreatorDev,
27 | ...appDefaultConfig,
28 | }
29 |
30 | const configExists = fs.pathExistsSync(appConfig);
31 | if (configExists) {
32 | Object.assign(config, require(appConfig));
33 | }
34 |
35 | config.css = config.css || {};
36 | config.css.loaderOptions = config.css.loaderOptions || {};
37 |
38 | module.exports = config;
--------------------------------------------------------------------------------
/packages/autofe-scripts/config/paths.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | const path = require('path');
4 | const fs = require('fs');
5 |
6 | // Make sure any symlinks in the project folder are resolved:
7 | // https://github.com/facebookincubator/create-react-app/issues/637
8 | const appDirectory = fs.realpathSync(process.cwd());
9 | function resolveApp(relativePath) {
10 | return path.resolve(appDirectory, relativePath);
11 | }
12 |
13 | module.exports = {
14 | appDirectory,
15 | appSrc: resolveApp('src'),
16 | appBuild: resolveApp('build'),
17 | appPublic: resolveApp('public'),
18 | appConfig: resolveApp('creator.config.js'),
19 | isCreatorDev: false,
20 | };
21 |
22 | function resolveOwn(relativePath) {
23 | return path.resolve(__dirname, relativePath);
24 | }
25 |
26 | if (__dirname.indexOf(path.join('packages', 'autofe-scripts', 'config')) !== -1) {
27 | module.exports = {
28 | appDirectory: resolveOwn('../template'),
29 | appSrc: resolveOwn('../template/src'),
30 | appBuild: resolveOwn('../template/build'),
31 | appPublic: resolveOwn('../template/public'),
32 | appConfig: resolveOwn('../template/creator.config.js'),
33 | isCreatorDev: true,
34 | };
35 | }
36 |
--------------------------------------------------------------------------------
/packages/autofe-scripts/gulpfile.js/config.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | const join = require('path').posix.join;
4 |
5 | const root = {
6 | src: 'src',
7 | dest: 'build',
8 | };
9 |
10 | module.exports = {
11 | src: root.src,
12 | dest: root.dest,
13 | clean: {
14 | dest: root.dest,
15 | },
16 | js: {
17 | src: join(root.src, '/**/*.old.js'),
18 | dest: root.dest,
19 | },
20 | html: {
21 | src: join(root.src, '/**/*.html'),
22 | dest: root.dest,
23 | exclude: `!${join(root.src, '/**/_*.html')}`,
24 | },
25 | htmlBundle: {
26 | src: join(root.dest, '/**/*.bundle.html'),
27 | dest: root.dest,
28 | },
29 | markdown: {
30 | src: join(root.src, '/**/*.md'),
31 | dest: root.dest,
32 | },
33 | };
34 |
--------------------------------------------------------------------------------
/packages/autofe-scripts/gulpfile.js/index.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | const { watch, series, parallel } = require('gulp');
4 | const log = require('fancy-log');
5 | const config = require('./config');
6 | const { clean } = require('./tasks/clean');
7 | const { js } = require('./tasks/js');
8 | const { webpack } = require('./tasks/webpack');
9 | const { html } = require('./tasks/html');
10 | const { markdown } = require('./tasks/markdown');
11 | const { htmlBundle } = require('./tasks/html-bundle');
12 |
13 | function reload(cb) {
14 | if (global.__creator_dev_server) {
15 | const server = global.__creator_dev_server;
16 | server.sockWrite(server.sockets, 'content-changed');
17 | }
18 | cb();
19 | }
20 |
21 | function myWatch(...args) {
22 | const watcher = watch(...args);
23 |
24 | watcher.on('change', function(path) {
25 | log(`File ${path} was changed`);
26 | });
27 | watcher.on('add', function(path) {
28 | log(`File ${path} was added`);
29 | });
30 | watcher.on('unlink', function(path) {
31 | log(`File ${path} was removed`);
32 | });
33 |
34 | return watcher;
35 | }
36 |
37 | const watchTask = function(cb) {
38 | myWatch(config.js.src, series(js, reload));
39 | myWatch(config.html.src, series(html, reload));
40 | myWatch(config.markdown.src, series(markdown, reload));
41 |
42 | cb();
43 | };
44 | watchTask.displayName = 'watch';
45 |
46 | const build = series(
47 | clean,
48 | parallel(js, webpack, html, markdown),
49 | htmlBundle,
50 | );
51 |
52 | const serve = series(
53 | clean,
54 | parallel(js, webpack, html, markdown),
55 | watchTask,
56 | );
57 |
58 | exports.build = build;
59 | exports.serve = serve;
60 |
--------------------------------------------------------------------------------
/packages/autofe-scripts/gulpfile.js/lib/svgmin.js:
--------------------------------------------------------------------------------
1 | const { Transform } = require('stream');
2 | const SVGO = require('svgo');
3 | const PluginError = require('plugin-error');
4 |
5 | const PLUGIN_NAME = 'gulp-svgmin';
6 |
7 | module.exports = function(options = {}) {
8 | const stream = new Transform({ objectMode: true });
9 | let svgo = new SVGO(options);
10 |
11 | stream._transform = function(file, encoding, next) {
12 | if (file.isNull()) {
13 | return next(null, file);
14 | }
15 |
16 | if (file.isStream()) {
17 | return next(new PluginError(PLUGIN_NAME, 'Streaming not supported'));
18 | }
19 |
20 | if (file.isBuffer()) {
21 | svgo.optimize(String(file.contents)).then(result => {
22 | file.contents = Buffer.from(result.data);
23 | next(null, file);
24 | }).catch(error => {
25 | next(new PluginError(PLUGIN_NAME, error));
26 | });
27 | }
28 | };
29 |
30 | return stream;
31 | };
--------------------------------------------------------------------------------
/packages/autofe-scripts/gulpfile.js/tasks/clean.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | const del = require('del');
4 | const config = require('../config');
5 |
6 | function clean() {
7 | const patterns = config.clean.dest;
8 | return del(patterns);
9 | }
10 |
11 | exports.clean = clean;
12 |
--------------------------------------------------------------------------------
/packages/autofe-scripts/gulpfile.js/tasks/html-bundle.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | const { src, dest } = require('gulp');
4 | const config = require('../config');
5 | const include = require('gulp-include');
6 |
7 | function htmlBundle() {
8 | return src(config.htmlBundle.src)
9 | .pipe(include())
10 | .pipe(dest(config.htmlBundle.dest));
11 | }
12 |
13 | exports.htmlBundle = htmlBundle;
14 |
--------------------------------------------------------------------------------
/packages/autofe-scripts/gulpfile.js/tasks/html.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | const { src, dest } = require('gulp');
4 | const config = require('../config');
5 | const render = require('gulp-nunjucks-render');
6 | const data = require('gulp-data');
7 | const path = require('path');
8 | const PluginError = require('plugin-error');
9 | const projectConfig = require('../../config');
10 | const resolveClientEnv = require('../../util/resolveClientEnv');
11 | const gulpif = require('gulp-if');
12 | const insert = require('gulp-insert');
13 |
14 | const isProd = process.env.NODE_ENV === 'production';
15 |
16 | const manageEnvironment = function (env) {
17 | // IncludePrettyExtension
18 | function IncludePrettyExtension() {
19 | const tagName = 'includePretty';
20 | this.tags = [tagName];
21 | this.parse = function (parse, nodes) {
22 | const tag = parse.peekToken();
23 | if (!parse.skipSymbol(tagName)) {
24 | parse.fail(`parseTemplateRef: expected ${tagName}`);
25 | }
26 |
27 | let indent = 0;
28 | const colno = tag.colno;
29 | // 回到行首
30 | parse.tokens.backN(colno + tagName.length);
31 | // 找到该行第一个字符的索引
32 | try {
33 | let str = parse.tokens.currentStr();
34 | for (; indent < colno; indent++) {
35 | if (str.charAt(indent) !== ' ') {
36 | break;
37 | }
38 | }
39 | } catch (e) {
40 | // 假定开头内容为 {% includePretty
41 | indent = colno - 3;
42 | }
43 | // 回到原位置
44 | parse.tokens.forwardN(colno + tagName.length);
45 |
46 | const args = parse.parseSignature(null, true);
47 |
48 | // var node = new nodes.Include(tag.lineno, tag.colno);
49 | // node.template = parse.parseExpression();
50 |
51 | parse.advanceAfterBlockEnd(tag.value);
52 |
53 | const indentValue = new nodes.Output(0, 0, [new nodes.TemplateData(0, 0, indent)]);
54 |
55 | const node = new nodes.CallExtension(this, 'run', args, [indentValue]);
56 |
57 | return node;
58 | };
59 | this.run = function (context, url, indentValue) {
60 | let output = '';
61 | const indentWidth = indentValue();
62 | const indentFilter = env.getFilter('indent');
63 | const trimFilter = env.getFilter('trim');
64 | const safeFilter = env.getFilter('safe');
65 |
66 | try {
67 | const tmpl = env.getTemplate(url);
68 | let result = tmpl.render(context.getVariables());
69 | if (indentWidth > 0) {
70 | result = indentFilter(result, indentWidth);
71 | }
72 | result = trimFilter(result);
73 | output = result;
74 | } catch (e) {
75 | throw e;
76 | }
77 |
78 | return safeFilter(output);
79 | };
80 | }
81 | env.addExtension('IncludePrettyExtension', new IncludePrettyExtension());
82 |
83 | // Filter: assets
84 | env.addFilter('assets', function (assetpath) {
85 | const url = path.join(this.ctx.__ctx_file.prefix || '', assetpath);
86 | return url;
87 | });
88 | };
89 |
90 | const options = {
91 | path: [config.src],
92 | manageEnv: manageEnvironment,
93 | };
94 |
95 | function html() {
96 | return src([config.html.src, config.html.exclude])
97 | .pipe(data((file) => {
98 | const obj = {
99 | path: file.path,
100 | relative: file.relative,
101 | base: file.base,
102 | prefix: path.relative(path.resolve(file.path, '..'), file.base),
103 | };
104 | return {
105 | __ctx_file: obj,
106 | ...resolveClientEnv(projectConfig, true),
107 | };
108 | }))
109 | .pipe(render(options))
110 | .on('error', function (error) {
111 | const message = new PluginError('nunjucks', error).toString();
112 | process.stderr.write(`${message}\n`);
113 |
114 | if (isProd) {
115 | process.exit(1);
116 | } else {
117 | this.emit('end');
118 | }
119 | })
120 | .pipe(gulpif(process.env.NODE_ENV !== 'production', insert.append(
121 | ''
122 | )))
123 | .pipe(dest(config.html.dest))
124 | }
125 |
126 | exports.html = html;
127 |
--------------------------------------------------------------------------------
/packages/autofe-scripts/gulpfile.js/tasks/js.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | const { src, dest } = require('gulp');
4 | const config = require('../config');
5 | const uglify = require('gulp-uglify');
6 | const gulpif = require('gulp-if');
7 | const rename = require('gulp-rename');
8 | const insert = require('gulp-insert');
9 | const PluginError = require('plugin-error');
10 | const projectConfig = require('../../config');
11 | const resolveClientEnv = require('../../util/resolveClientEnv');
12 |
13 | const variablesForDev = `
14 | window.process = window.process || {};
15 | window.process.env = ${JSON.stringify(resolveClientEnv(projectConfig, true))};
16 | `
17 |
18 | function js() {
19 | return src(config.js.src)
20 | .pipe(gulpif(process.env.NODE_ENV !== 'production', insert.prepend(
21 | variablesForDev
22 | )))
23 | .pipe(gulpif(process.env.NODE_ENV === 'production', uglify({
24 | output: {
25 | ascii_only: true,
26 | },
27 | compress: {
28 | global_defs: resolveClientEnv(projectConfig),
29 | },
30 | })))
31 | .on('error', function(err) {
32 | var message = new PluginError('js', err).toString();
33 | process.stderr.write(`${message}\n`);
34 | process.exit(1);
35 | })
36 | .pipe(rename((path) => {
37 | path.basename = path.basename.replace(/\.old$/, '');
38 | }))
39 | .pipe(dest(config.js.dest))
40 | }
41 |
42 | exports.js = js;
43 |
--------------------------------------------------------------------------------
/packages/autofe-scripts/gulpfile.js/tasks/markdown.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | const { src, dest } = require('gulp');
4 | const md = require('gulp-markdown');
5 | const wrap = require('gulp-wrap');
6 | const highlight = require('highlight.js');
7 | const join = require('path').join;
8 | const config = require('../config');
9 | const gulpif = require('gulp-if');
10 | const insert = require('gulp-insert');
11 |
12 | function markdown() {
13 | return src(config.markdown.src)
14 | .pipe(md({
15 | breaks: true,
16 | highlight(code) {
17 | return highlight.highlightAuto(code).value;
18 | },
19 | }))
20 | .pipe(wrap({ src: join(__dirname, 'markdown.html') }))
21 | .pipe(gulpif(process.env.NODE_ENV !== 'production', insert.append(
22 | ''
23 | )))
24 | .pipe(dest(config.markdown.dest))
25 | }
26 |
27 | exports.markdown = markdown;
28 |
--------------------------------------------------------------------------------
/packages/autofe-scripts/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "autofe-scripts",
3 | "version": "1.3.13",
4 | "description": "Configuration and scripts for Create AutoFE App.",
5 | "repository": "athm-fe/create-autofe-app",
6 | "author": "jpuncle",
7 | "engines": {
8 | "node": ">=8"
9 | },
10 | "bugs": {
11 | "url": "https://github.com/athm-fe/create-autofe-app/issues"
12 | },
13 | "scripts": {
14 | "test": "echo \"Error: no test specified\" && exit 1"
15 | },
16 | "bin": {
17 | "autofe-scripts": "./bin/autofe-scripts.js"
18 | },
19 | "dependencies": {
20 | "@babel/core": "^7.7.7",
21 | "@vue/cli-shared-utils": "^4.1.1",
22 | "address": "^1.1.2",
23 | "autofe-serve-index": "^0.2.0",
24 | "autofe-shared-utils": "^0.1.2",
25 | "autoprefixer": "^9.7.1",
26 | "babel-loader": "^8.0.6",
27 | "babel-preset-autofe-app": "^2.1.1",
28 | "chalk": "^2.4.1",
29 | "chokidar": "^3.4.0",
30 | "copy-webpack-plugin": "^5.0.5",
31 | "cross-spawn": "^6.0.5",
32 | "css-loader": "^3.2.0",
33 | "debug": "^4.1.1",
34 | "default-gateway": "^6.0.1",
35 | "del": "^3.0.0",
36 | "dotenv": "^8.2.0",
37 | "dotenv-expand": "^5.1.0",
38 | "eslint": "^5.3.0",
39 | "eslint-loader": "^2.1.0",
40 | "express": "^4.17.1",
41 | "fancy-log": "^1.3.2",
42 | "file-loader": "^4.2.0",
43 | "fork-ts-checker-webpack-plugin": "^4.0.3",
44 | "fs-extra": "^7.0.0",
45 | "glob": "^7.1.2",
46 | "gulp": "4.0.2",
47 | "gulp-data": "^1.3.1",
48 | "gulp-if": "^2.0.2",
49 | "gulp-include": "^2.3.1",
50 | "gulp-insert": "^0.5.0",
51 | "gulp-markdown": "2.0.0",
52 | "gulp-nunjucks-render": "^2.2.2",
53 | "gulp-rename": "^1.4.0",
54 | "gulp-uglify": "^3.0.1",
55 | "gulp-wrap": "^0.14.0",
56 | "highlight.js": "9.12.0",
57 | "mini-css-extract-plugin": "^0.8.0",
58 | "optimize-css-assets-webpack-plugin": "^5.0.3",
59 | "plugin-error": "^1.0.1",
60 | "portfinder": "^1.0.26",
61 | "postcss-loader": "^3.0.0",
62 | "resolve-url-loader": "^3.1.1",
63 | "sass": "^1.24.4",
64 | "sass-loader": "^8.0.0",
65 | "style-loader": "^1.2.1",
66 | "svg-inline-loader": "^0.8.0",
67 | "svg-url-loader": "^3.0.3",
68 | "svgo": "^1.3.2",
69 | "svgo-loader": "^2.2.1",
70 | "terser-webpack-plugin": "^2.3.1",
71 | "ts-loader": "^6.2.1",
72 | "typescript": "^3.7.5",
73 | "url-loader": "^2.3.0",
74 | "webpack": "^4.16.2",
75 | "webpack-chain": "^6.4.0",
76 | "webpack-dev-server": "^3.11.0",
77 | "webpack-merge": "^4.2.2"
78 | },
79 | "devDependencies": {
80 | "@typescript-eslint/eslint-plugin": "^2.19.0",
81 | "@typescript-eslint/parser": "^2.19.0",
82 | "autofe-polyfill": "^1.2.0",
83 | "eslint-config-autofe-app": "^1.2.2",
84 | "eslint-plugin-import": "^2.13.0"
85 | },
86 | "peerDependencies": {
87 | "eslint": "^5.3.0",
88 | "typescript": "^3.7.5"
89 | }
90 | }
91 |
--------------------------------------------------------------------------------
/packages/autofe-scripts/scripts/build.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | process.env.NODE_ENV = process.env.NODE_ENV || 'production';
4 |
5 | const runner = require('./lib/runner');
6 |
7 | runner('build');
8 |
--------------------------------------------------------------------------------
/packages/autofe-scripts/scripts/eject.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
--------------------------------------------------------------------------------
/packages/autofe-scripts/scripts/lib/runner.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | const spawn = require('cross-spawn');
4 | const config = require('../../config');
5 | const loadEnv = require('../../config/env');
6 |
7 | const isProd = process.env.NODE_ENV === 'production';
8 | const mode = isProd ? 'production' : 'development';
9 |
10 | // load mode .env
11 | if (mode) {
12 | loadEnv(mode);
13 | }
14 | // load base .env
15 | loadEnv();
16 |
17 | module.exports = function runner(command) {
18 | const args = process.argv.slice(2);
19 |
20 | process.chdir(config.appDirectory);
21 |
22 | console.log('cwd:', process.cwd());
23 | console.log('argv:', args);
24 |
25 | const gulpBin = require.resolve('gulp/bin/gulp.js');
26 | const gulpFile = require.resolve('../../gulpfile.js/index.js')
27 | const gulpArgs = [
28 | `${gulpBin}`,
29 | `--cwd=${config.appDirectory}`,
30 | `--gulpfile=${gulpFile}`,
31 | command,
32 | ];
33 |
34 | spawn('node', gulpArgs, { stdio: 'inherit' });
35 | };
36 |
--------------------------------------------------------------------------------
/packages/autofe-scripts/scripts/start.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | process.env.NODE_ENV = process.env.NODE_ENV || 'development';
4 |
5 | const runner = require('./lib/runner');
6 |
7 | runner('serve');
8 |
--------------------------------------------------------------------------------
/packages/autofe-scripts/scripts/test.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
--------------------------------------------------------------------------------
/packages/autofe-scripts/template/.browserslistrc:
--------------------------------------------------------------------------------
1 | > 0.2%
2 | last 2 versions
3 | Firefox ESR
4 | not dead
5 | iOS >= 9
6 | Android >= 4.4
7 | Explorer >= 9
--------------------------------------------------------------------------------
/packages/autofe-scripts/template/.env:
--------------------------------------------------------------------------------
1 | APP_TEST_ENV_FEATURE=Hello world
2 | TEST_ENV_FEATURE=You can't see me
--------------------------------------------------------------------------------
/packages/autofe-scripts/template/.env.development:
--------------------------------------------------------------------------------
1 | APP_TEST_ENV_FEATURE=Hello world from development
--------------------------------------------------------------------------------
/packages/autofe-scripts/template/.env.production:
--------------------------------------------------------------------------------
1 | APP_TEST_ENV_FEATURE=Hello world from production
--------------------------------------------------------------------------------
/packages/autofe-scripts/template/.eslintignore:
--------------------------------------------------------------------------------
1 | build
2 | src/fixtures
3 |
--------------------------------------------------------------------------------
/packages/autofe-scripts/template/.eslintrc.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | root: true,
3 | extends: [
4 | 'eslint-config-autofe-app',
5 | 'eslint-config-autofe-app/typescript',
6 | ],
7 | globals: {
8 | AHAPP: 'readonly',
9 | },
10 | rules: {
11 | 'no-console': 'off',
12 | 'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
13 | },
14 | };
15 |
--------------------------------------------------------------------------------
/packages/autofe-scripts/template/README.md:
--------------------------------------------------------------------------------
1 | This project was bootstrapped with [Create AutoFE App](https://github.com/athm-fe/create-autofe-app).
2 |
3 | Docs are available at [https://athm-fe.github.io/create-autofe-app/](https://athm-fe.github.io/create-autofe-app/)
--------------------------------------------------------------------------------
/packages/autofe-scripts/template/babel.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | presets: [
3 | ['autofe-app', {
4 | // debug: true,
5 | // useBuiltIns: 'usage',
6 | // helpers: false,
7 | }],
8 | ],
9 | };
10 |
--------------------------------------------------------------------------------
/packages/autofe-scripts/template/creator.config.js:
--------------------------------------------------------------------------------
1 | const path = require('path');
2 |
3 | function resolve(relativePath) {
4 | return path.resolve(__dirname, relativePath);
5 | }
6 |
7 | module.exports = {
8 | externals: {
9 | jquery: 'jQuery',
10 | },
11 | configureWebpack: {
12 | resolve: {
13 | alias: {
14 | vue$: 'vue/dist/vue.esm.js',
15 | // assets: resolve('src/assets'),
16 | },
17 | },
18 | },
19 | transpileDependencies: [
20 | '@auto/img-crop',
21 | ],
22 | };
23 |
--------------------------------------------------------------------------------
/packages/autofe-scripts/template/eslintignore:
--------------------------------------------------------------------------------
1 | build
2 | **/*.old.js
--------------------------------------------------------------------------------
/packages/autofe-scripts/template/gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | *.swp
3 | Thumbs.db
4 |
5 | node_modules
6 |
7 | build
8 |
9 | # local env files
10 | .env.local
11 | .env.*.local
12 |
13 | package-lock.json
14 | yarn.lock
15 |
16 | npm-debug.log*
17 | yarn-debug.log*
18 | yarn-error.log*
19 |
--------------------------------------------------------------------------------
/packages/autofe-scripts/template/postcss.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | plugins: {
3 | autoprefixer: {},
4 | },
5 | };
6 |
--------------------------------------------------------------------------------
/packages/autofe-scripts/template/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athm-fe/create-autofe-app/787a340370d98ac16ecf1297ecb8bc699e0f0422/packages/autofe-scripts/template/public/favicon.ico
--------------------------------------------------------------------------------
/packages/autofe-scripts/template/src/assets/share.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athm-fe/create-autofe-app/787a340370d98ac16ecf1297ecb8bc699e0f0422/packages/autofe-scripts/template/src/assets/share.png
--------------------------------------------------------------------------------
/packages/autofe-scripts/template/src/component/footer/_index.html:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/packages/autofe-scripts/template/src/component/footer/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athm-fe/create-autofe-app/787a340370d98ac16ecf1297ecb8bc699e0f0422/packages/autofe-scripts/template/src/component/footer/logo.png
--------------------------------------------------------------------------------
/packages/autofe-scripts/template/src/fixtures/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Fixtures Page
6 |
7 |
8 | Hello World
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/packages/autofe-scripts/template/src/fixtures/js/README.md:
--------------------------------------------------------------------------------
1 | ## 关于 Polyfills
2 |
3 | * Async functions, Generators
4 | regenerator-runtime
5 | * Array destructuring, For Of
6 | Symbol, prototype[Symbol.iterator]
7 | * Spread
8 | Array.from
9 |
10 | 如下的一些功能需要 babel-polyfills
11 | https://stackoverflow.com/questions/32120943/babel-is-not-processing-array-from-or-for-of-loops
12 | 所以用 transform-runtime 是更好的选择
13 | https://stackoverflow.com/questions/31781756/is-there-any-practical-difference-between-using-babel-runtime-and-the-babel-poly?rq=1
14 | * Abstract References
15 | * Array destructuring
16 | * Async functions
17 | * Comprehensions
18 | * For of
19 | * Array.from
20 | * spread
21 |
22 | ## 兼容 IE8
23 |
24 | https://github.com/zuojj/fedlab/issues/5
25 | https://segmentfault.com/a/1190000005128101
26 |
27 | ### `transform-es3-member-expression-literals`
28 |
29 | Ensure that reserved words are quoted in property accesses
30 |
31 | ```javascript
32 | obj.default;
33 | ```
34 |
35 | 转换为
36 |
37 | ```javascript
38 | obj["default"];
39 | ```
40 |
41 | ### `transform-es3-property-literals`
42 |
43 | Ensure that reserved words are quoted in object property keys
44 |
45 | ```javascript
46 | var foo = {
47 | catch: function () {}
48 | };
49 | ```
50 |
51 | 转换为
52 |
53 | ```javascript
54 | var foo = {
55 | "catch": function () {}
56 | };
57 | ```
--------------------------------------------------------------------------------
/packages/autofe-scripts/template/src/fixtures/js/commonjs/counter.js:
--------------------------------------------------------------------------------
1 | let counter = 3;
2 | function incCounter() {
3 | counter += 1;
4 | }
5 | module.exports = {
6 | counter,
7 | incCounter,
8 | };
9 |
--------------------------------------------------------------------------------
/packages/autofe-scripts/template/src/fixtures/js/commonjs/index.entry.js:
--------------------------------------------------------------------------------
1 | /**
2 | * 浏览器兼容性很棒,低版本 IE 也没有问题
3 | */
4 | const modA = require('./modA');
5 | const { name, say } = require('./modB');
6 | const modC = require('./modC');
7 | const counter = require('./counter');
8 |
9 | console.log('modA.title === "modA"', modA.title === 'modA');
10 | console.log('modA.say() === "modA say..."', modA.say() === 'modA say...');
11 |
12 | console.log('name === "modB"', name === 'modB');
13 | console.log('say() === "modB say..."', say() === 'modB say...');
14 |
15 | console.log('modC.title === "modC"', modC.title === 'modC');
16 | console.log('modC.say() === "modC say..."', modC.say() === 'modC say...');
17 |
18 | console.log('counter.counter === 3', counter.counter === 3); // 3
19 | counter.incCounter();
20 | console.log('counter.counter === 3', counter.counter === 3); // 3
21 |
22 | console.log('-------- commonjs --------');
23 |
--------------------------------------------------------------------------------
/packages/autofe-scripts/template/src/fixtures/js/commonjs/modA.js:
--------------------------------------------------------------------------------
1 | exports.title = 'modA';
2 | exports.say = () => 'modA say...';
3 |
--------------------------------------------------------------------------------
/packages/autofe-scripts/template/src/fixtures/js/commonjs/modB.js:
--------------------------------------------------------------------------------
1 | exports.name = 'modB';
2 | exports.say = () => 'modB say...';
3 |
--------------------------------------------------------------------------------
/packages/autofe-scripts/template/src/fixtures/js/commonjs/modC.js:
--------------------------------------------------------------------------------
1 | const title = 'modC';
2 | const say = () => 'modC say...';
3 | module.exports = {
4 | title,
5 | say,
6 | };
7 |
--------------------------------------------------------------------------------
/packages/autofe-scripts/template/src/fixtures/js/dynamic-import/index.entry.js:
--------------------------------------------------------------------------------
1 | /**
2 | * import() 和 require.ensure()
3 | *
4 | * 不用 babel 里的 System.import
5 | *
6 | * 用法说明
7 | * 1. 需要配置好 publicPath ,依赖此路径查找 chunk
8 | * 2. 指定 chunkName 的方式不同
9 | * 3. 当指定的 chunkName 同名时,会合并为一个 chunk 输出
10 | * rank-commonjs.js --> rank-commonjs.js
11 | * rank.js + rank-test.js --> rank.js
12 | * 4. ES6 Module,需要自己 rank.default,
13 | * 因为 import() 代表 import * from './rank',
14 | * 而不是 import rank from './rank
15 | * 5. 用到了 Function.prototype.bind
16 | *
17 | * 转换说明
18 | * 1. 依赖 Promise 对象,需要引用 es6-promise 或者 babel-polyfill
19 | * 2. 直接使用 rank.default 在 IE8 有问题,需要改用 rank['default']
20 | * 有插件可以解决这个问题
21 | */
22 | import(/* webpackChunkName: "rank" */ './rank').then((rank) => {
23 | console.log(rank.name, rank.default, rank.default.length === 4);
24 | });
25 |
26 | require.ensure([], (require) => {
27 | const rank = require('./rank-commonjs');
28 | console.log('rank-commonjs', rank, rank.length === 4);
29 | }, 'rank-commonjs');
30 |
31 | require.ensure([], (require) => {
32 | const rank = require('./rank-test');
33 | console.log('rank-test', rank.list, rank.list.length === 4);
34 | }, 'rank');
35 |
--------------------------------------------------------------------------------
/packages/autofe-scripts/template/src/fixtures/js/dynamic-import/rank-commonjs.js:
--------------------------------------------------------------------------------
1 | module.exports = [
2 | 'Webpack',
3 | 'Rollup',
4 | 'Browserify',
5 | 'Others',
6 | ];
7 |
--------------------------------------------------------------------------------
/packages/autofe-scripts/template/src/fixtures/js/dynamic-import/rank-test.js:
--------------------------------------------------------------------------------
1 | exports.list = [
2 | 'Webpack',
3 | 'Rollup',
4 | 'Browserify',
5 | 'Others',
6 | ];
7 |
--------------------------------------------------------------------------------
/packages/autofe-scripts/template/src/fixtures/js/dynamic-import/rank.js:
--------------------------------------------------------------------------------
1 | export default [
2 | 'Webpack',
3 | 'Rollup',
4 | 'Browserify',
5 | 'Others',
6 | ];
7 |
8 | export const name = 'rank';
9 |
--------------------------------------------------------------------------------
/packages/autofe-scripts/template/src/fixtures/js/es2016plus/index.entry.js:
--------------------------------------------------------------------------------
1 | // 2016 features
2 | // ================
3 |
4 | // exponentiation (**) operator
5 | // 转换为 Math.pow(), 低版本浏览器也支持
6 | // basic
7 | console.log(
8 | '2 ** 3 === 8 && -(5 ** 2) === -25 && (-5) ** 2 === 25',
9 | 2 ** 3 === 8 && -(5 ** 2) === -25 && (-5) ** 2 === 25,
10 | );
11 | // assignment
12 | let a = 2;
13 | a **= 3;
14 | console.log('let a = 2; a **= 3; a === 8', a === 8);
15 |
16 | // Array.prototype.includes
17 | // Polyfills
18 |
19 | // TODO 这两个有疑问,babel 好像不支持,但是 compat-table 显示 babel 支持
20 | // nested rest destructuring, declarations
21 | // const [x, ...[y, ...z]] = [1, 2, 3, 4];
22 | // x === 1 && y === 2 && z + '' === '3,4';
23 | // nested rest destructuring, parameters
24 | // function nestRest([x, ...[y, ...z]]) {
25 | // return x === 1 && y === 2 && z + '' === '3,4';
26 | // }([1, 2, 3, 4]);
27 |
28 |
29 | // 2017 features
30 | // ================
31 |
32 | // Object APIs
33 | // Polyfills
34 | // Object.values, Object.entries
35 | // Object.getOwnPropertyDescriptors
36 |
37 | // String padding APIs
38 | // Polyfills
39 | // padStart, padEnd
40 |
41 | // trailing commas in function syntax
42 | // babel 支持,低版本 IE 支持
43 | function f(
44 | w1,
45 | w2,
46 | ) {
47 | return w1 + w2;
48 | }
49 | console.log(
50 | 'trailing commas in function syntax: in parameter lists',
51 | f(3, 5) === 8,
52 | );
53 | console.log(
54 | 'trailing commas in function syntax: in argument lists',
55 | Math.min(
56 | 1,
57 | 2,
58 | 3,
59 | ) === 1,
60 | );
61 |
62 | // async/await
63 | // 转换为 generator,依赖 regenerator-runtime 或者原生 generator
64 |
65 | console.log('-------- es2016plus --------');
66 |
--------------------------------------------------------------------------------
/packages/autofe-scripts/template/src/fixtures/js/es5-code/index.entry.js:
--------------------------------------------------------------------------------
1 | /**
2 | * 绝大多数是 IE8 不支持,IE9 基本全支持。
3 | *
4 | * API: core-js, es5-shim
5 | * 对于 Object 的 Polyfills 不完全,
6 | * 所以一些 ES6 功能即使经过 babel 转换,也需要从 IE9 开始用
7 | *
8 | * 例外情况
9 | * 1. IE8 支持 JSON
10 | * 2. IE9 不支持 Strict mode ,IE10 支持
11 | * 3. IE8 DOM 对象才支持 Object.defineProperty
12 | */
13 |
14 | // JSON
15 | // 手动额外引入以支持 IE67
16 | console.log(
17 | 'typeof JSON === "object"',
18 | typeof JSON === 'object',
19 | );
20 |
21 | // Getter accessors
22 | // Setter accessors
23 | // IE8 不支持,不要用
24 | try {
25 | console.log(
26 | 'Getter accessors',
27 | ({ get x() { return 1; } }).x === 1,
28 | );
29 | let value = 0;
30 | ({ set x(v) { value = v; } }).x = 1;
31 | console.log('Setter accessors', value === 1);
32 | } catch (e) {
33 | console.warn('Getter/Setter accessors does not support');
34 | }
35 |
36 | // Trailing commas in object literals
37 | // Trailing commas in array literals
38 | // babel 完美解决
39 | const cObj = {
40 | a: true,
41 | };
42 | console.log('Trailing commas in object literals', cObj.a === true);
43 | const cArray = [
44 | 'a',
45 | 'b',
46 | 'c',
47 | ];
48 | console.log(
49 | 'Trailing commas in array literals',
50 | cArray[2] === 'c' && cArray[3] === undefined,
51 | );
52 |
53 | // Reserved words as property names
54 | // 有两个 babel 插件可以搞定
55 | const foo = {
56 | default: x => x + 3,
57 | };
58 | console.log(
59 | 'Reserved words as property names',
60 | foo.default(3) === 6,
61 | );
62 |
63 | // Object APIs
64 | // Polyfills
65 | // es5-shim 只支持 Object.keys
66 | // core-js 也没有全支持
67 | // Object.create
68 | // Object.defineProperty, Object.defineProperties
69 | // Object.getPrototypeOf
70 | // Object.keys
71 | // Object.seal, Object.freeze, Object.preventExtensions
72 | // Object.isSealed, Object.isFrozen, Object.isExtensible
73 | // Object.getOwnPropertyDescriptor
74 | // Object.getOwnPropertyNames
75 |
76 | // Array APIs
77 | // Polyfills, es5-shim 全支持
78 | // Array.isArray
79 | // indexOf, lastIndexOf,
80 | // every, some, forEach, map, filter, reduce, reduceRight
81 | // sort: compareFn must be function or undefined
82 |
83 | // String APIs
84 | // Polyfills, es5-shim 全支持
85 | // trim
86 | // Property access on strings
87 | console.log("'foobar'[3] === 'b'", 'foobar'[3] === 'b');
88 | // IE8 支持, IE67 不确定
89 |
90 | // Date APIs
91 | // Polyfills, es5-shim 全支持
92 | // Date.now()
93 | // toISOString
94 | // toJSON
95 |
96 | // Function
97 | // Polyfills, es5-shim 全支持
98 | // bind
99 |
100 | // Function.prototype.apply permits array-likes
101 | try {
102 | (function (a, b) {
103 | console.log(
104 | 'Function.prototype.apply permits array-likes',
105 | a === 1 && b === 2,
106 | );
107 | }).apply({}, { 0: 1, 1: 2, length: 2 });
108 | } catch (e) {
109 | console.warn('Function.prototype.apply permits array-likes does not support');
110 | }
111 |
112 |
113 | // parseInt ignores leading zeros
114 | // Polyfills, es5-shim
115 | console.log(
116 | 'parseInt("010", 10) === 10',
117 | parseInt('010', 10) === 10,
118 | );
119 |
120 | // Immutable globals
121 | // undefined, NaN, Infinity
122 | // IE8 不支持,不过也没有什么影响,这里不测了
123 | // undefined = 12345;
124 | // console.log(
125 | // 'undefined is Immutable',
126 | // typeof undefined === 'undefined',
127 | // );
128 | // NaN = false;
129 | // console.log(
130 | // 'NaN is Immutable',
131 | // typeof NaN === 'number',
132 | // );
133 | // Infinity = 12345;
134 | // console.log(
135 | // 'Infinity is Immutable',
136 | // typeof Infinity === 'number',
137 | // );
138 |
139 | // Strict mode
140 | // IE10 才支持,不过不支持也没关系,不用管它
141 | // 因为 babel 和 eslint 已经把相关问题搞定了
142 |
143 | console.log('-------- es5-code --------');
144 |
--------------------------------------------------------------------------------
/packages/autofe-scripts/template/src/fixtures/js/es6-code/arrow-function.js:
--------------------------------------------------------------------------------
1 | /**
2 | * 放心用,低版本 IE 也没有问题
3 | */
4 |
5 | function equal(arr1, arr2) {
6 | const length = arr1.length;
7 | if (length !== arr2.length) {
8 | return false;
9 | }
10 | for (let i = 0; i < length; i += 1) {
11 | if (arr1[i] !== arr2[i]) {
12 | return false;
13 | }
14 | }
15 | return true;
16 | }
17 |
18 | // Expression bodies
19 | const array = [1, 2, 3].map(value => value + 10);
20 | console.log('array[0] === 11', array[0] === 11);
21 | console.log('array[1] === 12', array[1] === 12);
22 | console.log('array[2] === 13', array[2] === 13);
23 |
24 | // Lexical this
25 | const bob = {
26 | name: 'Bob',
27 | friends: ['John', 'Jack', 'Tom', 'Lily'],
28 | printFriends() {
29 | const temp = [];
30 | this.friends.forEach((f) => {
31 | console.log('Lexical this', this === bob);
32 | temp.push(f);
33 | });
34 | console.log('Lexical this', equal(temp, bob.friends));
35 | },
36 | };
37 | bob.printFriends();
38 |
39 | // Lexical arguments
40 | function square() {
41 | const example = () => {
42 | const numbers = [];
43 | const args = Array.prototype.slice.call(arguments, 0);
44 | // Statement bodies
45 | args.forEach((number) => {
46 | numbers.push(number * number);
47 | });
48 |
49 | return numbers;
50 | };
51 |
52 | return example();
53 | }
54 |
55 | console.log(
56 | 'square(2, 4, 7.5, 8, 11.5, 21) equal to [4, 16, 56.25, 64, 132.25, 441]',
57 | equal(square(2, 4, 7.5, 8, 11.5, 21), [4, 16, 56.25, 64, 132.25, 441]),
58 | );
59 | // returns: [4, 16, 56.25, 64, 132.25, 441];
60 |
61 | console.log('-------- arrow function --------');
62 |
--------------------------------------------------------------------------------
/packages/autofe-scripts/template/src/fixtures/js/es6-code/binary-octal.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Binary and Octal Literals 二进制和八进制
3 | * Babel 转换不了 Number('0o1')
4 | */
5 | console.log('0b111110111 === 503', 0b111110111 === 503);
6 | console.log('0o767 === 503', 0o767 === 503);
7 | console.log('Number("0o1") === 1', Number('0o1') === 1);
8 | console.log('Number("0b1") === 1', Number('0b1') === 1);
9 |
10 | // Outputs:
11 | // console.log('0b111110111 === 503', 503 === 503);
12 | // console.log('0o767 === 503', 503 === 503);
13 | // console.log('Number("0o1") === 1', Number('0o1') === 1);
14 | // console.log('Number("0b1") === 1', Number('0b1') === 1);
15 |
16 | console.log('-------- binary, octal --------');
17 |
--------------------------------------------------------------------------------
/packages/autofe-scripts/template/src/fixtures/js/es6-code/class.js:
--------------------------------------------------------------------------------
1 | /**
2 | * http://babeljs.io/docs/usage/caveats/#internet-explorer-classes-10-and-below-
3 | *
4 | */
5 |
6 | class Point {
7 | constructor(x, y) {
8 | this.x = x;
9 | this.y = y;
10 | this.name = 'point';
11 | }
12 | toString() {
13 | return `(${this.x},${this.y})`;
14 | }
15 | static defaultX = 100
16 | }
17 | Point.defaultY = 200;
18 |
19 | class ColorPoint extends Point {
20 | constructor(x, y, color) {
21 | super(x, y);
22 |
23 | this.color = color;
24 | }
25 | toString() {
26 | return `${this.color} ${super.toString()}`;
27 | }
28 | instanceProperty = 'test';
29 | boundFunction = () => this.instanceProperty;
30 | boundFunction2() {
31 | return this.instanceProperty;
32 | }
33 | static randomColor() {
34 | console.log('super static', super.defaultX === 100);
35 | return '#F60';
36 | }
37 | }
38 |
39 | const cp = new ColorPoint(100, 100, 'red');
40 | console.log('cp.x === 100', cp.x === 100);
41 | console.log('cp.y === 100', cp.y === 100);
42 | console.log("cp.name === 'point'", cp.name === 'point');
43 | console.log('cp.color === "red"', cp.color === 'red');
44 | console.log(
45 | 'cp.boundFunction.call(undefined) === "test"',
46 | cp.boundFunction.call(undefined) === 'test',
47 | );
48 | console.log('ColorPoint.randomColor() === "#F60"',
49 | ColorPoint.randomColor() === '#F60');
50 |
51 | class Foo extends Array {}
52 |
53 | console.log('-------- class --------');
54 |
--------------------------------------------------------------------------------
/packages/autofe-scripts/template/src/fixtures/js/es6-code/default-rest-spread.js:
--------------------------------------------------------------------------------
1 | /**
2 | * 如下的代码大多数没有兼容性问题
3 | *
4 | * 有问题的用法
5 | * 1. string spread
6 | * Array.isArray(), Array.from()
7 | */
8 |
9 | // default parameter values
10 | function foo(x, y = 12) {
11 | // y is 12 if not passed (or passed as undefined)
12 | return x + y;
13 | }
14 | console.log('foo(3) === 15', foo(3) === 15);
15 |
16 | // rest
17 | function bar(x, ...y) {
18 | // y is an Array
19 | return x * y.length;
20 | }
21 | console.log('bar(3, "hello", true) === 6', bar(3, 'hello', true) === 6);
22 |
23 | function bar2(x, ...y) {
24 | // y is an Array
25 | return y;
26 | }
27 | console.log('bar2(3, "hello", true)[0] === "hello"', bar2(3, 'hello', true)[0] === 'hello');
28 | console.log('bar2(3, "hello", true)[1] === true', bar2(3, 'hello', true)[1] === true);
29 |
30 | // rest destructuring, declarations
31 | const [x, ...y] = [1, 2, 3, 4];
32 | console.log('const [x, ...y] = [1, 2, 3, 4]', x === 1 && y[2] === 4);
33 |
34 | // spread
35 | function too(s, t, u, v = 10) {
36 | return s + t + u + v;
37 | }
38 | // Pass each elem of array as argument
39 | console.log('too(1, ...[2, 3], 20) === 26', too(1, ...[2, 3], 20) === 26);
40 |
41 | // string spread
42 | // 依赖 Array.isArray(), Array.from()
43 | console.log(
44 | '["a", ..."bcd", "e"][3] === "d"',
45 | ['a', ...'bcd', 'e'][3] === 'd',
46 | );
47 |
48 | console.log('-------- default, rest, spread --------');
49 |
--------------------------------------------------------------------------------
/packages/autofe-scripts/template/src/fixtures/js/es6-code/destructuring.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Destructuring 解构
3 | *
4 | * 当前的代码都没有兼容性问题
5 | *
6 | * string matching 依赖 Iterator
7 | */
8 |
9 | // array matching
10 | const [a, , b] = [1, 2, 3];
11 | console.log('a === 1', a === 1);
12 | console.log('b === 3', b === 3);
13 |
14 | // string matching
15 | try {
16 | const [s1, , , , s5] = 'hello';
17 | console.log('s1 === "h"', s1 === 'h');
18 | console.log('s5 === "o"', s5 === 'o');
19 | } catch (e) {
20 | console.warn('string destructuring does not support');
21 | }
22 |
23 | // object matching
24 | const { name: c, age: d } = { name: 'Tom', age: 30, weight: 70 };
25 | console.log('c === "Tom"', c === 'Tom');
26 | console.log('d === 30', d === 30);
27 |
28 | const { ...x } = { name: 'Tom', age: 30, weight: 70 };
29 | console.log('x', x);
30 |
31 | // object matching shorthand
32 | const { name, age } = { name: 'Tom', age: 30, weight: 70 };
33 | console.log('name === "Tom"', name === 'Tom');
34 | console.log('age === 30', age === 30);
35 |
36 | // Can be used in parameter position
37 | function g({ name: x = 10 }) {
38 | return x;
39 | }
40 | console.log('g({ name: 5 }) === 5', g({ name: 5 }) === 5);
41 | console.log('g({}) === 10', g({}) === 10);
42 |
43 | // Fail-soft destructuring
44 | const [soft] = [];
45 | console.log('soft === undefined', soft === undefined);
46 |
47 | // Fail-soft destructuring with defaults
48 | const [softDefault = 1] = [];
49 | console.log('softDefault === 1', softDefault === 1);
50 |
51 | // Destructuring + defaults arguments
52 | function r({ x, y, w = 10, h = 10 }) {
53 | return x + y + w + h;
54 | }
55 | console.log('r({ x: 1, y: 2 }) === 23', r({ x: 1, y: 2 }) === 23);
56 |
57 | console.log('-------- destructuring --------');
58 |
--------------------------------------------------------------------------------
/packages/autofe-scripts/template/src/fixtures/js/es6-code/enhanced-object.js:
--------------------------------------------------------------------------------
1 | /**
2 | * 可以放心使用的也就是 Shorthand
3 | *
4 | * super.xxx() 以及 Computed (dynamic) property names
5 | * 会导致不支持 IE8
6 | *
7 | * 开启对应插件的 loose 模式,支持 Computed (dynamic) property names
8 | *
9 | * __proto__ in obj 不被 babel 支持,需要浏览器原生,不过这里有取巧,不支持也OK
10 | *
11 | * 依赖
12 | * Object.getOwnPropertyDescriptor()
13 | */
14 |
15 | const bar = 'bar';
16 | const foo = 'foo';
17 |
18 | const theProtoObj = {
19 | toString() {
20 | return 'theProtoObj.toString()';
21 | },
22 | };
23 |
24 | // const theProtoObj2 = {
25 | // toString() {
26 | // return 'theProtoObj2.toString()';
27 | // },
28 | // };
29 |
30 | const enhancedObj = {
31 | // Sets the prototype.
32 | __proto__: theProtoObj,
33 | // Computed property name does not set prototype or trigger early error for
34 | // duplicate __proto__ properties.
35 | // 下面这种方式是不行的,chrome 下 super.toString() 会报错
36 | // ['__proto__']: theProtoObj2,
37 | // Methods
38 | say() {
39 | return 'hello world';
40 | },
41 | // reserved words
42 | default: 3,
43 | // Shorthand
44 | bar,
45 | toString() {
46 | return `enhancedObj.toString() ---- ${super.toString()}`;
47 | },
48 | [foo]: foo,
49 | // Super calls,会使用类似 class 里的 _get() 方法,不支持 IE8
50 | // Computed (dynamic) property names
51 | // 导致使用 defineProperty
52 | [`prop_${(() => 42)()}`]: 42,
53 | };
54 | console.log('enhancedObj.say():', enhancedObj.say() === 'hello world');
55 | console.log('enhancedObj.default', enhancedObj.default === 3);
56 | console.log('enhancedObj.bar:', enhancedObj.bar === 'bar');
57 | console.log(
58 | 'enhancedObj.toString():',
59 | enhancedObj.toString() === 'enhancedObj.toString() ---- theProtoObj.toString()',
60 | );
61 | console.log('enhancedObj.foo:', enhancedObj.foo === 'foo');
62 | console.log('enhancedObj.prop_42L', enhancedObj.prop_42 === 42);
63 |
64 | console.log('-------- enhanced object --------');
65 |
--------------------------------------------------------------------------------
/packages/autofe-scripts/template/src/fixtures/js/es6-code/for-of.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Iterators 需要 babel polyfill 支持
3 | *
4 | * 可以使用 ESLint 禁用 iterators,禁止 for-in 和 for-of
5 | * ESLint: no-iterator no-restricted-syntax
6 | *
7 | * Use map() / every() / filter() / find() / findIndex() /
8 | * reduce() / some() / ... to iterate over arrays,
9 | * and Object.keys() / Object.values() / Object.entries()
10 | * to produce arrays so you can iterate over objects.
11 | *
12 | * 依赖 Symbol 和 Iterator
13 | * for...of是坑,转换后的代码太难看,而且有兼容性问题
14 | *
15 | * Iterator 还好,如果是针对 Generator 的 Iterator 暂时不要用,
16 | * 因为 Generator 太重了
17 | *
18 | * 对于数组的转换进行了优化
19 | */
20 | let sum = 0;
21 | for (const item of [1, 2, 3]) {
22 | sum += item;
23 | }
24 | console.log('sum === 6 after for...of', sum === 6);
25 | // Outputs:
26 | // var _arr = [1, 2, 3];
27 | // for (var _i = 0; _i < _arr.length; _i++) {
28 | // var item = _arr[_i];
29 | // console.log(item);
30 | // }
31 |
32 | function from(a1, a2, a3) {
33 | return [a1 * 2, a2 * 2, a3 * 2];
34 | }
35 |
36 | try {
37 | sum = 0;
38 | for (const item of from(1, 2, 3)) {
39 | sum += item;
40 | }
41 | console.log('sum === 12 after for...of', sum === 12);
42 | } catch (e) {
43 | console.warn('for-of iterator does not support');
44 | }
45 |
46 | try {
47 | const array = [];
48 | for (const item of '123') {
49 | array.push(item);
50 | }
51 | console.log('string for-of', array.length === 3 && array[2] === '3');
52 | } catch (e) {
53 | console.warn('for-of iterator does not support');
54 | }
55 |
56 | try {
57 | const obj = { a: 1, b: 2 };
58 | for (const item of obj) {
59 | console.log(item);
60 | }
61 | } catch (e) {
62 | console.warn('for-of iterator does not support');
63 | }
64 |
65 |
66 | console.log('-------- for...of --------');
67 |
--------------------------------------------------------------------------------
/packages/autofe-scripts/template/src/fixtures/js/es6-code/generators.js:
--------------------------------------------------------------------------------
1 | /**
2 | * TODO 需要 regenerator-runtime
3 | * babel polyfill 可以提供支持
4 | */
5 |
6 | function* helloWorldGenerator() {
7 | yield 'hello';
8 | yield 'world';
9 | }
10 |
11 | const hw = helloWorldGenerator();
12 |
13 | let result = hw.next();
14 | console.log(result.value === 'hello' && result.done === false);
15 | result = hw.next();
16 | console.log(result.value === 'world' && result.done === false);
17 | result = hw.next();
18 | console.log(result.value === undefined && result.done === true);
19 |
20 |
21 | function timeout(ms) {
22 | return new Promise((resolve) => {
23 | setTimeout(resolve, ms);
24 | });
25 | }
26 | async function asyncPrint(value, ms) {
27 | await timeout(ms);
28 | console.log(value);
29 | }
30 | asyncPrint('hello world', 50);
31 |
32 | async function* agf() {
33 | await 1;
34 | yield 2;
35 | }
36 |
37 | console.log('-------- generators --------');
38 |
--------------------------------------------------------------------------------
/packages/autofe-scripts/template/src/fixtures/js/es6-code/index.entry.js:
--------------------------------------------------------------------------------
1 | require('./let-const');
2 | require('./template-string');
3 | require('./arrow-function');
4 | require('./named-function-expression');
5 | require('./class');
6 | require('./enhanced-object');
7 | require('./destructuring');
8 | require('./default-rest-spread');
9 | require('./for-of');
10 | require('./generators');
11 | require('./unicode');
12 | // require('./regexp');
13 | require('./binary-octal');
14 | require('./parameters');
15 |
16 |
17 | // Symbols
18 | // babel polyfill 可以提供大多数支持,有一些功能不支持
19 |
20 |
21 | // Map + Set + WeakMap + WeakSet
22 | // babel polyfill 可以提供全面的支持
23 |
24 |
25 | // Math + Number + String + Object APIs + RegExp + Array + Date
26 | // babel polyfill 可以支持大多数
27 | // Object.setPrototypeOf 需要原生 __proto__ 支持
28 | // String.prototype.normalize 需要额外支持
29 | // https://github.com/addyosmani/es6-tools#polyfills
30 |
31 |
32 | // Promise
33 | // babel polyfill 提供全面支持
34 |
35 |
36 | // Generator and Async/await
37 | // 太重,不适合用,Promise 先凑合吧
38 |
39 |
40 | // Decorator
41 | // 待定
42 |
43 |
44 | // Reflect
45 | // babel polyfill 提供大多数支持
46 |
47 |
48 | // Proxies
49 | // Due to the limitations of ES5,
50 | // Proxies cannot be transpiled or polyfilled
51 |
52 |
53 | // Subclassable Built-ins
54 | // transform-es2015-classes/
55 | // 不要用,Babel 支持不了
56 | // babel-plugin-transform-builtin-extend
57 | // 依赖 Object.setPrototypeOf 和 Reflect.construct
58 | // 兼容性有限
59 |
60 |
61 | // ArrayBuffer, typed arrays
62 | // 待定
63 |
--------------------------------------------------------------------------------
/packages/autofe-scripts/template/src/fixtures/js/es6-code/let-const.js:
--------------------------------------------------------------------------------
1 | /* eslint-disable */
2 | /**
3 | * 都没有兼容性问题
4 | *
5 | * 就是还不支持 Temporal Dead Zone
6 | */
7 |
8 | // let 和 const 不允许重复定义
9 | // const 不允许修改变量值
10 | // 否则,webpack + babel 打包时报错
11 | function test() {
12 | {
13 | let x;
14 | {
15 | // this is ok since it's a block scoped name
16 | const x = "sneaky";
17 |
18 | // // error, was just defined with `const` above
19 | // x = "foo";
20 | }
21 | // this is ok since it was declared with `let`
22 | x = "bar";
23 |
24 | // // error, already declared above in this block
25 | // let x = "inner";
26 | }
27 | }
28 | test();
29 |
30 | // 变量提升
31 | // --------------------
32 |
33 | console.log('var foo === undefined', foo === undefined); // 输出 undefined
34 | var foo = 2;
35 |
36 | // Temporal Dead Zone
37 | try {
38 | bar = 3; // 应当报错 ReferenceError
39 | console.warn('Temporal Dead Zone', false);
40 | let bar = 2;
41 | } catch (e) {
42 | console.log('Temporal Dead Zone', true);
43 | }
44 |
45 | // 块级作用域
46 | // --------------------
47 |
48 | {
49 | let a = 10;
50 | const b = 20;
51 | var c = 100;
52 | a += b;
53 | console.log('a === 30', a === 30);
54 | }
55 | try {
56 | console.log('a:', a);
57 | } catch (e) {
58 | console.log('a is not defined', e instanceof ReferenceError);
59 | }
60 | console.log('c === 100', c === 100);
61 |
62 | var scopeArray = [];
63 | for (var i = 0; i < 10; i++) {
64 | scopeArray[i] = () => i;
65 | }
66 | console.log('scopeArray[6]() === 10', scopeArray[6]() === 10);
67 |
68 | var scopeArray2 = [];
69 | for (let i = 0; i < 10; i++) {
70 | scopeArray2[i] = () => i;
71 | }
72 | console.log('scopeArray2[6]() === 6', scopeArray2[6]() === 6);
73 |
74 | console.log('-------- let & const --------');
75 |
--------------------------------------------------------------------------------
/packages/autofe-scripts/template/src/fixtures/js/es6-code/named-function-expression.js:
--------------------------------------------------------------------------------
1 | /* eslint no-undef: "off" */
2 |
3 | console.log(
4 | "typeof g === 'undefined'",
5 | typeof g === 'undefined',
6 | );
7 | const f = function g() {};
8 | console.log(
9 | "typeof g === 'undefined'",
10 | typeof g === 'undefined',
11 | );
12 | try {
13 | console.log('f === g', f === g);
14 | } catch (e) {
15 | console.log('f === g cause the error', true);
16 | }
17 |
18 | console.log('-------- named function expression --------');
19 |
--------------------------------------------------------------------------------
/packages/autofe-scripts/template/src/fixtures/js/es6-code/parameters.js:
--------------------------------------------------------------------------------
1 | /* eslint-disable */
2 |
3 | function test(x = "hello", { a, b }, ...args) {
4 | console.log(x, a, b, args);
5 | }
6 |
7 | console.log('-------- parameters --------');
8 |
--------------------------------------------------------------------------------
/packages/autofe-scripts/template/src/fixtures/js/es6-code/regexp.js:
--------------------------------------------------------------------------------
1 | /**
2 | * y 和 u
3 | * babel 支持 u ,不支持 y
4 | */
5 |
6 | const s = 'aaa_aa_a';
7 | const r1 = /a+/g;
8 | const r2 = /a+/y;
9 |
10 | console.log(r1.exec(s)[0] === 'aaa');
11 | console.log(r2.exec(s)[0] === 'aaa');
12 |
13 | console.log(r1.exec(s)[0] === 'aa');
14 | console.log(r2.exec(s) === null);
15 |
16 | console.log('-------- regexp --------');
17 |
--------------------------------------------------------------------------------
/packages/autofe-scripts/template/src/fixtures/js/es6-code/template-string.js:
--------------------------------------------------------------------------------
1 | /**
2 | * 放心用,兼容低版本 IE
3 | *
4 | * String.raw 会导致兼容性问题
5 | * tagged template strings 会使用 Object.freeze 和 Object.defineProperties
6 | */
7 |
8 | const name = 'ES5';
9 | const templateStr = `In ${name} this is
10 | not legal.`;
11 | console.log('templateStr === "In ES5 this is\n not legal."',
12 | templateStr === 'In ES5 this is\n not legal.');
13 |
14 | // Don't use tagged template strings
15 | function echo(str) {
16 | return str;
17 | }
18 | console.log(
19 | 'echo`name`[0] === "name"',
20 | echo`name ${1}`[0] === 'name',
21 | );
22 |
23 | // Unescaped template strings
24 | // String.raw`In ES5 "\n" is a line-feed.`;
25 |
26 | console.log('-------- template string --------');
27 |
--------------------------------------------------------------------------------
/packages/autofe-scripts/template/src/fixtures/js/es6-code/unicode.js:
--------------------------------------------------------------------------------
1 | /**
2 | * 可以放心用
3 | */
4 |
5 | // same as ES5.1
6 | console.log('"𠮷".length === 2', '𠮷'.length === 2);
7 |
8 | // new RegExp behaviour, opt-in ‘u’
9 | console.log(
10 | '"𠮷".match(/./u)[0].length === 2',
11 | '𠮷'.match(/./u)[0].length === 2,
12 | );
13 |
14 | // new form
15 | console.log(
16 | '"\\u{20BB7}" === "𠮷" === "\\uD842\\uDFB7"',
17 | '\u{20BB7}' === '𠮷' && '𠮷' === '\uD842\uDFB7',
18 | );
19 |
20 | if (String.prototype.codePointAt) {
21 | // new String ops
22 | console.log(
23 | '"𠮷".codePointAt(0) === 0x20BB7',
24 | '𠮷'.codePointAt(0) === 0x20BB7,
25 | );
26 | } else {
27 | console.warn('String.prototype.codePointAt does not support');
28 | }
29 |
30 | // u for RegExp
31 | console.log(
32 | '/^\\uD83D/u.test("\\uD83D\\uDC2A") === false',
33 | /^\uD83D/u.test('\uD83D\uDC2A') === false,
34 | );
35 | console.log(
36 | '/^\\uD83D/.test("\\uD83D\\uDC2A") === true',
37 | /^\uD83D/.test('\uD83D\uDC2A') === true,
38 | );
39 |
40 | console.log(
41 | '/^.$/.test("𠮷") === false',
42 | /^.$/.test('𠮷') === false,
43 | );
44 | console.log(
45 | '/^.$/u.test("𠮷") === true',
46 | /^.$/u.test('𠮷') === true,
47 | );
48 |
49 | console.log('-------- unicode --------');
50 |
--------------------------------------------------------------------------------
/packages/autofe-scripts/template/src/fixtures/js/es6-modules/counter.js:
--------------------------------------------------------------------------------
1 | /* eslint import/no-mutable-exports: "off" */
2 |
3 | /**
4 | * CommonJS 模块输出的是一个值的拷贝,ES6 模块输出的是值的引用。
5 | */
6 | export let counter = 3;
7 | export function incCounter() {
8 | counter += 1;
9 | }
10 |
--------------------------------------------------------------------------------
/packages/autofe-scripts/template/src/fixtures/js/es6-modules/index.entry.js:
--------------------------------------------------------------------------------
1 | /**
2 | * 依赖 Object.defineProperty ,所以不支持 IE8
3 | *
4 | * Tree sharking
5 | *
6 | * http://babeljs.io/docs/usage/caveats/#internet-explorer-getters-setters-8-and-below-
7 | */
8 | import modA, { name, child } from './modA';
9 | import * as math from './math';
10 | import { counter, incCounter as addCounter } from './counter';
11 |
12 | console.log('modA() === "modA"', modA() === 'modA');
13 | console.log('name === "modA"', name === 'modA');
14 | console.log('child === "modB"', child === 'modB');
15 |
16 | console.log('math.sum(3, 5) === 8', math.sum(3, 5) === 8);
17 | console.log('math.pi === 3.141593', math.pi === 3.141593);
18 |
19 | console.log('counter === 3', counter === 3); // 3
20 | addCounter();
21 | console.log('counter === 4', counter === 4); // 4
22 |
23 | console.log('-------- es6-modules --------');
24 |
--------------------------------------------------------------------------------
/packages/autofe-scripts/template/src/fixtures/js/es6-modules/math.js:
--------------------------------------------------------------------------------
1 | export function sum(x, y) {
2 | return x + y;
3 | }
4 | export const pi = 3.141593;
5 |
--------------------------------------------------------------------------------
/packages/autofe-scripts/template/src/fixtures/js/es6-modules/modA.js:
--------------------------------------------------------------------------------
1 | const modB = require('./modB');
2 |
3 | export default function modA() {
4 | return 'modA';
5 | }
6 |
7 | export const name = 'modA';
8 | export const desc = `This is ${name}.`;
9 | export const child = modB;
10 |
--------------------------------------------------------------------------------
/packages/autofe-scripts/template/src/fixtures/js/es6-modules/modB.js:
--------------------------------------------------------------------------------
1 | module.exports = 'modB';
2 |
--------------------------------------------------------------------------------
/packages/autofe-scripts/template/src/fixtures/js/main.entry.js:
--------------------------------------------------------------------------------
1 | import 'autofe-polyfill';
2 |
--------------------------------------------------------------------------------
/packages/autofe-scripts/template/src/fixtures/js/stage/index.entry.js:
--------------------------------------------------------------------------------
1 | // stage 3
2 | // ================
3 |
4 | /**
5 | * object rest
6 | * object spread
7 | *
8 | * 依赖
9 | * Object.assign
10 | * _objectWithoutProperties, Array.prototype.indexOf
11 | */
12 | // object rest
13 | const { a, ...rest } = { a: 1, b: 2, c: 3 };
14 | console.log(
15 | 'object rest',
16 | a === 1 && rest.a === undefined && rest.b === 2 && rest.c === 3,
17 | );
18 |
19 | // object spread
20 | const spread = { b: 2, c: 3 };
21 | const spreadResult = { a: 1, ...spread };
22 | console.log(
23 | 'object spread',
24 | spreadResult !== spread && (spreadResult.a + spreadResult.b + spreadResult.c) === 6,
25 | );
26 |
27 | // async generator functions
28 | // for-await-of
29 | // babel 支持
30 |
31 |
32 | // stage 2
33 | // ================
34 |
35 | // String trimming APIs
36 | // trimLeft, trimRight, trimStart, trimEnd
37 | // Polyfills
38 |
39 | // class properties
40 | // babel 插件支持
41 | class C {
42 | x = 'x';
43 | static y = 'y';
44 | }
45 | console.log(
46 | "new C().x + C.y === 'xy'",
47 | new C().x + C.y === 'xy',
48 | );
49 |
50 |
51 | // stage 1
52 | // ================
53 |
54 | // String.prototype.matchAll
55 | // Babel polyfill
56 |
57 | // do expressions
58 | // Babel 插件
59 |
60 | // Observable
61 | // 待定
62 |
63 | // decorators
64 | // 待定
65 |
66 | // export-extensions
67 | // 待定
68 |
69 |
70 | // stage 0
71 | // ================
72 |
73 | // bind (::) operator
74 |
75 | // String.prototype.at
76 |
77 | // asap
78 |
79 |
80 | const obj = {
81 | foo: {
82 | bar: {
83 | baz: 42,
84 | },
85 | },
86 | };
87 |
88 | const baz = obj?.foo?.bar?.baz; // 42
89 |
90 | const safe = obj?.qux?.baz; // undefined
91 |
92 | console.log('obj?.foo?.bar?.baz', baz);
93 | console.log('obj?.qux?.baz', safe);
94 |
95 | console.log('-------- stage --------');
96 |
--------------------------------------------------------------------------------
/packages/autofe-scripts/template/src/index/README.md:
--------------------------------------------------------------------------------
1 | # demo 说明
2 |
3 | > 这个是引言
4 |
5 | 这个 demo 啥都**没有**,哈哈
6 |
7 | List
8 | * sass
9 | * markdown
10 | * nunjucks
11 |
12 | 一段 JS 代码
13 | ```javascript
14 | var test = function (msg) {
15 | console.log('You say:', msg);
16 | };
17 |
18 | test();
19 | ```
--------------------------------------------------------------------------------
/packages/autofe-scripts/template/src/index/_part1.html:
--------------------------------------------------------------------------------
1 | Tech
2 |
3 | - 背景灰色
4 | - React
5 | - Webpack
6 | - Babel
7 | - ES6
8 |
--------------------------------------------------------------------------------
/packages/autofe-scripts/template/src/index/_part2.html:
--------------------------------------------------------------------------------
1 | Editor
2 |
3 | - 背景橙色
4 | - Atom
5 | - Sublime Text
6 | - WebStorm
7 | - VS
8 |
--------------------------------------------------------------------------------
/packages/autofe-scripts/template/src/index/css/_attr.scss:
--------------------------------------------------------------------------------
1 | a {
2 | color: blue;
3 | }
4 |
5 | /* Internal links, beginning with "#" */
6 | a[href^="#"] {
7 | background-color: gold;
8 | }
9 |
10 | /* Links with "example" anywhere in the URL */
11 | a[href*="example"] {
12 | background-color: silver;
13 | }
14 |
15 | /* Links with "insensitive" anywhere in the URL,
16 | regardless of capitalization */
17 | a[href*="insensitive" i] {
18 | color: cyan;
19 | }
20 |
21 | /* Links with "cAsE" anywhere in the URL,
22 | with matching capitalization */
23 | // node-sass 暂时不支持如下方式
24 | // a[href*="cAsE" s] {
25 | // color: pink;
26 | // }
27 |
28 | /* Links that end in ".org" */
29 | a[href$=".org"] {
30 | color: red;
31 | }
--------------------------------------------------------------------------------
/packages/autofe-scripts/template/src/index/css/_base.scss:
--------------------------------------------------------------------------------
1 | html {
2 | background: url("../img/bg.png");
3 | }
4 |
5 | h1, h2 {
6 | padding: 0.5em 0;
7 | border-bottom: 2px solid #f60;
8 | }
9 |
10 | .cursor-hand {
11 | width: 200px;
12 | height: 200px;
13 | background-color: #333;
14 | cursor: url("../img/cursor-hand.cur"), auto;
15 | }
--------------------------------------------------------------------------------
/packages/autofe-scripts/template/src/index/css/_part1.scss:
--------------------------------------------------------------------------------
1 | .part1 {
2 | background: gray;
3 | }
--------------------------------------------------------------------------------
/packages/autofe-scripts/template/src/index/css/_part2.scss:
--------------------------------------------------------------------------------
1 | .part2 {
2 | background: orange;
3 | }
--------------------------------------------------------------------------------
/packages/autofe-scripts/template/src/index/css/_reset.scss:
--------------------------------------------------------------------------------
1 | body, ul, li {
2 | margin: 0;
3 | padding: 0;
4 | }
--------------------------------------------------------------------------------
/packages/autofe-scripts/template/src/index/css/_test-ascii.scss:
--------------------------------------------------------------------------------
1 | .test-ascii {
2 | content: '\e091';
3 | }
--------------------------------------------------------------------------------
/packages/autofe-scripts/template/src/index/css/_test-autoprefixer.scss:
--------------------------------------------------------------------------------
1 | :fullscreen a {
2 | display: flex
3 | }
4 |
5 | .btn {
6 | -webkit-border-radius: 10px;
7 | border-radius: 10px;
8 | }
9 |
10 | .btn .icon1 {
11 | transform: scale(0.5);
12 | }
13 |
14 | .btn .icon2 {
15 | -webkit-transform: scale(0.5);
16 | transform: scale(0.5);
17 | }
18 |
19 | .btn .icon3 {
20 | -webkit-transform: scale(0.6);
21 | transform: scale(0.5);
22 | }
23 |
24 | .btn .icon4 {
25 | transform: scale(0.5);
26 | -webkit-transform: scale(0.6);
27 | }
--------------------------------------------------------------------------------
/packages/autofe-scripts/template/src/index/css/_test-color.scss:
--------------------------------------------------------------------------------
1 | .test-color {
2 | width: 200px;
3 | height: 200px;
4 | // background-color: #ff6633 - #000001;
5 | background-color: adjust-color(#ff6633, $blue: -1);
6 | }
--------------------------------------------------------------------------------
/packages/autofe-scripts/template/src/index/css/_test-iehack.scss:
--------------------------------------------------------------------------------
1 | .btn {
2 | _background: none;
3 | }
4 |
5 | a {
6 | font-size: 2em\9;
7 | }
--------------------------------------------------------------------------------
/packages/autofe-scripts/template/src/index/css/_test-null.scss:
--------------------------------------------------------------------------------
1 | @keyframes slideout-null {
2 | 0% { opacity: 1;}
3 | 100% { opacity: 1;}
4 | }
5 |
6 | .null {
7 | animation: slideout-null 10ms;
8 | }
--------------------------------------------------------------------------------
/packages/autofe-scripts/template/src/index/css/_test-postcss-assets.scss:
--------------------------------------------------------------------------------
1 | .assets-svg {
2 | width: 400px;
3 | height: 72px;
4 | background: url("../img/postcss-assets.svg?datauri");
5 | }
6 | .assets-svg-normal {
7 | width: 400px;
8 | height: 72px;
9 | background: url("../img/postcss-assets.svg");
10 | }
11 | .assets-png {
12 | width: 200px;
13 | height: 57px;
14 | background: url("../img/postcss-assets.png?datauri");
15 | }
16 | .assets-png-normal {
17 | width: 200px;
18 | height: 57px;
19 | background: url("../img/postcss-assets.png");
20 | }
21 | .assets-jpg {
22 | width: 190px;
23 | height: 190px;
24 | background: url("../img/postcss-assets.jpg?datauri");
25 | }
26 | .assets-jpg-normal {
27 | width: 190px;
28 | height: 190px;
29 | background: url("../img/postcss-assets.jpg");
30 | }
--------------------------------------------------------------------------------
/packages/autofe-scripts/template/src/index/css/_test-root-alias.scss:
--------------------------------------------------------------------------------
1 | .test-root-alias {
2 | width: 320px;
3 | height: 240px;
4 | // working
5 | background: url("~@/index/img/car.jpg") no-repeat;
6 | // not working
7 | // background: url("@/index/img/car.jpg") no-repeat;
8 | }
--------------------------------------------------------------------------------
/packages/autofe-scripts/template/src/index/css/main.scss:
--------------------------------------------------------------------------------
1 | @import "reset";
2 | @import "base";
3 | @import "part1";
4 | @import "part2";
5 | @import "test-postcss-assets";
6 | @import "test-autoprefixer";
7 | @import "test-iehack";
8 | @import "test-null";
9 | @import "sub/test-relative-url";
10 | @import "attr";
11 | @import "test-color";
12 | @import "test-ascii";
13 |
14 | // working
15 | @import "@/index/css/_test-root-alias.scss";
16 | // working, the same
17 | @import "~@/index/css/_test-root-alias.scss";
18 |
19 | // @import "~xxxxx";
20 | // .xxxxx2 {
21 | // width: 60px;
22 | // height: 60px;
23 | // background: url("~xxxxx/autohome2.png") no-repeat;
24 | // background-size: contain;
25 | // }
26 |
27 | @import 'nest/_test_nest.scss';
28 |
--------------------------------------------------------------------------------
/packages/autofe-scripts/template/src/index/css/nest/_test_nest.scss:
--------------------------------------------------------------------------------
1 | /* test nest */
2 |
3 | // @import 'nnest/_test_nest2.css';
4 | @import 'nnest/_test_nest2';
5 | @import 'nnest/test_nest2';
6 |
7 | @import 'nnest/test_nest3';
--------------------------------------------------------------------------------
/packages/autofe-scripts/template/src/index/css/nest/nnest/_test_nest2.css:
--------------------------------------------------------------------------------
1 | /* test nest2 ---333---- */
--------------------------------------------------------------------------------
/packages/autofe-scripts/template/src/index/css/nest/nnest/_test_nest3.scss:
--------------------------------------------------------------------------------
1 | /* test nest3 */
--------------------------------------------------------------------------------
/packages/autofe-scripts/template/src/index/css/pure.css:
--------------------------------------------------------------------------------
1 | @import "sub/_test-relative-url-pure.css";
2 |
3 | /* @import "~xxxxx";
4 | .xxxxx2 {
5 | width: 60px;
6 | height: 60px;
7 | background: url("~xxxxx/autohome2.png") no-repeat;
8 | background-size: contain;
9 | } */
--------------------------------------------------------------------------------
/packages/autofe-scripts/template/src/index/css/sub/_test-relative-url-pure.css:
--------------------------------------------------------------------------------
1 | .test-relative-url3 {
2 | width: 320px;
3 | height: 240px;
4 | background: url("./car.jpg") no-repeat;
5 | }
6 |
7 | .test-relative-url4 {
8 | width: 320px;
9 | height: 240px;
10 | background: url("../../img/car.jpg") no-repeat;
11 | }
--------------------------------------------------------------------------------
/packages/autofe-scripts/template/src/index/css/sub/_test-relative-url.scss:
--------------------------------------------------------------------------------
1 | .test-relative-url1 {
2 | width: 320px;
3 | height: 240px;
4 | background: url("./car.jpg") no-repeat;
5 | }
6 |
7 | .test-relative-url2 {
8 | width: 320px;
9 | height: 240px;
10 | background: url("../../img/car.jpg") no-repeat;
11 | }
--------------------------------------------------------------------------------
/packages/autofe-scripts/template/src/index/css/sub/car.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athm-fe/create-autofe-app/787a340370d98ac16ecf1297ecb8bc699e0f0422/packages/autofe-scripts/template/src/index/css/sub/car.jpg
--------------------------------------------------------------------------------
/packages/autofe-scripts/template/src/index/font/iconfont.css:
--------------------------------------------------------------------------------
1 | @font-face {font-family: "iconfont";
2 | src: url('iconfont.eot?t=1575457538052'); /* IE9 */
3 | src: url('iconfont.eot?t=1575457538052#iefix') format('embedded-opentype'), /* IE6-IE8 */
4 | url('data:application/x-font-woff2;charset=utf-8;base64,d09GMgABAAAAAAa8AAsAAAAADWAAAAZtAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHEIGVgCDYAqMbIl/ATYCJAMoCxYABCAFhG0HgRAbFQsjkg5ShuwfCY6x1rETXDT+jhSrK6qPTZMQN5Kinong6fKdd7t3HThAnwLUrVSsFbBqKAELh2XTBHL8u1nzCLWk9SRoHamJYWXNKCsiYdfhziMla4KdiSBn9ndXeuYsTjWs7c4FRGgwl5Xu8csdV7YVnyfv+dR+rZ5JEm36DkiaCi1+sf17hok3s1BIhMwwXUyShcIQIpQc2cSr6SBmvUkvPExgMGcmVl7W9nQyWw0Yc09XJ7pCscxwhC7ZIBdm8a7WVa/VW3iL/j7+zEdHpU7sR21drp5bKEqHvfwz9hPjZbxKiJeRMEMmztHqQykhs4gOWHU2z1YzTCldLEYR8KvlYHAlyWrjH16r0xMNm05gfOjpKTwIClQUSBTIFKgp0FCgpUBHKXa5JNDjcXIVhZJME3fUOEax67YEOd9ptnWqoaZGLSfJjIwNwaA5FLI82ooEGc/jThJdw18JF1yNDL4cymfkiOQ4wiVDsrMoHF6Ji0papDsFBz3NO8m2Gzra3RE5eBx3sgDXNCQhHdg+Zpah2lk5OSsnAxmOINwKCkgbTLBwLlnndS0FPAx0CQh59DIg7UCsYzZ0nFXJKE+HOHgzLp8doltuMBs1Q3drAA/dlF26qWmTcinDlEocEaou3Sqj1aAfqluPCNBO0a01WaYUU99RQRzgr5FtojL8jTn4kSX0tfXVSKdsxyx/m6eCfcHwdDhijYQsbkUHf411r5N41vNmcQdPI/4hL0MhxHEU5QsWmb3OEtrvKLUKKtF/XK8iWdL8HmOg3neZrB9GjFb6A+eU+b2ggeIodHSVAeTonpOm/ZFSa8BVrGGaWbnbd6inCjLrh44ddsHhv0GumeGdk5xhW8MyPpfMbuM8AQe94sI1q2o1bnZu9pDY9rfZIIgH2Bv0zBr2mv+szC7ICI5B3e3cM/yNQkJAi87ax9U4CSsXcq7BEjuGZo9amGvCf2XDaOVKNOwwAePfgMkDlkgQk7AquDufGRtLTPRUJmoku0GKDSEWAnapaPcqw2hvz6rmbRejdmpmxYrd5O5oUtFRWtOLR3EnN61XQ19NSIrubshD7YlePK5f2WM9Q+Ts2V689bboHnJP4QzVyxJ/zd5DxIgejf4OltkcvW17E6SJM96r5XeYevtPNO584JJ/dNSPlyzcPmSuNW0wFZr3rWoqUYo1hZceYBX290KOnv6T+mMPXPYVi8pWe2hMG00a89rtTaUk4Lt8hbt1jwlaDe/b0PQ4vkjvS3vAl+PV35+R489u/KAv9ylb0+mCLGmCO60f+pbUrnerfrtc6PeIl/6YLYT3HKBftKF70m2GblvGQI9xIAOWf37aAyKYc50AdZ6+gi9xy3zA/7/x/+TnGL8cHf1eiuyZqTxATe3E8P7Z/QWeWU8gsE/Krvv1/1lwCwH/Psy1763aHjiOp/WlJ+qh0fz5Oymj84HAnOm/wi9MX46O/Nv/pckcgKlucmi9G6oZndavNt/n12kKNb7sPrWo0WqNfrVFXenQ6f33mePToPmFy777xNAv/vWp+4hH54YF1dWGVENNdU00VSSgecq/9z6fze7s6LsvUyHu3e/+CnvPHW6TqIBm43T9CaePLJ6MFf9X8j+zY75o3lf+TxqLYhrinC+eU2J5DpRow9fAkecAAGLvpIeweoDY++lZrBYgFk23YTQAAHYu+S5yfUoCBT4ky7PFPq5+S3rhU3oQ2JI80eVpbb8lEl/cTZ+kPIRoU+ydDPOMgEQS0Fr4TAotl0gNySa4uW7wxI9+yQ/wYaaSQj8OIGbVZ8IXYyeo1sKHP0FlkEiQDUwijVZqLEMcQh3iJeoErhQGLydkwXbAoJwEACVwggBJh3shkepZYNLhba3U+Dni0DCHeOkIA67wK+5veO4h6OyxoGA8wfoHJGNQbhmfxWPfUDcnSl6Kgl9YKrXB1I/lvlcMWMY4pX7rmVmBKtHDC3kcOhchlbih5N4wp+MwKOwVvYy+O/OoQAJDJ2D1F+QnUhSojdlZ5fffIK1xhMKYUc//BRUVbR1MemML7SsNrWZcy+TqmzZjWqmA11lEPkm8cJXIOd0RSPh+GySxnunRmRwNdCXVlvbzJ/ytLf0NzGJ/2llUkSJHHU200UUfQ4yurmLQAYPeSIQ/2psWNibaueLgjXC/TFopXCnW/qr/atZqYsu06yDhxCEar0Qwjaakau46AAA=') format('woff2'),
5 | url('iconfont.woff?t=1575457538052') format('woff'),
6 | url('iconfont.ttf?t=1575457538052') format('truetype'), /* chrome, firefox, opera, Safari, Android, iOS 4.2+ */
7 | url('iconfont.svg?t=1575457538052#iconfont') format('svg'); /* iOS 4.1- */
8 | }
9 |
10 | .iconfont {
11 | font-family: "iconfont" !important;
12 | font-size: 16px;
13 | font-style: normal;
14 | -webkit-font-smoothing: antialiased;
15 | -moz-osx-font-smoothing: grayscale;
16 | }
17 |
18 | .icon-gongnengjianyi:before {
19 | content: "\e600";
20 | }
21 |
22 | .icon-huanyipi:before {
23 | content: "\e601";
24 | }
25 |
26 | .icon-lianjie:before {
27 | content: "\e602";
28 | }
29 |
30 | .icon-31guanbi:before {
31 | content: "\e603";
32 | }
33 |
34 | .icon-31xuanze:before {
35 | content: "\e604";
36 | }
37 |
38 | .icon-31shouqi:before {
39 | content: "\e605";
40 | }
41 |
42 | .icon-31xiala:before {
43 | content: "\e606";
44 | }
45 |
46 | .icon-31fanhui1:before {
47 | content: "\e607";
48 | }
49 |
50 | .icon-31fanhui2:before {
51 | content: "\e608";
52 | }
53 |
54 |
--------------------------------------------------------------------------------
/packages/autofe-scripts/template/src/index/font/iconfont.eot:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athm-fe/create-autofe-app/787a340370d98ac16ecf1297ecb8bc699e0f0422/packages/autofe-scripts/template/src/index/font/iconfont.eot
--------------------------------------------------------------------------------
/packages/autofe-scripts/template/src/index/font/iconfont.json:
--------------------------------------------------------------------------------
1 | {
2 | "id": "134286",
3 | "name": "前端平台",
4 | "font_family": "iconfont",
5 | "css_prefix_text": "icon-",
6 | "description": "",
7 | "glyphs": [
8 | {
9 | "icon_id": "77107",
10 | "name": "功能建议",
11 | "font_class": "gongnengjianyi",
12 | "unicode": "e600",
13 | "unicode_decimal": 58880
14 | },
15 | {
16 | "icon_id": "77108",
17 | "name": "换一批",
18 | "font_class": "huanyipi",
19 | "unicode": "e601",
20 | "unicode_decimal": 58881
21 | },
22 | {
23 | "icon_id": "77403",
24 | "name": "链接",
25 | "font_class": "lianjie",
26 | "unicode": "e602",
27 | "unicode_decimal": 58882
28 | },
29 | {
30 | "icon_id": "200856",
31 | "name": "3.1关闭",
32 | "font_class": "31guanbi",
33 | "unicode": "e603",
34 | "unicode_decimal": 58883
35 | },
36 | {
37 | "icon_id": "200857",
38 | "name": "3.1选择",
39 | "font_class": "31xuanze",
40 | "unicode": "e604",
41 | "unicode_decimal": 58884
42 | },
43 | {
44 | "icon_id": "201650",
45 | "name": "3.1 收起",
46 | "font_class": "31shouqi",
47 | "unicode": "e605",
48 | "unicode_decimal": 58885
49 | },
50 | {
51 | "icon_id": "201652",
52 | "name": "3.1 下拉",
53 | "font_class": "31xiala",
54 | "unicode": "e606",
55 | "unicode_decimal": 58886
56 | },
57 | {
58 | "icon_id": "201666",
59 | "name": "3.1 返回1",
60 | "font_class": "31fanhui1",
61 | "unicode": "e607",
62 | "unicode_decimal": 58887
63 | },
64 | {
65 | "icon_id": "201667",
66 | "name": "3.1 返回2",
67 | "font_class": "31fanhui2",
68 | "unicode": "e608",
69 | "unicode_decimal": 58888
70 | }
71 | ]
72 | }
73 |
--------------------------------------------------------------------------------
/packages/autofe-scripts/template/src/index/font/iconfont.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athm-fe/create-autofe-app/787a340370d98ac16ecf1297ecb8bc699e0f0422/packages/autofe-scripts/template/src/index/font/iconfont.ttf
--------------------------------------------------------------------------------
/packages/autofe-scripts/template/src/index/font/iconfont.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athm-fe/create-autofe-app/787a340370d98ac16ecf1297ecb8bc699e0f0422/packages/autofe-scripts/template/src/index/font/iconfont.woff
--------------------------------------------------------------------------------
/packages/autofe-scripts/template/src/index/font/iconfont.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athm-fe/create-autofe-app/787a340370d98ac16ecf1297ecb8bc699e0f0422/packages/autofe-scripts/template/src/index/font/iconfont.woff2
--------------------------------------------------------------------------------
/packages/autofe-scripts/template/src/index/img/bg.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athm-fe/create-autofe-app/787a340370d98ac16ecf1297ecb8bc699e0f0422/packages/autofe-scripts/template/src/index/img/bg.png
--------------------------------------------------------------------------------
/packages/autofe-scripts/template/src/index/img/car.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athm-fe/create-autofe-app/787a340370d98ac16ecf1297ecb8bc699e0f0422/packages/autofe-scripts/template/src/index/img/car.jpg
--------------------------------------------------------------------------------
/packages/autofe-scripts/template/src/index/img/cursor-hand.cur:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athm-fe/create-autofe-app/787a340370d98ac16ecf1297ecb8bc699e0f0422/packages/autofe-scripts/template/src/index/img/cursor-hand.cur
--------------------------------------------------------------------------------
/packages/autofe-scripts/template/src/index/img/postcss-assets.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athm-fe/create-autofe-app/787a340370d98ac16ecf1297ecb8bc699e0f0422/packages/autofe-scripts/template/src/index/img/postcss-assets.jpg
--------------------------------------------------------------------------------
/packages/autofe-scripts/template/src/index/img/postcss-assets.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athm-fe/create-autofe-app/787a340370d98ac16ecf1297ecb8bc699e0f0422/packages/autofe-scripts/template/src/index/img/postcss-assets.png
--------------------------------------------------------------------------------
/packages/autofe-scripts/template/src/index/img/postcss-assets.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/packages/autofe-scripts/template/src/index/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 | Index Page
10 |
11 |
12 |
13 |
14 | Hello World, 标题有样式
15 |
16 | css background image 页面有背景图
17 |
18 | html img src
19 |
20 |
21 | css background image, svg, inline
22 |
23 | css background image, svg, normal
24 |
25 | css background image, png, inline
26 |
27 | css background image, png, normal
28 |
29 | css background image, jpg, inline
30 |
31 | css background image, jpg, normal
32 |
33 | css cursor image, <1kb
34 |
35 |
36 | scss subdir background image relative url
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 | scss color background-color #ff6632
46 |
47 |
48 | Nunjucks, includePretty, 对齐没毛病
49 | {% includePretty "index/_part1.html" %}
50 | {% includePretty "index/_part2.html" %}
51 |
52 | Nunjucks, includePretty, assets
53 | {% includePretty "component/footer/_index.html" %}
54 |
55 | Nunjucks, 来自 .env 配置的变量
56 | {{ APP_TEST_ENV_FEATURE }}
57 |
58 | Nunjucks, 区分开发和线上
59 | {% if NODE_ENV === 'development' %}
60 | 这是只出现在开发环境的内容
61 | {% else %}
62 | 这是只出现在生产环境的内容
63 | {% endif %}
64 |
65 | 属性选择器
66 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
--------------------------------------------------------------------------------
/packages/autofe-scripts/template/src/index/js/hello.ts:
--------------------------------------------------------------------------------
1 | /* eslint @typescript-eslint/no-unused-vars: "off" */
2 | /* eslint @typescript-eslint/no-explicit-any: "off" */
3 | /* eslint @typescript-eslint/no-inferrable-types: "off" */
4 |
5 | console.group('ts');
6 |
7 |
8 | const age1 = 'seventeen';
9 | const age2: string = 'seventeen';
10 | const age3: any = 'seventeen';
11 |
12 | const isDone: boolean = false;
13 | // const isFinished: boolean = 'finished';
14 |
15 | const decLiteral: number = 6;
16 | const notANumber: number = NaN;
17 | const infinityNumber: number = Infinity;
18 |
19 | const myName: string = 'Tom';
20 | const myAge: number = 25;
21 | const sentence: string = `Hello, my name is ${myName}.
22 | I'll be ${myAge + 1} years old next month.`;
23 |
24 |
25 | function sayHello(person: string): string {
26 | return 'Hello, ' + person;
27 | }
28 |
29 | const user = 'Tom';
30 | const num = 10;
31 |
32 | console.log(sayHello(user));
33 | // console.log(sayHello(num));
34 |
35 |
36 | function alertName(): void {
37 | console.log('My name is Tom');
38 | }
39 |
40 |
41 | const numUndifined: number | undefined = undefined;
42 | const numNull: number | null = null;
43 |
44 |
45 | // 任意类型
46 | let myFavoriteNumber: any = 'seven';
47 | myFavoriteNumber = 7;
48 |
49 | // 类型推论
50 | let myFavoriteNumber2 = 'seven';
51 | // myFavoriteNumber2 = 7;
52 | myFavoriteNumber2 = 'eight';
53 |
54 | // 任意类型
55 | let myFavoriteNumber3;
56 | myFavoriteNumber3 = 'seven';
57 | myFavoriteNumber3 = 7;
58 |
59 |
60 | function getLength(something: string | number): number {
61 | if (typeof something === 'string') {
62 | return something.length;
63 | }
64 | return 0;
65 | }
66 |
67 | function getString(something: string | number): string {
68 | return something.toString();
69 | }
70 |
71 |
72 | const fibonacci: number[] = [1, 1, 2, 3, 5];
73 | const fibonacci2: Array = [1, 1, 2, 3, 5];
74 | const myInfo: any[] = ['jpuncle', 33, { website: 'https://jpuncle.com' }];
75 | function sum(...args: Array): number {
76 | return args[0] + args[1];
77 | }
78 | function sum2(): number {
79 | const args: IArguments = arguments;
80 |
81 | return args[0] + args[1];
82 | }
83 | function sum3(x: number, y: number): number {
84 | return x + y;
85 | }
86 |
87 |
88 | class Animal {
89 | protected name: string;
90 | public age: number;
91 | public constructor(name: string) {
92 | this.name = name;
93 | this.age = 0;
94 | }
95 | }
96 |
97 | class Cat extends Animal {
98 | constructor(name: string) {
99 | super(name);
100 | console.log(this.name);
101 | }
102 | }
103 |
104 | const a = new Animal('Jack');
105 | // a.name = 'Tom';
106 | a.age = 20;
107 |
108 | let foo = 3;
109 | switch (foo) {
110 | case 1:
111 | sayHello('Tom');
112 | break;
113 | case 2:
114 | sayHello('Jack');
115 | break;
116 | // default:
117 | // // do nothing
118 | // no default
119 | }
120 | foo = 3 + 3;
121 |
122 |
123 | export { sayHello };
124 | export { getString, getLength };
125 |
126 |
127 | console.groupEnd();
128 |
--------------------------------------------------------------------------------
/packages/autofe-scripts/template/src/index/js/index.entry.js:
--------------------------------------------------------------------------------
1 | /**
2 | * 请注意
3 | * ES6 模块不支持 IE < 9
4 | * CommonJS 模块支持 IE < 9
5 | */
6 |
7 | import $ from 'jquery';
8 | import { sum, PI } from './math';
9 | import bg from '../img/bg.png';
10 | import sharePic from '@/assets/share.png';
11 | import svgContent from '../img/postcss-assets.svg?inline';
12 |
13 | console.log('sum(3, 5)', sum(3, 5));
14 | console.log('PI', PI);
15 | console.log(bg);
16 | console.log(sharePic);
17 | console.log(svgContent);
18 | console.log(process.env.BASE_URL);
19 | console.log(process.env.NODE_ENV);
20 | console.log(process.env.APP_TEST_ENV_FEATURE);
21 | console.log(process.env.TEST_ENV_FEATURE);
22 |
23 | $(function () {
24 | console.log('jQuery document.ready 中文');
25 | });
26 |
--------------------------------------------------------------------------------
/packages/autofe-scripts/template/src/index/js/indexts.entry.ts:
--------------------------------------------------------------------------------
1 | import { sayHello, getString } from './hello';
2 |
3 | console.group('ts');
4 |
5 | console.log(sayHello('Tom'));
6 | console.log(getString('test get string'));
7 | console.log(getString(12345));
8 |
9 | console.groupEnd();
10 |
--------------------------------------------------------------------------------
/packages/autofe-scripts/template/src/index/js/main.old.js:
--------------------------------------------------------------------------------
1 | (function () {
2 | console.log('Hello world from old script. 中文');
3 | }());
4 |
5 | console.log(process.env.BASE_URL);
6 | console.log(process.env.NODE_ENV);
7 | console.log(process.env.APP_TEST_ENV_FEATURE);
8 | console.log(process.env.TEST_ENV_FEATURE);
9 |
10 | console.log('-------- old script --------');
11 |
--------------------------------------------------------------------------------
/packages/autofe-scripts/template/src/index/js/math.js:
--------------------------------------------------------------------------------
1 | export function sum(x, y) {
2 | return x + y;
3 | }
4 | export const PI = 3.141593;
5 |
--------------------------------------------------------------------------------
/packages/autofe-scripts/template/src/index/pic/01.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athm-fe/create-autofe-app/787a340370d98ac16ecf1297ecb8bc699e0f0422/packages/autofe-scripts/template/src/index/pic/01.jpg
--------------------------------------------------------------------------------
/packages/autofe-scripts/template/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | // 使用最新语言规范,交给 Babel 来做后续编译处理
4 | "target": "esnext",
5 | // 使用最新模块规范,交给 Webpack 来做后续打包
6 | "module": "esnext",
7 | // Enable all strict type-checking options
8 | "strict": true,
9 | // Specify JSX code generation: 'preserve', 'react-native', or 'react'.
10 | "jsx": "preserve",
11 | // Import emit helpers from 'tslib'.
12 | "importHelpers": true,
13 | // Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6).
14 | "moduleResolution": "node",
15 | // Enables experimental support for ES7 decorators.
16 | "experimentalDecorators": true,
17 | // Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'.
18 | "esModuleInterop": true,
19 | /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
20 | "allowSyntheticDefaultImports": true,
21 | /* Generates corresponding '.map' file. */
22 | "sourceMap": true,
23 | /* Base directory to resolve non-absolute module names. */
24 | "baseUrl": ".",
25 | /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
26 | "paths": {
27 | "@/*": [
28 | "src/*"
29 | ]
30 | },
31 | // Specify library files to be included in the compilation.
32 | "lib": [
33 | "esnext",
34 | "dom",
35 | "dom.iterable",
36 | "scripthost"
37 | ]
38 | },
39 | "include": [
40 | "src/**/*.ts",
41 | "src/**/*.tsx"
42 | // "src/**/*.vue",
43 | ],
44 | "exclude": [
45 | "node_modules"
46 | ]
47 | }
48 |
--------------------------------------------------------------------------------
/packages/autofe-scripts/util/isAbsoluteUrl.js:
--------------------------------------------------------------------------------
1 | module.exports = function isAbsoluteUrl (url) {
2 | // A URL is considered absolute if it begins with "://" or "//"
3 | return /^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(url)
4 | }
5 |
--------------------------------------------------------------------------------
/packages/autofe-scripts/util/prepareURLs.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2015-present, Facebook, Inc.
3 | *
4 | * This source code is licensed under the MIT license found in the
5 | * LICENSE file at
6 | * https://github.com/facebookincubator/create-react-app/blob/master/LICENSE
7 | */
8 |
9 | const url = require('url')
10 | const { chalk } = require('@vue/cli-shared-utils')
11 | const address = require('address')
12 | const defaultGateway = require('default-gateway')
13 |
14 | module.exports = function prepareUrls (protocol, host, port, pathname = '/') {
15 | const formatUrl = hostname =>
16 | url.format({
17 | protocol,
18 | hostname,
19 | port,
20 | pathname
21 | })
22 | const prettyPrintUrl = hostname =>
23 | url.format({
24 | protocol,
25 | hostname,
26 | port: chalk.bold(port),
27 | pathname
28 | })
29 |
30 | const isUnspecifiedHost = host === '0.0.0.0' || host === '::'
31 | let prettyHost, lanUrlForConfig
32 | if (isUnspecifiedHost) {
33 | prettyHost = 'localhost'
34 | try {
35 | // This can only return an IPv4 address
36 | const result = defaultGateway.v4.sync()
37 | const ip = address.ip(result && result.interface)
38 | if (ip) {
39 | // Check if the address is a private ip
40 | // https://en.wikipedia.org/wiki/Private_network#Private_IPv4_address_spaces
41 | if (
42 | /^10[.]|^172[.](1[6-9]|2[0-9]|3[0-1])[.]|^192[.]168[.]/.test(
43 | ip
44 | )
45 | ) {
46 | lanUrlForConfig = ip
47 | }
48 | }
49 | } catch (_e) {
50 | // ignored
51 | }
52 | } else {
53 | prettyHost = host
54 | lanUrlForConfig = host
55 | }
56 | const lanUrlForTerminal = lanUrlForConfig
57 | ? prettyPrintUrl(lanUrlForConfig)
58 | : chalk.gray('unavailable')
59 | const lanUrlForBrowser = lanUrlForConfig
60 | ? formatUrl(lanUrlForConfig)
61 | : undefined
62 | const localUrlForTerminal = prettyPrintUrl(prettyHost)
63 | const localUrlForBrowser = formatUrl(prettyHost)
64 | return {
65 | lanUrlForConfig,
66 | lanUrlForTerminal,
67 | lanUrlForBrowser,
68 | localUrlForTerminal,
69 | localUrlForBrowser
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/packages/autofe-scripts/util/resolveClientEnv.js:
--------------------------------------------------------------------------------
1 | const prefixRE = /^APP_/
2 |
3 | module.exports = function resolveClientEnv (options, raw) {
4 | const env = {}
5 | Object.keys(process.env).forEach(key => {
6 | if (prefixRE.test(key) || key === 'NODE_ENV') {
7 | env[key] = process.env[key]
8 | }
9 | })
10 | env.BASE_URL = options.publicPath
11 |
12 | if (raw) {
13 | return env
14 | }
15 |
16 | for (const key in env) {
17 | env[key] = JSON.stringify(env[key])
18 | }
19 | return {
20 | 'process.env': env
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/packages/autofe-serve-index/.editorconfig:
--------------------------------------------------------------------------------
1 | # http://editorconfig.org
2 | root = true
3 |
4 | [*]
5 | charset = utf-8
6 | insert_final_newline = true
7 | trim_trailing_whitespace = true
8 |
9 | [{*.js,*.json,*.yml}]
10 | indent_size = 2
11 | indent_style = space
12 |
--------------------------------------------------------------------------------
/packages/autofe-serve-index/.gitignore:
--------------------------------------------------------------------------------
1 | coverage
2 | node_modules
3 | npm-debug.log
4 | package-lock.json
5 |
--------------------------------------------------------------------------------
/packages/autofe-serve-index/LICENSE:
--------------------------------------------------------------------------------
1 | (The MIT License)
2 |
3 | Copyright (c) 2010 Sencha Inc.
4 | Copyright (c) 2011 LearnBoost
5 | Copyright (c) 2011 TJ Holowaychuk
6 | Copyright (c) 2014-2015 Douglas Christopher Wilson
7 |
8 | Permission is hereby granted, free of charge, to any person obtaining
9 | a copy of this software and associated documentation files (the
10 | 'Software'), to deal in the Software without restriction, including
11 | without limitation the rights to use, copy, modify, merge, publish,
12 | distribute, sublicense, and/or sell copies of the Software, and to
13 | permit persons to whom the Software is furnished to do so, subject to
14 | the following conditions:
15 |
16 | The above copyright notice and this permission notice shall be
17 | included in all copies or substantial portions of the Software.
18 |
19 | THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
20 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
22 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
23 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
24 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
25 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 |
--------------------------------------------------------------------------------
/packages/autofe-serve-index/README.md:
--------------------------------------------------------------------------------
1 | # serve-index
2 |
3 | 修改自 [serve-index](https://github.com/expressjs/serve-index) ,但是主要目的是为了配合 webpack-dev-server 使用。
--------------------------------------------------------------------------------
/packages/autofe-serve-index/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "autofe-serve-index",
3 | "description": "Serve directory listings",
4 | "version": "0.2.0",
5 | "author": "jpuncle",
6 | "license": "MIT",
7 | "repository": {
8 | "type": "git",
9 | "url": "https://github.com/athm-fe/create-autofe-app.git",
10 | "directory": "packages/autofe-serve-index"
11 | },
12 | "dependencies": {
13 | "accepts": "~1.3.7",
14 | "batch": "0.6.1",
15 | "debug": "2.6.9",
16 | "escape-html": "~1.0.3",
17 | "http-errors": "~1.7.2",
18 | "mime-types": "~2.1.24",
19 | "parseurl": "~1.3.3"
20 | },
21 | "files": [
22 | "public/",
23 | "LICENSE",
24 | "index.js"
25 | ],
26 | "engines": {
27 | "node": ">= 0.8.0"
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/packages/autofe-serve-index/public/directory.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | listing directory {directory}
7 |
8 |
74 |
75 |
76 |
77 |
78 |
~{linked-path}
79 | {files}
80 |
81 |
82 |
--------------------------------------------------------------------------------
/packages/autofe-serve-index/public/icons/application_xp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athm-fe/create-autofe-app/787a340370d98ac16ecf1297ecb8bc699e0f0422/packages/autofe-serve-index/public/icons/application_xp.png
--------------------------------------------------------------------------------
/packages/autofe-serve-index/public/icons/application_xp_terminal.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athm-fe/create-autofe-app/787a340370d98ac16ecf1297ecb8bc699e0f0422/packages/autofe-serve-index/public/icons/application_xp_terminal.png
--------------------------------------------------------------------------------
/packages/autofe-serve-index/public/icons/box.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athm-fe/create-autofe-app/787a340370d98ac16ecf1297ecb8bc699e0f0422/packages/autofe-serve-index/public/icons/box.png
--------------------------------------------------------------------------------
/packages/autofe-serve-index/public/icons/cd.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athm-fe/create-autofe-app/787a340370d98ac16ecf1297ecb8bc699e0f0422/packages/autofe-serve-index/public/icons/cd.png
--------------------------------------------------------------------------------
/packages/autofe-serve-index/public/icons/controller.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athm-fe/create-autofe-app/787a340370d98ac16ecf1297ecb8bc699e0f0422/packages/autofe-serve-index/public/icons/controller.png
--------------------------------------------------------------------------------
/packages/autofe-serve-index/public/icons/drive.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athm-fe/create-autofe-app/787a340370d98ac16ecf1297ecb8bc699e0f0422/packages/autofe-serve-index/public/icons/drive.png
--------------------------------------------------------------------------------
/packages/autofe-serve-index/public/icons/film.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athm-fe/create-autofe-app/787a340370d98ac16ecf1297ecb8bc699e0f0422/packages/autofe-serve-index/public/icons/film.png
--------------------------------------------------------------------------------
/packages/autofe-serve-index/public/icons/folder.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athm-fe/create-autofe-app/787a340370d98ac16ecf1297ecb8bc699e0f0422/packages/autofe-serve-index/public/icons/folder.png
--------------------------------------------------------------------------------
/packages/autofe-serve-index/public/icons/font.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athm-fe/create-autofe-app/787a340370d98ac16ecf1297ecb8bc699e0f0422/packages/autofe-serve-index/public/icons/font.png
--------------------------------------------------------------------------------
/packages/autofe-serve-index/public/icons/image.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athm-fe/create-autofe-app/787a340370d98ac16ecf1297ecb8bc699e0f0422/packages/autofe-serve-index/public/icons/image.png
--------------------------------------------------------------------------------
/packages/autofe-serve-index/public/icons/map.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athm-fe/create-autofe-app/787a340370d98ac16ecf1297ecb8bc699e0f0422/packages/autofe-serve-index/public/icons/map.png
--------------------------------------------------------------------------------
/packages/autofe-serve-index/public/icons/page.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athm-fe/create-autofe-app/787a340370d98ac16ecf1297ecb8bc699e0f0422/packages/autofe-serve-index/public/icons/page.png
--------------------------------------------------------------------------------
/packages/autofe-serve-index/public/icons/page_add.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athm-fe/create-autofe-app/787a340370d98ac16ecf1297ecb8bc699e0f0422/packages/autofe-serve-index/public/icons/page_add.png
--------------------------------------------------------------------------------
/packages/autofe-serve-index/public/icons/page_attach.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athm-fe/create-autofe-app/787a340370d98ac16ecf1297ecb8bc699e0f0422/packages/autofe-serve-index/public/icons/page_attach.png
--------------------------------------------------------------------------------
/packages/autofe-serve-index/public/icons/page_code.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athm-fe/create-autofe-app/787a340370d98ac16ecf1297ecb8bc699e0f0422/packages/autofe-serve-index/public/icons/page_code.png
--------------------------------------------------------------------------------
/packages/autofe-serve-index/public/icons/page_copy.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athm-fe/create-autofe-app/787a340370d98ac16ecf1297ecb8bc699e0f0422/packages/autofe-serve-index/public/icons/page_copy.png
--------------------------------------------------------------------------------
/packages/autofe-serve-index/public/icons/page_delete.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athm-fe/create-autofe-app/787a340370d98ac16ecf1297ecb8bc699e0f0422/packages/autofe-serve-index/public/icons/page_delete.png
--------------------------------------------------------------------------------
/packages/autofe-serve-index/public/icons/page_edit.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athm-fe/create-autofe-app/787a340370d98ac16ecf1297ecb8bc699e0f0422/packages/autofe-serve-index/public/icons/page_edit.png
--------------------------------------------------------------------------------
/packages/autofe-serve-index/public/icons/page_error.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athm-fe/create-autofe-app/787a340370d98ac16ecf1297ecb8bc699e0f0422/packages/autofe-serve-index/public/icons/page_error.png
--------------------------------------------------------------------------------
/packages/autofe-serve-index/public/icons/page_excel.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athm-fe/create-autofe-app/787a340370d98ac16ecf1297ecb8bc699e0f0422/packages/autofe-serve-index/public/icons/page_excel.png
--------------------------------------------------------------------------------
/packages/autofe-serve-index/public/icons/page_find.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athm-fe/create-autofe-app/787a340370d98ac16ecf1297ecb8bc699e0f0422/packages/autofe-serve-index/public/icons/page_find.png
--------------------------------------------------------------------------------
/packages/autofe-serve-index/public/icons/page_gear.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athm-fe/create-autofe-app/787a340370d98ac16ecf1297ecb8bc699e0f0422/packages/autofe-serve-index/public/icons/page_gear.png
--------------------------------------------------------------------------------
/packages/autofe-serve-index/public/icons/page_go.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athm-fe/create-autofe-app/787a340370d98ac16ecf1297ecb8bc699e0f0422/packages/autofe-serve-index/public/icons/page_go.png
--------------------------------------------------------------------------------
/packages/autofe-serve-index/public/icons/page_green.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athm-fe/create-autofe-app/787a340370d98ac16ecf1297ecb8bc699e0f0422/packages/autofe-serve-index/public/icons/page_green.png
--------------------------------------------------------------------------------
/packages/autofe-serve-index/public/icons/page_key.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athm-fe/create-autofe-app/787a340370d98ac16ecf1297ecb8bc699e0f0422/packages/autofe-serve-index/public/icons/page_key.png
--------------------------------------------------------------------------------
/packages/autofe-serve-index/public/icons/page_lightning.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athm-fe/create-autofe-app/787a340370d98ac16ecf1297ecb8bc699e0f0422/packages/autofe-serve-index/public/icons/page_lightning.png
--------------------------------------------------------------------------------
/packages/autofe-serve-index/public/icons/page_link.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athm-fe/create-autofe-app/787a340370d98ac16ecf1297ecb8bc699e0f0422/packages/autofe-serve-index/public/icons/page_link.png
--------------------------------------------------------------------------------
/packages/autofe-serve-index/public/icons/page_paintbrush.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athm-fe/create-autofe-app/787a340370d98ac16ecf1297ecb8bc699e0f0422/packages/autofe-serve-index/public/icons/page_paintbrush.png
--------------------------------------------------------------------------------
/packages/autofe-serve-index/public/icons/page_paste.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athm-fe/create-autofe-app/787a340370d98ac16ecf1297ecb8bc699e0f0422/packages/autofe-serve-index/public/icons/page_paste.png
--------------------------------------------------------------------------------
/packages/autofe-serve-index/public/icons/page_red.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athm-fe/create-autofe-app/787a340370d98ac16ecf1297ecb8bc699e0f0422/packages/autofe-serve-index/public/icons/page_red.png
--------------------------------------------------------------------------------
/packages/autofe-serve-index/public/icons/page_refresh.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athm-fe/create-autofe-app/787a340370d98ac16ecf1297ecb8bc699e0f0422/packages/autofe-serve-index/public/icons/page_refresh.png
--------------------------------------------------------------------------------
/packages/autofe-serve-index/public/icons/page_save.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athm-fe/create-autofe-app/787a340370d98ac16ecf1297ecb8bc699e0f0422/packages/autofe-serve-index/public/icons/page_save.png
--------------------------------------------------------------------------------
/packages/autofe-serve-index/public/icons/page_white.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athm-fe/create-autofe-app/787a340370d98ac16ecf1297ecb8bc699e0f0422/packages/autofe-serve-index/public/icons/page_white.png
--------------------------------------------------------------------------------
/packages/autofe-serve-index/public/icons/page_white_acrobat.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athm-fe/create-autofe-app/787a340370d98ac16ecf1297ecb8bc699e0f0422/packages/autofe-serve-index/public/icons/page_white_acrobat.png
--------------------------------------------------------------------------------
/packages/autofe-serve-index/public/icons/page_white_actionscript.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athm-fe/create-autofe-app/787a340370d98ac16ecf1297ecb8bc699e0f0422/packages/autofe-serve-index/public/icons/page_white_actionscript.png
--------------------------------------------------------------------------------
/packages/autofe-serve-index/public/icons/page_white_add.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athm-fe/create-autofe-app/787a340370d98ac16ecf1297ecb8bc699e0f0422/packages/autofe-serve-index/public/icons/page_white_add.png
--------------------------------------------------------------------------------
/packages/autofe-serve-index/public/icons/page_white_c.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athm-fe/create-autofe-app/787a340370d98ac16ecf1297ecb8bc699e0f0422/packages/autofe-serve-index/public/icons/page_white_c.png
--------------------------------------------------------------------------------
/packages/autofe-serve-index/public/icons/page_white_camera.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athm-fe/create-autofe-app/787a340370d98ac16ecf1297ecb8bc699e0f0422/packages/autofe-serve-index/public/icons/page_white_camera.png
--------------------------------------------------------------------------------
/packages/autofe-serve-index/public/icons/page_white_cd.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athm-fe/create-autofe-app/787a340370d98ac16ecf1297ecb8bc699e0f0422/packages/autofe-serve-index/public/icons/page_white_cd.png
--------------------------------------------------------------------------------
/packages/autofe-serve-index/public/icons/page_white_code.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athm-fe/create-autofe-app/787a340370d98ac16ecf1297ecb8bc699e0f0422/packages/autofe-serve-index/public/icons/page_white_code.png
--------------------------------------------------------------------------------
/packages/autofe-serve-index/public/icons/page_white_code_red.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athm-fe/create-autofe-app/787a340370d98ac16ecf1297ecb8bc699e0f0422/packages/autofe-serve-index/public/icons/page_white_code_red.png
--------------------------------------------------------------------------------
/packages/autofe-serve-index/public/icons/page_white_coldfusion.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athm-fe/create-autofe-app/787a340370d98ac16ecf1297ecb8bc699e0f0422/packages/autofe-serve-index/public/icons/page_white_coldfusion.png
--------------------------------------------------------------------------------
/packages/autofe-serve-index/public/icons/page_white_compressed.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athm-fe/create-autofe-app/787a340370d98ac16ecf1297ecb8bc699e0f0422/packages/autofe-serve-index/public/icons/page_white_compressed.png
--------------------------------------------------------------------------------
/packages/autofe-serve-index/public/icons/page_white_copy.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athm-fe/create-autofe-app/787a340370d98ac16ecf1297ecb8bc699e0f0422/packages/autofe-serve-index/public/icons/page_white_copy.png
--------------------------------------------------------------------------------
/packages/autofe-serve-index/public/icons/page_white_cplusplus.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athm-fe/create-autofe-app/787a340370d98ac16ecf1297ecb8bc699e0f0422/packages/autofe-serve-index/public/icons/page_white_cplusplus.png
--------------------------------------------------------------------------------
/packages/autofe-serve-index/public/icons/page_white_csharp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athm-fe/create-autofe-app/787a340370d98ac16ecf1297ecb8bc699e0f0422/packages/autofe-serve-index/public/icons/page_white_csharp.png
--------------------------------------------------------------------------------
/packages/autofe-serve-index/public/icons/page_white_cup.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athm-fe/create-autofe-app/787a340370d98ac16ecf1297ecb8bc699e0f0422/packages/autofe-serve-index/public/icons/page_white_cup.png
--------------------------------------------------------------------------------
/packages/autofe-serve-index/public/icons/page_white_database.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athm-fe/create-autofe-app/787a340370d98ac16ecf1297ecb8bc699e0f0422/packages/autofe-serve-index/public/icons/page_white_database.png
--------------------------------------------------------------------------------
/packages/autofe-serve-index/public/icons/page_white_delete.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athm-fe/create-autofe-app/787a340370d98ac16ecf1297ecb8bc699e0f0422/packages/autofe-serve-index/public/icons/page_white_delete.png
--------------------------------------------------------------------------------
/packages/autofe-serve-index/public/icons/page_white_dvd.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athm-fe/create-autofe-app/787a340370d98ac16ecf1297ecb8bc699e0f0422/packages/autofe-serve-index/public/icons/page_white_dvd.png
--------------------------------------------------------------------------------
/packages/autofe-serve-index/public/icons/page_white_edit.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athm-fe/create-autofe-app/787a340370d98ac16ecf1297ecb8bc699e0f0422/packages/autofe-serve-index/public/icons/page_white_edit.png
--------------------------------------------------------------------------------
/packages/autofe-serve-index/public/icons/page_white_error.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athm-fe/create-autofe-app/787a340370d98ac16ecf1297ecb8bc699e0f0422/packages/autofe-serve-index/public/icons/page_white_error.png
--------------------------------------------------------------------------------
/packages/autofe-serve-index/public/icons/page_white_excel.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athm-fe/create-autofe-app/787a340370d98ac16ecf1297ecb8bc699e0f0422/packages/autofe-serve-index/public/icons/page_white_excel.png
--------------------------------------------------------------------------------
/packages/autofe-serve-index/public/icons/page_white_find.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athm-fe/create-autofe-app/787a340370d98ac16ecf1297ecb8bc699e0f0422/packages/autofe-serve-index/public/icons/page_white_find.png
--------------------------------------------------------------------------------
/packages/autofe-serve-index/public/icons/page_white_flash.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athm-fe/create-autofe-app/787a340370d98ac16ecf1297ecb8bc699e0f0422/packages/autofe-serve-index/public/icons/page_white_flash.png
--------------------------------------------------------------------------------
/packages/autofe-serve-index/public/icons/page_white_freehand.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athm-fe/create-autofe-app/787a340370d98ac16ecf1297ecb8bc699e0f0422/packages/autofe-serve-index/public/icons/page_white_freehand.png
--------------------------------------------------------------------------------
/packages/autofe-serve-index/public/icons/page_white_gear.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athm-fe/create-autofe-app/787a340370d98ac16ecf1297ecb8bc699e0f0422/packages/autofe-serve-index/public/icons/page_white_gear.png
--------------------------------------------------------------------------------
/packages/autofe-serve-index/public/icons/page_white_get.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athm-fe/create-autofe-app/787a340370d98ac16ecf1297ecb8bc699e0f0422/packages/autofe-serve-index/public/icons/page_white_get.png
--------------------------------------------------------------------------------
/packages/autofe-serve-index/public/icons/page_white_go.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athm-fe/create-autofe-app/787a340370d98ac16ecf1297ecb8bc699e0f0422/packages/autofe-serve-index/public/icons/page_white_go.png
--------------------------------------------------------------------------------
/packages/autofe-serve-index/public/icons/page_white_h.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athm-fe/create-autofe-app/787a340370d98ac16ecf1297ecb8bc699e0f0422/packages/autofe-serve-index/public/icons/page_white_h.png
--------------------------------------------------------------------------------
/packages/autofe-serve-index/public/icons/page_white_horizontal.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athm-fe/create-autofe-app/787a340370d98ac16ecf1297ecb8bc699e0f0422/packages/autofe-serve-index/public/icons/page_white_horizontal.png
--------------------------------------------------------------------------------
/packages/autofe-serve-index/public/icons/page_white_key.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athm-fe/create-autofe-app/787a340370d98ac16ecf1297ecb8bc699e0f0422/packages/autofe-serve-index/public/icons/page_white_key.png
--------------------------------------------------------------------------------
/packages/autofe-serve-index/public/icons/page_white_lightning.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athm-fe/create-autofe-app/787a340370d98ac16ecf1297ecb8bc699e0f0422/packages/autofe-serve-index/public/icons/page_white_lightning.png
--------------------------------------------------------------------------------
/packages/autofe-serve-index/public/icons/page_white_link.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athm-fe/create-autofe-app/787a340370d98ac16ecf1297ecb8bc699e0f0422/packages/autofe-serve-index/public/icons/page_white_link.png
--------------------------------------------------------------------------------
/packages/autofe-serve-index/public/icons/page_white_magnify.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athm-fe/create-autofe-app/787a340370d98ac16ecf1297ecb8bc699e0f0422/packages/autofe-serve-index/public/icons/page_white_magnify.png
--------------------------------------------------------------------------------
/packages/autofe-serve-index/public/icons/page_white_medal.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athm-fe/create-autofe-app/787a340370d98ac16ecf1297ecb8bc699e0f0422/packages/autofe-serve-index/public/icons/page_white_medal.png
--------------------------------------------------------------------------------
/packages/autofe-serve-index/public/icons/page_white_office.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athm-fe/create-autofe-app/787a340370d98ac16ecf1297ecb8bc699e0f0422/packages/autofe-serve-index/public/icons/page_white_office.png
--------------------------------------------------------------------------------
/packages/autofe-serve-index/public/icons/page_white_paint.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athm-fe/create-autofe-app/787a340370d98ac16ecf1297ecb8bc699e0f0422/packages/autofe-serve-index/public/icons/page_white_paint.png
--------------------------------------------------------------------------------
/packages/autofe-serve-index/public/icons/page_white_paintbrush.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athm-fe/create-autofe-app/787a340370d98ac16ecf1297ecb8bc699e0f0422/packages/autofe-serve-index/public/icons/page_white_paintbrush.png
--------------------------------------------------------------------------------
/packages/autofe-serve-index/public/icons/page_white_paste.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athm-fe/create-autofe-app/787a340370d98ac16ecf1297ecb8bc699e0f0422/packages/autofe-serve-index/public/icons/page_white_paste.png
--------------------------------------------------------------------------------
/packages/autofe-serve-index/public/icons/page_white_php.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athm-fe/create-autofe-app/787a340370d98ac16ecf1297ecb8bc699e0f0422/packages/autofe-serve-index/public/icons/page_white_php.png
--------------------------------------------------------------------------------
/packages/autofe-serve-index/public/icons/page_white_picture.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athm-fe/create-autofe-app/787a340370d98ac16ecf1297ecb8bc699e0f0422/packages/autofe-serve-index/public/icons/page_white_picture.png
--------------------------------------------------------------------------------
/packages/autofe-serve-index/public/icons/page_white_powerpoint.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athm-fe/create-autofe-app/787a340370d98ac16ecf1297ecb8bc699e0f0422/packages/autofe-serve-index/public/icons/page_white_powerpoint.png
--------------------------------------------------------------------------------
/packages/autofe-serve-index/public/icons/page_white_put.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athm-fe/create-autofe-app/787a340370d98ac16ecf1297ecb8bc699e0f0422/packages/autofe-serve-index/public/icons/page_white_put.png
--------------------------------------------------------------------------------
/packages/autofe-serve-index/public/icons/page_white_ruby.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athm-fe/create-autofe-app/787a340370d98ac16ecf1297ecb8bc699e0f0422/packages/autofe-serve-index/public/icons/page_white_ruby.png
--------------------------------------------------------------------------------
/packages/autofe-serve-index/public/icons/page_white_stack.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athm-fe/create-autofe-app/787a340370d98ac16ecf1297ecb8bc699e0f0422/packages/autofe-serve-index/public/icons/page_white_stack.png
--------------------------------------------------------------------------------
/packages/autofe-serve-index/public/icons/page_white_star.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athm-fe/create-autofe-app/787a340370d98ac16ecf1297ecb8bc699e0f0422/packages/autofe-serve-index/public/icons/page_white_star.png
--------------------------------------------------------------------------------
/packages/autofe-serve-index/public/icons/page_white_swoosh.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athm-fe/create-autofe-app/787a340370d98ac16ecf1297ecb8bc699e0f0422/packages/autofe-serve-index/public/icons/page_white_swoosh.png
--------------------------------------------------------------------------------
/packages/autofe-serve-index/public/icons/page_white_text.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athm-fe/create-autofe-app/787a340370d98ac16ecf1297ecb8bc699e0f0422/packages/autofe-serve-index/public/icons/page_white_text.png
--------------------------------------------------------------------------------
/packages/autofe-serve-index/public/icons/page_white_text_width.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athm-fe/create-autofe-app/787a340370d98ac16ecf1297ecb8bc699e0f0422/packages/autofe-serve-index/public/icons/page_white_text_width.png
--------------------------------------------------------------------------------
/packages/autofe-serve-index/public/icons/page_white_tux.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athm-fe/create-autofe-app/787a340370d98ac16ecf1297ecb8bc699e0f0422/packages/autofe-serve-index/public/icons/page_white_tux.png
--------------------------------------------------------------------------------
/packages/autofe-serve-index/public/icons/page_white_vector.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athm-fe/create-autofe-app/787a340370d98ac16ecf1297ecb8bc699e0f0422/packages/autofe-serve-index/public/icons/page_white_vector.png
--------------------------------------------------------------------------------
/packages/autofe-serve-index/public/icons/page_white_visualstudio.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athm-fe/create-autofe-app/787a340370d98ac16ecf1297ecb8bc699e0f0422/packages/autofe-serve-index/public/icons/page_white_visualstudio.png
--------------------------------------------------------------------------------
/packages/autofe-serve-index/public/icons/page_white_width.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athm-fe/create-autofe-app/787a340370d98ac16ecf1297ecb8bc699e0f0422/packages/autofe-serve-index/public/icons/page_white_width.png
--------------------------------------------------------------------------------
/packages/autofe-serve-index/public/icons/page_white_word.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athm-fe/create-autofe-app/787a340370d98ac16ecf1297ecb8bc699e0f0422/packages/autofe-serve-index/public/icons/page_white_word.png
--------------------------------------------------------------------------------
/packages/autofe-serve-index/public/icons/page_white_world.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athm-fe/create-autofe-app/787a340370d98ac16ecf1297ecb8bc699e0f0422/packages/autofe-serve-index/public/icons/page_white_world.png
--------------------------------------------------------------------------------
/packages/autofe-serve-index/public/icons/page_white_wrench.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athm-fe/create-autofe-app/787a340370d98ac16ecf1297ecb8bc699e0f0422/packages/autofe-serve-index/public/icons/page_white_wrench.png
--------------------------------------------------------------------------------
/packages/autofe-serve-index/public/icons/page_white_zip.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athm-fe/create-autofe-app/787a340370d98ac16ecf1297ecb8bc699e0f0422/packages/autofe-serve-index/public/icons/page_white_zip.png
--------------------------------------------------------------------------------
/packages/autofe-serve-index/public/icons/page_word.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athm-fe/create-autofe-app/787a340370d98ac16ecf1297ecb8bc699e0f0422/packages/autofe-serve-index/public/icons/page_word.png
--------------------------------------------------------------------------------
/packages/autofe-serve-index/public/icons/page_world.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athm-fe/create-autofe-app/787a340370d98ac16ecf1297ecb8bc699e0f0422/packages/autofe-serve-index/public/icons/page_world.png
--------------------------------------------------------------------------------
/packages/autofe-shared-utils/.gitignore:
--------------------------------------------------------------------------------
1 | .idea/
2 | .vscode/
3 | node_modules/
4 | .DS_Store
5 | npm-debug.log*
6 | yarn-debug.log*
7 | yarn-error.log*
8 | package-lock.json
9 | yarn.lock
10 |
--------------------------------------------------------------------------------
/packages/autofe-shared-utils/README.md:
--------------------------------------------------------------------------------
1 | # autofe-shared-utils
2 |
--------------------------------------------------------------------------------
/packages/autofe-shared-utils/index.js:
--------------------------------------------------------------------------------
1 | // [
2 | // 'env',
3 | // 'exit',
4 | // 'ipc',
5 | // 'logger',
6 | // 'module',
7 | // 'object',
8 | // 'openBrowser',
9 | // 'pluginResolution',
10 | // 'launch',
11 | // 'request',
12 | // 'spinner',
13 | // 'validate'
14 | // ].forEach(m => {
15 | // Object.assign(exports, require(`./lib/${m}`))
16 | // });
17 |
18 | function getChromeName() {
19 | let chromeName = 'google chrome';
20 |
21 | if (process.platform === 'darwin') {
22 | chromeName = 'google chrome';
23 | } else if (process.platform === 'linux') {
24 | chromeName = 'google-chrome';
25 | } else if (process.platform === 'win32') {
26 | chromeName = 'chrome';
27 | }
28 |
29 | return chromeName;
30 | }
31 |
32 | exports.getChromeName = getChromeName;
33 | exports.CssUrlRelativePlugin = require('./lib/css-url-relative-plugin');
34 | exports.OmitJsForCssOnlyPlugin = require('./lib/omit-js-for-css-only-plugin');
35 |
--------------------------------------------------------------------------------
/packages/autofe-shared-utils/lib/css-url-relative-plugin/css-replace.js:
--------------------------------------------------------------------------------
1 | /*
2 | MIT License http://www.opensource.org/licenses/mit-license.php
3 | Author yibn2008
4 | */
5 | 'use strict'
6 |
7 | const parseImport = require('parse-import')
8 |
9 | const COMMENT_RULE = /\/\*([\s\S]*?)\*\//g
10 | const RESOLVE_RULE = /@import\s+[^;]*;|url\(([^)]*)\)/g
11 |
12 | /**
13 | * resolve @import and url(...)
14 | *
15 | * @param {String} content
16 | * @param {Function} replacer
17 | */
18 | function cssReplace (content, replacer) {
19 | // replace all comments to comment mark /*{ID}*/
20 | const comments = []
21 | content = content.replace(COMMENT_RULE, (comment) => {
22 | const id = comments.length
23 | comments.push(comment)
24 | return `/*${id}*/`
25 | })
26 |
27 | // replace @import with replacer
28 | content = content.replace(RESOLVE_RULE, (statement, urlPath) => {
29 | if (statement.startsWith('@import')) {
30 | // remove possible comments
31 | statement = statement.replace(COMMENT_RULE, '')
32 |
33 | const parsed = parseImport(statement)
34 | if (!parsed.length) {
35 | throw new Error(`parse rule ${statement} failed`)
36 | }
37 |
38 | /**
39 | * parsed[0]: {
40 | * path: 'foobar.css',
41 | * condition: 'print',
42 | * rule: '@import url("foobar.css") print'
43 | * }
44 | */
45 | return replacer(Object.assign({
46 | type: 'import'
47 | }, parsed[0]))
48 | } else {
49 | // remove possible comments
50 | urlPath = urlPath.replace(COMMENT_RULE, '').trim()
51 |
52 | const clearPath = urlPath.replace(/['"]/g, '')
53 |
54 | return replacer({
55 | type: 'url',
56 | path: clearPath,
57 | condition: '',
58 | rule: `url(${urlPath})`
59 | })
60 | }
61 | })
62 |
63 | // replace back from comment mark to real comment
64 | content = content.replace(COMMENT_RULE, (comment, id) => {
65 | return comments[id | 0]
66 | })
67 |
68 | return content
69 | }
70 |
71 | module.exports = cssReplace
72 |
--------------------------------------------------------------------------------
/packages/autofe-shared-utils/lib/omit-js-for-css-only-plugin/another.js:
--------------------------------------------------------------------------------
1 | /**
2 | * OmitJSforCSSPlugin
3 | * @description : This plugin will omit bundled JS files, for dependencies that are exclusively CSS which become obsolete once extract-text-plugin extracts inlined CSS into its own .css file
4 | */
5 |
6 | /**
7 | * @param {Object} options - Configurable options
8 | * @constructor
9 | */
10 | function OmitJSforCSSPlugin(options) {
11 | const defaults = {
12 | preview: false, // OPTIONAL - {Boolean} - A preview of the files that are to be omitted (Will not actually omit)
13 | verbose: false // OPTIONAL - {Boolean} - Whether it should display which files will be omitted
14 | };
15 |
16 | if ((typeof options !== 'undefined' && (options === null || typeof options !== 'object')) || Array.isArray(options)) {
17 | throw new Error('OmitJSforCSSPlugin only takes an options "object" as an argument');
18 | }
19 |
20 | this.options = Object.assign({}, defaults, options || {});
21 | }
22 |
23 | /**
24 | * @function omitFiles
25 | * @param {Object} omitted - The omitted file's details
26 | * @param {Object} compilation
27 | */
28 | OmitJSforCSSPlugin.prototype.omitFiles = function (omitted, compilation) {
29 | if (this.options.preview) {
30 | console.log(`PREVIEW File to be omitted for ${omitted.chunkName} : ${omitted.filename}`);
31 | } else {
32 | this.options.verbose && console.log(`File omitted for ${omitted.chunkName} : ${omitted.filename}`);
33 | delete compilation.assets[omitted.filename];
34 | }
35 | };
36 |
37 | /**
38 | * @function findOmissibleFiles
39 | * @param {Object} compilation
40 | */
41 | /**
42 | * @function findOmissibleFiles
43 | * @param {Object} compilation
44 | */
45 | OmitJSforCSSPlugin.prototype.findOmissibleFiles = function (compilation) {
46 | // Every chunk / entry point
47 | compilation.chunks.forEach(chunk => {
48 | let resourceOrigin = {};
49 | let assetTypeCount = { internal: 0, css: 0 };
50 |
51 | if (chunk.entryModule) {
52 | resourceOrigin[chunk.entryModule.resource] = true;
53 | }
54 |
55 | // Each entry point will have its own dependencies, based on the files inner deps or the array deps in entry
56 | Array.from(chunk.modulesIterable, module => {
57 | module.dependencies.forEach(({ module }) => {
58 | if (module) {
59 | const { resource } = module;
60 | if (resource && !resourceOrigin[resource]) {
61 | /\.(css|less|scss|sass)$/i.test(resource) ? assetTypeCount.css++ : assetTypeCount.internal++;
62 | }
63 | }
64 | });
65 | });
66 |
67 | // Get the filenames that will be emitted, generated by the chunk, and omit JS if applicable
68 | chunk.files.forEach(filename => {
69 | // If all dependencies of this entry were CSS, then a JS version of this file will be created
70 | // This js file will be empty due to extract-text-webpack-plugin
71 | if (assetTypeCount.css > 0 && assetTypeCount.internal === 0 && (/\.(js)$/i.test(filename) || /\.(js).map$/i.test(filename))) {
72 | let omitted = {
73 | filename: filename,
74 | chunkName: chunk.name
75 | };
76 |
77 | this.omitFiles(omitted, compilation);
78 | }
79 | });
80 | });
81 | };
82 |
83 | /**
84 | * Hook into the webpack compiler
85 | * @param {Object} compiler - The webpack compiler object
86 | */
87 | OmitJSforCSSPlugin.prototype.apply = function (compiler) {
88 | compiler.hooks.emit.tap('OmitJSforCSSPlugin', (compilation) => {
89 | this.findOmissibleFiles(compilation);
90 | });
91 | };
92 |
93 | module.exports = OmitJSforCSSPlugin;
94 |
--------------------------------------------------------------------------------
/packages/autofe-shared-utils/lib/omit-js-for-css-only-plugin/index.js:
--------------------------------------------------------------------------------
1 | const _collectedModules = [];
2 |
3 | class OmitJsForCssOnlyPlugin {
4 | constructor(options) {
5 | _collectedModules.length = 0;
6 |
7 | this.options = Object.assign({
8 | extensions: ["less", "scss", "css"],
9 | ignore: undefined,
10 | }, options);
11 | }
12 |
13 | apply(compiler) {
14 | const plugin = { name: this.constructor.name };
15 |
16 | const extensionsWithoutDots = this.options.extensions.map(e =>
17 | e[0] === "." ? e.substring(1) : e
18 | );
19 |
20 | const patternOneOfExtensions = extensionsWithoutDots
21 | .map(ext => escapeRegExp(ext))
22 | .join("|");
23 |
24 | const reStylesResource = new RegExp(
25 | `[.](${patternOneOfExtensions})([?].*)?$`
26 | );
27 |
28 | compiler.hooks.compilation.tap(plugin, compilation => {
29 | compilation.hooks.chunkAsset.tap(plugin, (chunk, file) => {
30 | if (!file.endsWith(".js") && !file.endsWith(".mjs")) {
31 | return;
32 | }
33 | if (!chunk.hasEntryModule()) {
34 | return;
35 | }
36 |
37 | const rawResources = collectEntryResources(chunk.entryModule);
38 | const resources = this.options.ignore
39 | ? rawResources.filter(r => !r.match(this.options.ignore))
40 | : rawResources;
41 |
42 | const isStyleOnly =
43 | resources.length &&
44 | resources.every(resource => reStylesResource.test(resource));
45 | if (isStyleOnly) {
46 | chunk.files = chunk.files.filter(f => f != file);
47 | delete compilation.assets[file];
48 | }
49 | });
50 | });
51 | }
52 | }
53 |
54 | function collectEntryResources(module, level = 0) {
55 | if (typeof module.resource == "string") {
56 | return [module.resource];
57 | }
58 |
59 | const resources = [];
60 | if (module.dependencies) {
61 | module.dependencies.forEach(dep => {
62 | if (dep && (dep.module || dep.originModule)) {
63 | const nextModule = dep.module || dep.originModule;
64 | if (_collectedModules.indexOf(nextModule.id) === -1) {
65 | _collectedModules.push(nextModule.id);
66 | const depResources = collectEntryResources(nextModule, level + 1);
67 | Array.prototype.push.apply(resources, depResources);
68 | }
69 | }
70 | });
71 | }
72 |
73 | return resources;
74 | }
75 |
76 | // https://github.com/lodash/lodash/blob/4.17.11/lodash.js#L14274
77 | const reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
78 | const reHasRegExpChar = RegExp(reRegExpChar.source);
79 | function escapeRegExp(string) {
80 | string = String(string);
81 | return string && reHasRegExpChar.test(string)
82 | ? string.replace(reRegExpChar, "\\$&")
83 | : string;
84 | }
85 |
86 | module.exports = OmitJsForCssOnlyPlugin;
87 |
--------------------------------------------------------------------------------
/packages/autofe-shared-utils/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "autofe-shared-utils",
3 | "version": "0.1.2",
4 | "description": "shared utilities for Create AutoFE App",
5 | "license": "MIT",
6 | "repository": "athm-fe/create-autofe-app",
7 | "author": "jpuncle",
8 | "engines": {
9 | "node": ">=8"
10 | },
11 | "bugs": {
12 | "url": "https://github.com/athm-fe/create-autofe-app/issues"
13 | },
14 | "scripts": {
15 | "test": "echo \"Error: no test specified\" && exit 1"
16 | },
17 | "dependencies": {
18 | "loader-utils": "^1.2.3",
19 | "parse-import": "^2.0.0",
20 | "webpack-sources": "^1.4.3"
21 | },
22 | "keywords": [
23 | "webpack",
24 | "autofe"
25 | ]
26 | }
27 |
--------------------------------------------------------------------------------
/packages/autofe-webpack/.gitignore:
--------------------------------------------------------------------------------
1 | .idea/
2 | .vscode/
3 | node_modules/
4 | .DS_Store
5 | npm-debug.log*
6 | yarn-debug.log*
7 | yarn-error.log*
8 | package-lock.json
9 | yarn.lock
10 |
--------------------------------------------------------------------------------
/packages/autofe-webpack/README.md:
--------------------------------------------------------------------------------
1 | # autofe-webpack
2 |
3 | **Deprecated**, please see `autofe-shared-utils`
--------------------------------------------------------------------------------
/packages/autofe-webpack/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "autofe-webpack",
3 | "version": "0.1.2",
4 | "description": "The webpack tools for autofe",
5 | "license": "MIT",
6 | "repository": "athm-fe/create-autofe-app",
7 | "author": "jpuncle",
8 | "main": "src/index.js",
9 | "engines": {
10 | "node": ">=8"
11 | },
12 | "bugs": {
13 | "url": "https://github.com/athm-fe/create-autofe-app/issues"
14 | },
15 | "scripts": {
16 | "test": "echo \"Error: no test specified\" && exit 1"
17 | },
18 | "dependencies": {
19 | "loader-utils": "^1.2.3",
20 | "parse-import": "^2.0.0",
21 | "webpack-sources": "^1.4.3"
22 | },
23 | "keywords": [
24 | "webpack",
25 | "autofe"
26 | ]
27 | }
28 |
--------------------------------------------------------------------------------
/packages/autofe-webpack/src/css-url-relative-plugin/css-replace.js:
--------------------------------------------------------------------------------
1 | /*
2 | MIT License http://www.opensource.org/licenses/mit-license.php
3 | Author yibn2008
4 | */
5 | 'use strict'
6 |
7 | const parseImport = require('parse-import')
8 |
9 | const COMMENT_RULE = /\/\*([\s\S]*?)\*\//g
10 | const RESOLVE_RULE = /@import\s+[^;]*;|url\(([^)]*)\)/g
11 |
12 | /**
13 | * resolve @import and url(...)
14 | *
15 | * @param {String} content
16 | * @param {Function} replacer
17 | */
18 | function cssReplace (content, replacer) {
19 | // replace all comments to comment mark /*{ID}*/
20 | const comments = []
21 | content = content.replace(COMMENT_RULE, (comment) => {
22 | const id = comments.length
23 | comments.push(comment)
24 | return `/*${id}*/`
25 | })
26 |
27 | // replace @import with replacer
28 | content = content.replace(RESOLVE_RULE, (statement, urlPath) => {
29 | if (statement.startsWith('@import')) {
30 | // remove possible comments
31 | statement = statement.replace(COMMENT_RULE, '')
32 |
33 | const parsed = parseImport(statement)
34 | if (!parsed.length) {
35 | throw new Error(`parse rule ${statement} failed`)
36 | }
37 |
38 | /**
39 | * parsed[0]: {
40 | * path: 'foobar.css',
41 | * condition: 'print',
42 | * rule: '@import url("foobar.css") print'
43 | * }
44 | */
45 | return replacer(Object.assign({
46 | type: 'import'
47 | }, parsed[0]))
48 | } else {
49 | // remove possible comments
50 | urlPath = urlPath.replace(COMMENT_RULE, '').trim()
51 |
52 | const clearPath = urlPath.replace(/['"]/g, '')
53 |
54 | return replacer({
55 | type: 'url',
56 | path: clearPath,
57 | condition: '',
58 | rule: `url(${urlPath})`
59 | })
60 | }
61 | })
62 |
63 | // replace back from comment mark to real comment
64 | content = content.replace(COMMENT_RULE, (comment, id) => {
65 | return comments[id | 0]
66 | })
67 |
68 | return content
69 | }
70 |
71 | module.exports = cssReplace
72 |
--------------------------------------------------------------------------------
/packages/autofe-webpack/src/index.js:
--------------------------------------------------------------------------------
1 | throw new Error('**Deprecated**, please see autofe-shared-utils');
2 |
--------------------------------------------------------------------------------
/packages/autofe-webpack/src/omit-js-for-css-only-plugin/another.js:
--------------------------------------------------------------------------------
1 | /**
2 | * OmitJSforCSSPlugin
3 | * @description : This plugin will omit bundled JS files, for dependencies that are exclusively CSS which become obsolete once extract-text-plugin extracts inlined CSS into its own .css file
4 | */
5 |
6 | /**
7 | * @param {Object} options - Configurable options
8 | * @constructor
9 | */
10 | function OmitJSforCSSPlugin(options) {
11 | const defaults = {
12 | preview: false, // OPTIONAL - {Boolean} - A preview of the files that are to be omitted (Will not actually omit)
13 | verbose: false // OPTIONAL - {Boolean} - Whether it should display which files will be omitted
14 | };
15 |
16 | if ((typeof options !== 'undefined' && (options === null || typeof options !== 'object')) || Array.isArray(options)) {
17 | throw new Error('OmitJSforCSSPlugin only takes an options "object" as an argument');
18 | }
19 |
20 | this.options = Object.assign({}, defaults, options || {});
21 | }
22 |
23 | /**
24 | * @function omitFiles
25 | * @param {Object} omitted - The omitted file's details
26 | * @param {Object} compilation
27 | */
28 | OmitJSforCSSPlugin.prototype.omitFiles = function (omitted, compilation) {
29 | if (this.options.preview) {
30 | console.log(`PREVIEW File to be omitted for ${omitted.chunkName} : ${omitted.filename}`);
31 | } else {
32 | this.options.verbose && console.log(`File omitted for ${omitted.chunkName} : ${omitted.filename}`);
33 | delete compilation.assets[omitted.filename];
34 | }
35 | };
36 |
37 | /**
38 | * @function findOmissibleFiles
39 | * @param {Object} compilation
40 | */
41 | /**
42 | * @function findOmissibleFiles
43 | * @param {Object} compilation
44 | */
45 | OmitJSforCSSPlugin.prototype.findOmissibleFiles = function (compilation) {
46 | // Every chunk / entry point
47 | compilation.chunks.forEach(chunk => {
48 | let resourceOrigin = {};
49 | let assetTypeCount = { internal: 0, css: 0 };
50 |
51 | if (chunk.entryModule) {
52 | resourceOrigin[chunk.entryModule.resource] = true;
53 | }
54 |
55 | // Each entry point will have its own dependencies, based on the files inner deps or the array deps in entry
56 | Array.from(chunk.modulesIterable, module => {
57 | module.dependencies.forEach(({ module }) => {
58 | if (module) {
59 | const { resource } = module;
60 | if (resource && !resourceOrigin[resource]) {
61 | /\.(css|less|scss|sass)$/i.test(resource) ? assetTypeCount.css++ : assetTypeCount.internal++;
62 | }
63 | }
64 | });
65 | });
66 |
67 | // Get the filenames that will be emitted, generated by the chunk, and omit JS if applicable
68 | chunk.files.forEach(filename => {
69 | // If all dependencies of this entry were CSS, then a JS version of this file will be created
70 | // This js file will be empty due to extract-text-webpack-plugin
71 | if (assetTypeCount.css > 0 && assetTypeCount.internal === 0 && (/\.(js)$/i.test(filename) || /\.(js).map$/i.test(filename))) {
72 | let omitted = {
73 | filename: filename,
74 | chunkName: chunk.name
75 | };
76 |
77 | this.omitFiles(omitted, compilation);
78 | }
79 | });
80 | });
81 | };
82 |
83 | /**
84 | * Hook into the webpack compiler
85 | * @param {Object} compiler - The webpack compiler object
86 | */
87 | OmitJSforCSSPlugin.prototype.apply = function (compiler) {
88 | compiler.hooks.emit.tap('OmitJSforCSSPlugin', (compilation) => {
89 | this.findOmissibleFiles(compilation);
90 | });
91 | };
92 |
93 | module.exports = OmitJSforCSSPlugin;
94 |
--------------------------------------------------------------------------------
/packages/autofe-webpack/src/omit-js-for-css-only-plugin/index.js:
--------------------------------------------------------------------------------
1 | const _collectedModules = [];
2 |
3 | class OmitJsForCssOnlyPlugin {
4 | constructor(options) {
5 | _collectedModules.length = 0;
6 |
7 | this.options = Object.assign({
8 | extensions: ["less", "scss", "css"],
9 | ignore: undefined,
10 | }, options);
11 | }
12 |
13 | apply(compiler) {
14 | const plugin = { name: this.constructor.name };
15 |
16 | const extensionsWithoutDots = this.options.extensions.map(e =>
17 | e[0] === "." ? e.substring(1) : e
18 | );
19 |
20 | const patternOneOfExtensions = extensionsWithoutDots
21 | .map(ext => escapeRegExp(ext))
22 | .join("|");
23 |
24 | const reStylesResource = new RegExp(
25 | `[.](${patternOneOfExtensions})([?].*)?$`
26 | );
27 |
28 | compiler.hooks.compilation.tap(plugin, compilation => {
29 | compilation.hooks.chunkAsset.tap(plugin, (chunk, file) => {
30 | if (!file.endsWith(".js") && !file.endsWith(".mjs")) {
31 | return;
32 | }
33 | if (!chunk.hasEntryModule()) {
34 | return;
35 | }
36 |
37 | const rawResources = collectEntryResources(chunk.entryModule);
38 | const resources = this.options.ignore
39 | ? rawResources.filter(r => !r.match(this.options.ignore))
40 | : rawResources;
41 |
42 | const isStyleOnly =
43 | resources.length &&
44 | resources.every(resource => reStylesResource.test(resource));
45 | if (isStyleOnly) {
46 | chunk.files = chunk.files.filter(f => f != file);
47 | delete compilation.assets[file];
48 | }
49 | });
50 | });
51 | }
52 | }
53 |
54 | function collectEntryResources(module, level = 0) {
55 | if (typeof module.resource == "string") {
56 | return [module.resource];
57 | }
58 |
59 | const resources = [];
60 | if (module.dependencies) {
61 | module.dependencies.forEach(dep => {
62 | if (dep && (dep.module || dep.originModule)) {
63 | const nextModule = dep.module || dep.originModule;
64 | if (_collectedModules.indexOf(nextModule.id) === -1) {
65 | _collectedModules.push(nextModule.id);
66 | const depResources = collectEntryResources(nextModule, level + 1);
67 | Array.prototype.push.apply(resources, depResources);
68 | }
69 | }
70 | });
71 | }
72 |
73 | return resources;
74 | }
75 |
76 | // https://github.com/lodash/lodash/blob/4.17.11/lodash.js#L14274
77 | const reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
78 | const reHasRegExpChar = RegExp(reRegExpChar.source);
79 | function escapeRegExp(string) {
80 | string = String(string);
81 | return string && reHasRegExpChar.test(string)
82 | ? string.replace(reRegExpChar, "\\$&")
83 | : string;
84 | }
85 |
86 | module.exports = OmitJsForCssOnlyPlugin;
87 |
--------------------------------------------------------------------------------
/packages/babel-preset-autofe-app/README.md:
--------------------------------------------------------------------------------
1 | # babel-preset-autofe-app
2 |
3 | > A babel preset for transforming your JavaScript for autofe-app.
4 |
5 | > Thanks for [babel-preset-airbnb](https://github.com/airbnb/babel-preset-airbnb).
6 |
7 | Currently contains transforms for all standard syntax that is [stage 4](https://github.com/tc39/ecma262) (ES2018) or [stage 3](https://github.com/tc39/proposals#active-proposals), except for the following:
8 | - [async-to-promises](https://www.npmjs.com/package/babel-plugin-async-to-promises) is not yet complete enough to be safely used
9 | - lifted template literal restrictions: we do not use tagged template literals, nor implement custom DSLs, otherwise we would enable this.
10 |
11 | ## Install
12 |
13 | ```sh
14 | $ npm install --save-dev babel-preset-autofe-app
15 | ```
16 |
17 | ## Usage
18 |
19 | ### Via `.babelrc` (Recommended)
20 |
21 | **.babelrc**
22 |
23 | ```json
24 | {
25 | "presets": ["autofe-app"]
26 | }
27 | ```
28 |
29 | ### Via CLI
30 |
31 | ```sh
32 | $ babel script.js --presets autofe-app
33 | ```
34 |
35 | ### Via Node API
36 |
37 | ```javascript
38 | require("babel-core").transform("code", {
39 | presets: ["autofe-app"]
40 | });
41 | ```
42 |
43 | ### Targeting Environments
44 |
45 | This module uses babel-preset-env to target specific environments.
46 |
47 | Please refer to [babel-preset-env#targets](https://github.com/babel/babel-preset-env#targets) for a list of available options.
48 |
49 | For a list of browsers please see [browserlist](https://github.com/ai/browserslist).
50 |
51 | You may override our default list of targets by providing your own `targets` key.
52 |
53 | ```json
54 | {
55 | "presets": [["autofe-app", {
56 | "targets": {
57 | "chrome": 50,
58 | "explorer": 11,
59 | "firefox": 45
60 | }
61 | }]]
62 | }
63 | ```
64 |
65 | The following transpiles only for Node v6.
66 |
67 | ```json
68 | {
69 | "presets": [["autofe-app", {
70 | "targets": {
71 | "node": 6
72 | }
73 | }]]
74 | }
75 | ```
76 |
77 | If you wish, you can also inherit our default list of browsers and extend them using `additionalTargets`.
78 |
79 | ```json
80 | {
81 | "presets": [["autofe-app", {
82 | "additionalTargets": {
83 | "chrome": 42,
84 | "explorer": 8
85 | }
86 | }]]
87 | }
88 | ```
89 |
90 | You may override our default debug option by providing your own `debug` key.
91 |
92 | ```json
93 | {
94 | "presets": [["autofe-app", {
95 | "debug": true
96 | }]]
97 | }
98 | ```
--------------------------------------------------------------------------------
/packages/babel-preset-autofe-app/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "babel-preset-autofe-app",
3 | "version": "2.1.1",
4 | "description": "Babel preset used by AutoFE apps",
5 | "repository": "athm-fe/create-autofe-app",
6 | "author": "jpuncle",
7 | "engines": {
8 | "node": ">=8"
9 | },
10 | "bugs": {
11 | "url": "https://github.com/athm-fe/create-autofe-app/issues"
12 | },
13 | "files": [
14 | "index.js"
15 | ],
16 | "dependencies": {
17 | "@babel/core": "^7.15.8",
18 | "@babel/plugin-proposal-class-properties": "^7.14.5",
19 | "@babel/plugin-proposal-object-rest-spread": "^7.15.6",
20 | "@babel/plugin-proposal-private-methods": "^7.14.5",
21 | "@babel/plugin-proposal-private-property-in-object": "^7.15.4",
22 | "@babel/plugin-transform-classes": "^7.15.4",
23 | "@babel/plugin-transform-computed-properties": "^7.14.5",
24 | "@babel/plugin-transform-member-expression-literals": "^7.14.5",
25 | "@babel/plugin-transform-property-literals": "^7.14.5",
26 | "@babel/plugin-transform-property-mutators": "^7.14.5",
27 | "@babel/plugin-transform-runtime": "^7.15.8",
28 | "@babel/preset-env": "^7.15.8",
29 | "@babel/runtime": "^7.15.4",
30 | "core-js": "^3.18.3",
31 | "regenerator-runtime": "^0.13.9"
32 | },
33 | "peerDependencies": {
34 | "@babel/runtime": "^7.15.4"
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/packages/create-autofe-app/README.md:
--------------------------------------------------------------------------------
1 | # create-autofe-app
2 |
3 | ``` sh
4 | npx create-autofe-app my-app
5 |
6 | cd my-app
7 | npm start
8 | ```
9 |
10 | [Full Docs](https://athm-fe.github.io/create-autofe-app/)
11 |
--------------------------------------------------------------------------------
/packages/create-autofe-app/index.js:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env node
2 |
3 | /**
4 | * Copyright (c) 2015-present, Facebook, Inc.
5 | * All rights reserved.
6 | *
7 | * This source code is licensed under the BSD-style license found in the
8 | * LICENSE file in the root directory of this source tree. An additional grant
9 | * of patent rights can be found in the PATENTS file in the same directory.
10 | */
11 |
12 | // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
13 | // /!\ DO NOT MODIFY THIS FILE /!\
14 | // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15 | //
16 | // create-react-app is installed globally on people's computers. This means
17 | // that it is extremely difficult to have them upgrade the version and
18 | // because there's only one global version installed, it is very prone to
19 | // breaking changes.
20 | //
21 | // The only job of create-react-app is to init the repository and then
22 | // forward all the commands to the local version of create-react-app.
23 | //
24 | // If you need to add a new command, please add it to the scripts/ folder.
25 | //
26 | // The only reason to modify this file is to add more warnings and
27 | // troubleshooting information for the `create-react-app` command.
28 | //
29 | // Do not make breaking changes! We absolutely don't want to have to
30 | // tell people to update their global version of create-react-app.
31 | //
32 | // Also be careful with new language features.
33 | // This file must work on Node 8+.
34 | //
35 | // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
36 | // /!\ DO NOT MODIFY THIS FILE /!\
37 | // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
38 |
39 | var chalk = require('chalk');
40 |
41 | var currentNodeVersion = process.versions.node;
42 | var semver = currentNodeVersion.split('.');
43 | var major = semver[0];
44 |
45 | if (major < 8) {
46 | console.error(
47 | chalk.red(
48 | 'You are running Node ' +
49 | currentNodeVersion +
50 | '.\n' +
51 | 'Create AutoFE apps requires Node 8 or higher. \n' +
52 | 'Please update your version of Node.'
53 | )
54 | );
55 | process.exit(1);
56 | }
57 |
58 | require('./createApp');
59 |
--------------------------------------------------------------------------------
/packages/create-autofe-app/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "create-autofe-app",
3 | "version": "0.6.4",
4 | "description": "Create AutoFE apps with no build configuration.",
5 | "repository": "athm-fe/create-autofe-app",
6 | "author": "jpuncle",
7 | "engines": {
8 | "node": ">=8"
9 | },
10 | "bugs": {
11 | "url": "https://github.com/athm-fe/create-autofe-app/issues"
12 | },
13 | "files": [
14 | "index.js",
15 | "createApp.js"
16 | ],
17 | "bin": {
18 | "create-autofe-app": "./index.js"
19 | },
20 | "dependencies": {
21 | "chalk": "^2.4.1",
22 | "commander": "^2.16.0",
23 | "cross-spawn": "^6.0.5",
24 | "fs-extra": "^7.0.0",
25 | "semver": "^5.5.0"
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/packages/eslint-config-autofe-app/README.md:
--------------------------------------------------------------------------------
1 | # eslint-config-autofe-app
--------------------------------------------------------------------------------
/packages/eslint-config-autofe-app/index.js:
--------------------------------------------------------------------------------
1 | const customExtends = [
2 | './rules/best-practices',
3 | './rules/errors',
4 | './rules/node',
5 | './rules/style',
6 | './rules/variables',
7 | './rules/es6',
8 | './rules/imports',
9 | ].map(require.resolve);
10 |
11 | // TODO: vue, react, jsx-a11y, react-hooks
12 | // TODO: use https://github.com/AlloyTeam/eslint-config-alloy
13 |
14 | module.exports = {
15 | extends: [
16 | // 'eslint:recommended',
17 | ].concat(customExtends),
18 | env: {
19 | browser: true,
20 | commonjs: true,
21 | amd: true,
22 | es6: true,
23 | node: true,
24 | },
25 | parserOptions: {
26 | ecmaVersion: 2018,
27 | sourceType: 'module',
28 | ecmaFeatures: {
29 | jsx: true,
30 | },
31 | },
32 |
33 | // NOTE: When adding rules here, you need to make sure they are compatible with
34 | // `typescript-eslint`, as some rules such as `no-array-constructor` aren't compatible.
35 | rules: {
36 | strict: 'off',
37 | },
38 | };
39 |
--------------------------------------------------------------------------------
/packages/eslint-config-autofe-app/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "eslint-config-autofe-app",
3 | "version": "1.2.2",
4 | "description": "ESLint configuration used by AutoFE apps",
5 | "repository": "athm-fe/create-autofe-app",
6 | "author": "jpuncle",
7 | "engines": {
8 | "node": ">=8"
9 | },
10 | "bugs": {
11 | "url": "https://github.com/athm-fe/create-autofe-app/issues"
12 | },
13 | "dependencies": {
14 | "confusing-browser-globals": "^1.0.9"
15 | },
16 | "devDependencies": {
17 | "@typescript-eslint/eslint-plugin": "^2.19.0",
18 | "@typescript-eslint/parser": "^2.19.0"
19 | },
20 | "peerDependencies": {
21 | "eslint": "^5.3.0",
22 | "eslint-plugin-import": "^2.13.0"
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/packages/eslint-config-autofe-app/rules/node.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | env: {
3 | node: true
4 | },
5 |
6 | rules: {
7 | // enforce return after a callback
8 | 'callback-return': 'off',
9 |
10 | // require all requires be top-level
11 | // https://eslint.org/docs/rules/global-require
12 | 'global-require': 'error',
13 |
14 | // enforces error handling in callbacks (node environment)
15 | 'handle-callback-err': 'off',
16 |
17 | // disallow use of the Buffer() constructor
18 | // https://eslint.org/docs/rules/no-buffer-constructor
19 | 'no-buffer-constructor': 'error',
20 |
21 | // disallow mixing regular variable and require declarations
22 | 'no-mixed-requires': ['off', false],
23 |
24 | // disallow use of new operator with the require function
25 | 'no-new-require': 'error',
26 |
27 | // disallow string concatenation with __dirname and __filename
28 | // https://eslint.org/docs/rules/no-path-concat
29 | 'no-path-concat': 'error',
30 |
31 | // disallow use of process.env
32 | 'no-process-env': 'off',
33 |
34 | // disallow process.exit()
35 | 'no-process-exit': 'off',
36 |
37 | // restrict usage of specified node modules
38 | 'no-restricted-modules': 'off',
39 |
40 | // disallow use of synchronous methods (off by default)
41 | 'no-sync': 'off',
42 | }
43 | };
44 |
--------------------------------------------------------------------------------
/packages/eslint-config-autofe-app/rules/variables.js:
--------------------------------------------------------------------------------
1 | const confusingBrowserGlobals = require('confusing-browser-globals');
2 |
3 | module.exports = {
4 | rules: {
5 | // enforce or disallow variable initializations at definition
6 | 'init-declarations': 'off',
7 |
8 | // disallow the catch clause parameter name being the same as a variable in the outer scope
9 | 'no-catch-shadow': 'off',
10 |
11 | // disallow deletion of variables
12 | 'no-delete-var': 'error',
13 |
14 | // disallow labels that share a name with a variable
15 | // https://eslint.org/docs/rules/no-label-var
16 | 'no-label-var': 'error',
17 |
18 | // disallow specific globals
19 | 'no-restricted-globals': ['error', 'isFinite', 'isNaN'].concat(confusingBrowserGlobals),
20 |
21 | // disallow declaration of variables already declared in the outer scope
22 | 'no-shadow': 'off',
23 |
24 | // disallow shadowing of names such as arguments
25 | 'no-shadow-restricted-names': 'error',
26 |
27 | // disallow use of undeclared variables unless mentioned in a /*global */ block
28 | 'no-undef': 'error',
29 |
30 | // disallow use of undefined when initializing variables
31 | 'no-undef-init': 'error',
32 |
33 | // disallow use of undefined variable
34 | // https://eslint.org/docs/rules/no-undefined
35 | // TODO: enable?
36 | 'no-undefined': 'off',
37 |
38 | // disallow declaration of variables that are not used in the code
39 | 'no-unused-vars': ['error', { vars: 'all', args: 'after-used', ignoreRestSiblings: true }],
40 |
41 | // disallow use of variables before they are defined
42 | 'no-use-before-define': ['error', { functions: true, classes: true, variables: true }],
43 | }
44 | };
45 |
--------------------------------------------------------------------------------
/tasks/release.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | # Copyright (c) 2015-present, Facebook, Inc.
3 | #
4 | # This source code is licensed under the MIT license found in the
5 | # LICENSE file in the root directory of this source tree.
6 |
7 | # ******************************************************************************
8 | # This releases an update to the `react-scripts` package.
9 | # Don't use `npm publish` for it.
10 | # Read the release instructions:
11 | # https://github.com/facebook/create-react-app/blob/master/CONTRIBUTING.md#cutting-a-release
12 | # ******************************************************************************
13 |
14 | # Start in tasks/ even if run from root directory
15 | cd "$(dirname "$0")"
16 |
17 | # Exit the script on any command with non 0 return code
18 | # We assume that all the commands in the pipeline set their return code
19 | # properly and that we do not need to validate that the output is correct
20 | set -e
21 |
22 | # Echo every command being executed
23 | set -x
24 |
25 | # Go to root
26 | cd ..
27 | root_path=$PWD
28 |
29 | # You can only release with npm >= 3
30 | if [ $(npm -v | head -c 1) -lt 3 ]; then
31 | echo "Releasing requires npm >= 3. Aborting.";
32 | exit 1;
33 | fi;
34 |
35 | if [ -n "$(git status --porcelain)" ]; then
36 | echo "Your git status is not clean. Aborting.";
37 | exit 1;
38 | fi
39 |
40 | cd $root_path
41 | # Go!
42 | ./node_modules/.bin/lerna publish --independent "$@"
43 |
--------------------------------------------------------------------------------
/tasks/releaseDoc.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # Start in tasks/ even if run from root directory
4 | cd "$(dirname "$0")"
5 |
6 | # Exit the script on any command with non 0 return code
7 | # We assume that all the commands in the pipeline set their return code
8 | # properly and that we do not need to validate that the output is correct
9 | set -e
10 |
11 | # Echo every command being executed
12 | set -x
13 |
14 | # Go to root
15 | cd ..
16 |
17 | # build
18 | npm run docs:build
19 |
20 | # navigate into the build output directory
21 | cd docs/.vuepress/dist
22 |
23 | # if you are deploying to a custom domain
24 | # echo 'www.example.com' > CNAME
25 |
26 | git init
27 | git add -A
28 | git commit -m 'deploy'
29 |
30 | # if you are deploying to https://.github.io
31 | # git push -f git@github.com:/.github.io.git master
32 |
33 | # if you are deploying to https://.github.io/
34 | git push -f git@github.com:athm-fe/create-autofe-app.git master:gh-pages
35 |
36 | cd -
--------------------------------------------------------------------------------
/tasks/replace-own-deps.js:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env node
2 | /**
3 | * Copyright (c) 2015-present, Facebook, Inc.
4 | * All rights reserved.
5 | *
6 | * This source code is licensed under the BSD-style license found in the
7 | * LICENSE file in the root directory of this source tree. An additional grant
8 | * of patent rights can be found in the PATENTS file in the same directory.
9 | */
10 | 'use strict';
11 |
12 | // Replaces internal dependencies in package.json with local package paths.
13 |
14 | const fs = require('fs');
15 | const path = require('path');
16 |
17 | const packagesDir = path.join(__dirname, '../packages');
18 | const pkgFilename = path.join(packagesDir, 'autofe-scripts/package.json');
19 | const data = require(pkgFilename);
20 |
21 | fs.readdirSync(packagesDir).forEach((name) => {
22 | if (data.dependencies[name]) {
23 | data.dependencies[name] = 'file:' + path.join(packagesDir, name);
24 | }
25 | });
26 |
27 | fs.writeFile(pkgFilename, JSON.stringify(data, null, 2), 'utf8', (err) => {
28 | if (err) {
29 | throw err;
30 | }
31 | console.log('Replaced local dependencies.');
32 | });
33 |
--------------------------------------------------------------------------------