npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

prince-cli

v0.1.4

Published

automatic tool for h5 SPA development.

Downloads

6

Readme

About prince

license

中文文档

fast & light React SPA mobile tooling.

  • connect Redux.
  • webpack-dev-server provides hot reload.
  • Starting new programe at localhost(local mode); online programe code develop by proxy of localhost(debug mode).
  • page turning animation imitates native app.
  • each page is splited the trunks for router, and connect reducers with global store when it is onloaded.
  • support get、post、jsonp、webSocket mock function, support requesting localhost in the debug mode.

Use command

  1. you should install node.js (v8.0.0+)
  2. use npm install prince-cli -g install prince-cli for global
  3. use prince new myApp create new react SPA app from local template
  4. use prince new myApp -r create new react SPA app from remote(github) template
  5. cd to the pages path and use prince add xxx create a new page(xxx is your page name)
  6. use npm install install packages
  7. use npm run dev:local start local mode
  8. use npm run dev:debug start debug mode
  9. use npm run build create release bundle
  10. use npm test run unit testing

Development rule

########### myApp formation ###########
├── mock
│   ├── mock.api.js         // http mock
│   ├── socket.api.js       // websocket mock
│   └── data
│       ├── mockData.js     // rest mock data
│       └── socketData.js   // websocket mock data
├── script
│   ├── config.js           // environment host config
│   ├── webpack.config.js   // webpack config
│   └── server.js           // local server
├── src
│   ├── common                  // common function
│   │   ├── action              // actions
│   │   ├── assests             // static files
│   │   ├── component           // components
│   │   ├── less                // styles
│   │   ├── reducers            // stores
│   │   └── service             // methods
│   ├── page
│   │   ├── firstPage           // page 1
│   │   │   ├── action              // actions
│   │   │   ├── assests             // static files
│   │   │   ├── component           // components
│   │   │   ├── less                // styles
│   │   │   ├── reducers            // stores
│   │   │   ├── service             // methods
│   │   │   ├── firstPage.test.js   // unit test
│   │   │   └── index.js            // page entry
│   │   ├── secondPage          // page 2   
│   │   └── thirdPage           // page 3
│   └── route
│       ├── router.js           // router core
│       └── config.js           // router config
├── entry.js                // main entry
├── package.json            // npm config
├── .eslintrc               // Eslint config
└── temp.html               // template

Development guide

  • in the path of pages useprince add xxxto create new page template

  • add page routers at route/config.js (you can change the port anyway):exemple static files server:http://localhost:4396 (static files and hot reload) http requests server:http://localhost:4397 (return ajax and jsonp mock request) webSocket server:ws://localhost:4398 (send and push socket mock message)

  • http requests

import { commonService } from '@common/service';
/**
* @description GET,POST,JSONP请求
* @param {string} url request url
* @param {obj} data request data
* @param {obj} options(optional)
*/
commonService.get('/mockGetRest', null, { mock: true }).then(res => {
      console.log('GET response:', res);
});
commonService.post('/mockPostRest', { a: 1 }).then(res => {
      console.log('POST response:', res);
});
commonService.jsonp('/mockJsonpRest', { a: 2 }).then(res => {
      console.log('JSONP response:', res);
});

you can inject{ mock, headers }at the third parameter to get mock server return during debug mode, headersconfig will add custom request headers, if you request url start with http or https, it will use absolute path, otherwise will use relative path.

  • send or push webSocket message
import { commonService } from '@common/service';
/**
* @description subscribe socket message
* @param {string} sign name
* @param {obj} data callback data
*/
commonService.ws.subscribe('lzw', data => {
	//...
});
commonService.ws.send({ a: 3 });

first param of subscribe method define the sign which is confirmed by server side document,common Service create event subscribe for each sign,when the messages are sended to client, it will just trgger the callback that bind the same sign.

  • development and debug data mock

http mock:

const mockData = require('./data/mockData');

const mockApi = new Map();

/**
* @description rest api mock
* @example mockApi.set([method, url, timeout], response);
* @param {string} method api type, support'GET','POST','JSONP'
* @param {string} url api url path
* @param {number} timeout request return delay (optional)
* @param {object} response request return data
*/
mockApi.set(['GET', '/mockGetRest', 2000], mockData.mockGetRest);
mockApi.set(['POST', '/mockPostRest', 200], mockData.mockPostRest);
mockApi.set(['JSONP', '/mockJsonpRest'], mockData.mockJsonpRest);

module.exports = mockApi;

webScoket mock:

const socketData = require('./data/socketData');

const socketApi = new Map();

/**
* @description webSocket msg mock
* @example mockApi.set([type, time], response);
* @param {string} type push message times,'timeout' for once,'interval' for interval
* @param {number} time interval time
* @param {object} response socket push data
*/
socketApi.set(['timeout', 2500], socketData.wzl);
socketApi.set(['interval', 1000 * 20], socketData.lzw);

module.exports = socketApi;
  • page turning
import { commonService } from '@common/service';

commonService.pageJump('push', {
      pathname: '/thirdPage'
});
commonService.pageBack('go', -1);

add turning animation liked native is based on react-router, pageJumpis animate to next page, pageBackis animate previous page, first param of this method is react-router history proto method, and the second param is history method options.

  • common folder content page component actions, reducers, methods needed many times, use path like@common/in the code.
  • debugmode require that you shuold build server side bufore using it, then edit file script/config.js andbuild program. At last commit dist folder to server side.

Developer information

Any questions or suggestions please send e-mail to me: [email protected]