Giter Club home page Giter Club logo

san-cli's Introduction

San-CLI

A CLI Tooling based on San.js for rapid development
NPM version Issues License

English | 简体中文

🎉 Features

  • Complete project scaffolding
  • webpack-based with zero configuration
  • Extensible command line and webpack packaging plugins

San CLI takes into account the San ecosystem while trying to achieve universal configuration. At the beginning of the design phase, we aimed to be not limited to the San application scope, but to make a general and customizable front-end development tooling.

📦 Installation

San CLI requires Node.js version 12.13.0 or above (12.13.0+ recommended).

# use npm
npm install -g san-cli
# or use yarn
yarn global add san-cli

If you want to use San CLI only in the project, you can add it to the devDependencies of the project package.json and then use npm-scripts.

After installation, you can view the help information with the following command:

san -h

For more information, visit https://ecomfe.github.io/san-cli.

🤝 Contributing PRs Welcome

San CLI uses Yarn Workspaces for local development.

First clone the project to your computer, then install dependencies:

# install dependencies
yarn

For design details, please read architecture.

🔨 Testing

# test all
yarn test
# or test one specific package
yarn test [packageName]
# such as
yarn test san-cli

🐛 Debug Log

The debug module is used in the San CLI, so if you need to debug or see some information you can use the DEBUG variable. In San CLI, the scope of debug is san-cli:, and common variables include:

  • perf: Output performance log of San CLI itself.
  • babel: Output Babel related configuration.
  • service: Output service layer log.
  • webpack:closeDevtool: Close Devtools and no longer output eval type code. Directly output the packaged code for debugging.
  • webpack:build: Output webpack build related configuration.
  • webpack:serve: Output webpack serve related configuration.
  • webpack:config: Output the final config object of webpack.

📝 Documentation

For detailed documentation, please check the San CLI docs.

🍻 Companions

☀️ License

MIT

san-cli's People

Contributors

clark-t avatar harttle avatar jiangxinge avatar jinzhan avatar justineo avatar kidnes avatar ksky521 avatar leo-me avatar lohoyo avatar luoyimaid avatar rayjune avatar snyk-bot avatar zheeeng avatar zhixinbao avatar zhongkai avatar zttonly avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

san-cli's Issues

[Bug]san-loader在Windows下路径解析错误

版本
san-loader 0.1.1

运行环境:
node: 10.13.0
windows10

描述:

webpack配置如下:

`

module: {

    rules: [
        {
            test: /\.san$/,
            loader: 'san-loader'
        },
        {
            test: /\.js$/,
            loader: 'babel-loader'
        },
         ...
    ]
}

`
然后
webpack-dev-server启动

报错
`
ERROR in ./src/App.san
Module not found: Error: Can't resolve 'F:san-projectsrcApp.san?lang=html&san=&type=template' in 'F:\san-pro
ject\src'
@ ./src/App.san 6:8-86 11:41-49
@ ./src/index.js

ERROR in ./src/App.san
Module not found: Error: Can't resolve 'F:san-projectsrcApp.san?lang=js&san=&type=script' in 'F:\san-project
\src'
@ ./src/App.san 8:4-77 9:4-72 9:4-72 11:33-39
@ ./src/index.js

ERROR in ./src/App.san
Module not found: Error: Can't resolve 'F:san-projectsrcApp.san?lang=less&san=&type=style&index=0' in 'F:\sa
n-project\src'
@ ./src/App.san 3:8-78
@ ./src/index.js
`
正确解析路径应该是 F:\san-project\src\App.san?lang=less&san=&type=style&index=0
在maxos下无此问题存在

组件反解

目前通过san-cli创建的ksky521/san-project的demo项目,如何在首页使用组件反解功能?
单独创建首页写?按照当前的结构我不是很清楚要如何使用该功能

IE11不支持吗

打包IE11无法打开,san框架都不渲染,只有一个<div #app>

[Bug]san-loader与ts-loader一起使用,watch模式下编译报错

Version
san-cli/packages/san-loader版本0.1.1

Describe the bug
实际项目中,.san文件里面的script采用lang="ts"编写,然后ts编译采用ts-loader,开启watch模式的时候,除了第一次编译正常,后面更新代码触发watch重新编译,会报错

使用san-loader里面提供的example例子也可以复现,把babel-loader换成ts-loader,一些.ts文件也会过san-loader,导致编译报错

To Reproduce

1、cd san-cli/packages/san-loader/examples
2、修改src/components/comp-component.san,script添加 lang="ts"
3、修改package.json,build命令添加--watch

