Command Line Interface
WinJS provides many built-in CLI commands for starting and building projects, as well as some development assistance commands such as generators.
To get a list of available commands, you can run the help command in your project directory:
win helpYou should see output similar to the following:
Usage: win <command> [options]Commands: build build app for production config win config cli cache manage win cache dev dev server for development help show commands help info print debugging information about your environment lint lint source code using eslint and stylelint setup setup project see generate possessing by SEE platform ftp FTP uploads local files to the target server deadcode check dead code version show win version v show win version plugin inspect win plugins verify-commit verify the commit message, which is usually used with husky. preview locally preview production build zip compress the package to zip package run run the script commands, support for ts and zx generate generate code snippets quickly g generate code snippets quicklyRun `win help<command>` for more information of specific commands.Visit https://winjs-dev.github.io/winjs-docs/ to learn more about WinJS.For easy reference, the following commands are sorted alphabetically.
build
Builds the project for production deployment.
$ win buildconfig
Quickly view and modify configurations through the command line.
To view configurations, uselist orget.
$ win config list - [key:polyfill] false - [key:externals] { esbuild: true }$ win config get mfsu - [key:externals] { esbuild: true }To modify configurations, useset orremove.
$ win config set polyfill falseset config:polyfill on /private/tmp/sorrycc-wsYpty/.winrc.ts$ win config remove polyfillremove config:polyfill on /private/tmp/sorrycc-wsYpty/.winrc.tscache
WinJS usesnode_modules/.cache as the cache directory. Sometimes you need to manually clear the cache, for example, when you've modified files innode_modules and want to verify the results, or when mf errors can be resolved by clearing the cache. You can execute this command to clear the cache.
$ win cache cleanIt also supports outputting the cache directory tree and size, displaying cache folder information.--depth indicates the optional number of layers, with a default value of 1 layer, where the cache layer is level 0.
Execute the following command:
win cache ls [--depth]info - [wincache] dir info└─ [40.71MB] node_modules/.cache ├─ [16.52MB] bundler-webpack-eager ├─ [166KB] logger ├─ [4.50MB] mfsu └─ [19.53MB] mfsu-depsdeadcode
Used to find unreferenced files in the src directory and output the results to a file in the root directory.
$ win deadcode- Preparing...- begin check deadCode- write file /examples/win-run/DeadCodeList-{timeStamp}.txt- check dead code end, please be careful if you want to remove themdev
Starts the local development server for project development and debugging.
$ win dev ╔═════════════════════════════════════════════════════╗ ║ App listening at: ║ ║ > Local: https://127.0.0.1:8001 ║ready - ║ > Network: https://192.168.1.1:8001 ║ ║ ║ ║ Now you can open browser with the above addresses👆 ║ ╚═════════════════════════════════════════════════════╝event - compiled successfully in 1051 ms (416modules)ftp
Uploads local files to the target server through FTP tools. Usually set inscripts.ftp of package.json.
By default, it reads the ftpOptions property from the.winrc.ts configuration. For specific configuration details, refer toconfiguring ftpOptions.
{ "scripts": { "ftp": "win ftp" }}generate
Used for incremental file generation or enabling features. The command line alias isg.
When run without any parameters, it provides an interactive generator selection.
$ win g# 或$ win generate? Pick generator type › - Use arrow-keys. Return to submit.❯ Create Pages -- Create a win page by page name Enable Tailwind CSS -- Setup Tailwind CSS configuration Enable Uno CSS -- Setup Uno CSS configuration Generate Component -- Generate component boilerplate code Generate mock -- Generate mock boilerplate code Enable E2E Testing with Cypress -- Setup Cypress Configuration Generator api -- Generate api route boilerplate code Generate Precommit -- Generate precommit boilerplate code Generate huipro -- Generate subsystem build tool for hui 1.0 proYou can also specify parameters.
# Generate route files$ win g page index --typescript --lesshelp
Shows help information.
$ win helpUsage: win <command> [options]Commands: build build app for production config win config cli dev dev server for development help show commands help setup setup project see generate possessing by SEE platform version show win version plugin inspect win plugins generate generate code snippets quicklyRun `win help<command>` for more information of specific commands.Visit https://winjs-dev.github.io/winjs-docs/ to learn more about WinJS.You can also specify a command to view detailed help for a specific command.
$ win help buildUsage: win build [options]build app for production.Details: win build # build without compression COMPRESS=none win build # clean and build win build --cleaninfo
Prints debugging information about your environment.
$ win infoUsage: win info System: OS: macOS 11.4 CPU: (8) arm64 Apple M1 Binaries: Node: 18.16.0 - ~/Library/Caches/fnm_multishells/13409_1689559164099/bin/node npm: 9.6.7 - ~/Library/Caches/fnm_multishells/13409_1689559164099/bin/npm Browsers: Chrome: 114.0.5735.198 Edge: Not Found Safari: 14.1.1 npmPackages: vue: Not Found vue-router: Not Found win: workspace:* => 0.0.13 npmGlobalPackages: win: Not Foundlint
Used to check and fix code compliance with rules.
$ win lintUsage: win lint # automatically fix, where possible win lint --fix # disable reporting on warnings win lint --quiet # generate a report win lint --report # scan the directory win lint --include srcmfsu
Thewin mfsu command can view MFSU dependency information, rebuild MFSU dependencies, and clear MFSU dependencies.
Get MFSU command help
$ win mfsuGet MFSU dependency list
$ win mfsu lswarning@0.0.3regenerator-runtime/runtime.js@0.13.11react/jsx-dev-runtime@18.1.0react-intl@3.12.1react-error-overlay/lib/index.js@6.0.9react@18.1.0qiankun@2.8.4lodash/noop@4.17.21lodash/mergeWith@4.17.21lodash/concat@4.17.21...Rebuild MFSU dependencies
$ win mfsu buildinfo - Preparing...info - MFSU eager strategy enabledwarn - Invalidate webpack cache since mfsu cache is missinginfo - [MFSU] buildDeps since cacheDependency has changed...info - [plugin:@winner-fed/preset-win/dist/commands/mfsu/mfsu] [MFSU][eager] build successClear MFSU dependencies
$ # Delete dependency information list$ win mfsu remove$ # Delete dependency information list and build artifacts$ win mfsu remove --allplugin
Plugin-related operations. Currently only supports thelist subcommand.
List all plugins.
$ win plugin list- @winner-fed/core/dist/service/servicePlugin- @winner-fed/preset-win (frompreset)- @winner-fed/preset-win/dist/registerMethods (frompreset)- @winner-fed/preset-win/dist/features/appData/appData (frompreset)- @winner-fed/preset-win/dist/features/check/check (frompreset)- @winner-fed/preset-win/dist/features/configPlugins/configPlugins (frompreset)- virtual: config-styles- virtual: config-scripts- virtual: config-routes- virtual: config-plugins...preview
Thewin preview command starts a local static web server, serving the dist folder athttp://127.0.0.1:4172 to preview build artifacts. It supports proxy, mock, and other settings.
You can configure the service port using the--port parameter.
$ win preview --port 9527Now thepreview command will run the server athttp://127.0.0.1:9527.
Use the--host parameter to specify the hostname for the service.
The following user configurations will also take effect duringpreview:
Note that thedist directory will change according to theoutputPath configuration.
run
Thewin run command allows you to run TypeScript and ESM files just like running JavaScript with node. You can combine it withzx for better script command usage.
$ win run ./script.tssetup
Initializes the project and performs operations such as generating temporary files. Usually set inscripts.postinstall of package.json.
{ "scripts": { "postinstall": "win setup" }}see
Generates SEE platform artifacts from built static resources. Usually set inscripts.see of package.json.
Note
This command only packages existing static resources in the build output directory and does not perform source code compilation.
By default, it reads the seeOptions property from the.winrc.ts configuration. For specific configuration details, refer toconfiguring seeOptions.
{ "scripts": { "see": "win see" }}verify-commit
Verifies commit message information, usually used in combination withhusky.
For example, configure in.husky/commit-msg as follows:
#!/bin/sh. "$(dirname "$0")/_/husky.sh"npx --no-install win verify-commit $1version
View thewin version, equivalent towin -v.
$ win version0.0.3zip
Compresses the specified directory into a zip package. Usually set inscripts.zip of package.json.
By default, it reads the zipOptions property from the.winrc.ts configuration. For specific configuration details, refer toconfiguring zipOptions.
{ "scripts": { "zip": "win zip" }}$ win zipinfo - Win v0.0.4Building examplesample-v1001687759573867.zip...info - Zip successfully! At /Users/liwenbo/Desktop/xxx/winjs/examples/sample/dist-zip/examplesample-v1001687759573867.zip