"scripts": {
         "start": "http-server -c-1 dist",       
          "build": "webpack --watch"
     }

4、修改webpack.config.js,把.ts的编译从babel-loader换成ts-loader

{
    test: /\.ts$/,
    use: [
          {
               loader: 'ts-loader',
               options: {
                   appendTsSuffixTo: [/\.san$/] // 给.san文件添加.ts后缀
                }
         }
     ]
}

5、在san-loader的lib/loader.js的入口打调试信息,输出文件路径

console.log('san-loader', this.resourcePath);

6、运行npm run build,第一次编译经过的san-loader文件正常,文件再修改一次的时候,触发watch编译,然后经过san-loader的文件就不对了,一些ts文件也会直接过san-loader编译,log如下

san-loader /Users/yuanxueran/Documents/code/baidu/san-cli/packages/san-loader/examples/src/components/ts/comp-simple-ts/index.ts
san-loader /Users/yuanxueran/Documents/code/baidu/san-cli/packages/san-loader/examples/src/components/comp-component.san
san-loader /Users/yuanxueran/Documents/code/baidu/san-cli/packages/san-loader/examples/types/index.d.ts
san-loader /Users/yuanxueran/Documents/code/baidu/san-cli/packages/san-loader/examples/src/components/comp-component.san

Expected behavior.
触发watch编译的时候,ts文件不应该过san-loader才对

[Bug] san remote add

  1. 初次安装san-cli
  2. 通过命令san remote add demo ksky521/san-project 添加别名
  3. 报错 Users/xx/.san/sanrc.json 不存在
    发现安装san-cli后并没有添加.san文件夹以及创建sanrc.json

[Bug] 按照文档通过loaderOptions配置babel-plugin-import按需加载不生效,使用.babelrc则正常

Version
San CLI-0.1.3

Describe the bug
文档配置方式如下,引入santd,样式按需加载不生效,需要手动引入

module.exports = {
    //...
    loaderOptions: {
        babel: {
            plugins: [
                [
                    // @baidu/nano的按需引入
                    require.resolve('babel-plugin-import'),
                    {
                        libraryName: '@baidu/nano',
                        libraryDirectory: 'es',
                        style: true
                    }
                ]
            ]
        }
    }
};

将babel-plugin-import配置放入.babelrc文件中,则可正常按需引入样式

[Bug]部署流程中验证邮箱无法通过:缺失保存邮箱验证数据的临时目录

Version
[email protected]
[email protected]

Describe the bug
在使用--remote远程部署目标开发机时,首先会通过输入的邮箱做身份认证,但会出现如下报错信息,表示读取不到用户目录下的一个文件:

✔ The output directory is ready to be deployed. Duration 35.904/34.204s, Webpack 4.44.1.                                                                           8:55:19 PM
prompt: Enter your email:  
error:   The specified value must be a valid email address.
prompt: Enter your email:  [email protected]

ERROR  ENOENT: no such file or directory, open '/Users/MY_NAME/.deploy-tmp/deploy.json'
......
......

经过debug发现,部署过程中,有一个读取/Users/MY_NAME/.deploy-tmp/目录文件的方法被调用了(方法的位置./node_modules/deploy-files/fsr.js),但是本地却没有这么一个目录

function getTmpFile() {
    return require('os').homedir() + '/.deploy-tmp/deploy.json';
}

参考@baidu/[email protected],@baidu/[email protected],读取的目录是/Users/MY_NAME/.hulk-templates/,因为安装完hulk-cli的同时,这个目录就已经存在了,所以能顺利部署

Expected behavior
san-cli安装时保留一个临时目录/Users/MY_NAME/.deploy-tmp/

san-cli创建的demo,无法使用sass或scss[Bug]

Version
The version of San CLI.
3.0.0
Describe the bug
A clear and concise description of what the bug is.
1、通过san-cli创建demo时(使用的ksky521/san-project ),选择的sass,但是项目建完后,项目的demo中的预制文件后缀是.less
2、创建.san单文件时使用stylelang是scss/sass时无法通过编译,先是提示需要安装Sass-loader,安装完毕后,编译无法通过。

支持pug

.san的template指定lang并添加相应的loader后,san-cli仍旧无法编译通过
是不是现在不支持template的lang属性?vue是可以的
或者有什么需要注意的地方呢?

[Bug]

Version
4.1.0

Describe the bug
San Cli 创建的基础项目,build之后得到的源码并不兼容ie6呀,数据驱动没有生效,组件没法正常显示。但是用CDN引入san.min.js的方式,是兼容ie6的呀。babel默认配置已经是按需引入polyfill了,新建的项目也没有写任何es6+的语法。

To Reproduce
npm run build

[Bug] san-hot-loader

版本
san-loader 0.1.1

运行环境:
node: 10.13.0
windows10

描述:

webpack配置如下:
`

module: {

       rules: [

        {
            test: /\.san$/,
            use: [
                {
                    loader: require.resolve('san-hot-loader')
                },
                {
                    loader: path.resolve(__dirname, 'node_modules/san-hot-loader/index.js'),
                    options: {
                        compileTemplate: 'aPack'
                    }
                }
            ]
        },
        {
            test: /\.js$/,
            use: [
                {
                    loader: 'babel-loader',
                    options: {
                        plugins: [
                            require.resolve('@babel/plugin-proposal-class-properties'),
                            require.resolve('san-hot-loader/lib/babel-plugin')
                        ],
                        presets: [
                            [
                                require.resolve('@babel/preset-env'),
                                {
                                    targets: {
                                        browsers: '> 1%, last 2 versions'
                                    },
                                    modules: false
                                }
                            ]
                        ]
                    }
                }
            ]
        },
        ......
    ]
},
plugins: [
    new SanLoaderPlugin()
]

`
然后
webpack-dev-server启动

报错

ERROR in ./src/App.san 1:0
Module parse failed: Unexpected token (1:0)
File was processed with these loaders:

  • ./node_modules/san-hot-loader/index.js
  • ./node_modules/san-hot-loader/index.js
    You may need an additional loader to handle the result of these loaders.
    @ ./src/index.js 2:0-24 3:14-17

[Bug] css modules

Version
The version of San CLI.
3.0.0
Describe the bug
使用 cli 创建的 demo 项目中, 在 .san 文件中使用 css modules, 启动项目后, 报 css-loader#module not set

san.config.js

chainWebpack: config => {
  config.module.rule('css')
    .test(/\.css$/)
    .oneOf('css-module')
        .resourceQuery(/module/)
        .use('style-loader').loader('style-loader')
            .end()
        .use('css-loader').loader('css-loader')
            .options({
                modules: {
                    localIdentName: '[local]_[hash:base64:5]'
                },
                localsConvention: 'camelCase',
                sourceMap: true
            })
            .end()
        .end()
    .oneOf('css-normal')
        .use('style-loader').loader('style-loader')
            .end()
        .use('css-loader').loader('css-loader')
}

[Bug] Bad character escape sequence (4:123)

版本
0.1.0

运行环境:
node: 10.13.0
windows10

描述:

按照官方文档运行
san int ksky521/san-project

然后
npm install
npm start

报错
ERROR F:\ksky521\san-project\src\pages\index\containers\app.js: unknown: Bad character escape sequence (4:123)
`
2 | if (module.hot) {
3 | var HOT_API =
require('node_modules_san-hot-loader@0.1.1@san-hot-loader\lib\runtime\component-client-api.js');

4 | var HOT_UTILS = require('node_modules_san-hot-loader@0.1.1@san-hot-loader\lib\runtime\utils.js');
| ^
5 |
6 | var SAN_COMPONENT = HOT_UTILS.getExports(module);
7 | if (SAN_COMPONENT.template || SAN_COMPONENT.prototype.template) {
at Parser._raise (node_modules_@[email protected]@@babel\parser\lib\index.js:757:17)
at Parser.raiseWithData (node_modules_@[email protected]@@babel\parser\lib\index.js:750:17)
at Parser.raise (node_modules_@[email protected]@@babel\parser\lib\index.js:744:17)
at Parser.readHexChar (node_modules_@[email protected]@@babel\parser\lib\index.js:8622:14)
at Parser.readCodePoint (node_modules_@[email protected]@@babel\parser\lib\index.js:8423:19)
at Parser.readEscapedChar (node_modules_@[email protected]@@babel\parser\lib\index.js:8549:29)
at Parser.readString (node_modules_@[email protected]@@babel\parser\lib\index.js:8443:21)
at Parser.getTokenFromCode (node_modules_@[email protected]@@babel\parser\lib\index.js:8098:14)
at Parser.nextToken (node_modules_@[email protected]@@babel\parser\lib\index.js:7625:12)
at Parser.next (node_modules_@[email protected]@@babel\parser\lib\index.js:7550:10)
@ ./src/pages/index/index.js 7:34-61
@ multi ./node_modules/_webpack-dev-server@3.11.0@webpack-dev-server/client?http://192.168.0.106:8888/sockjs-node (webpack)/hot/only-dev-server.js ./src/pages/index/index.js
`

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.