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

project-pages-manage

v1.2.0

Published

以小程序目录结构为例: - 所有的页面都位于`pages`目录下 - 所有页面都是一个个独立的文件夹, 在文件夹内包含固定的4个文件, 然后每个文件也许都有些默认的代码、内容 - 创建好文件后还需要去`app.json`目录添加路由

Downloads

10

Readme

背景由来

以小程序目录结构为例:

  • 所有的页面都位于pages目录下
  • 所有页面都是一个个独立的文件夹, 在文件夹内包含固定的4个文件, 然后每个文件也许都有些默认的代码、内容
  • 创建好文件后还需要去app.json目录添加路由

又或者以一个项目为例:

  • 每次的需求开发都要求新建一个项目
  • 这个项目有很多的开发目录及默认的文件 (例: pages, server, tools, gulpfile.js, .gitignore)
  • 在创建的过程中也许其中个别项目有 90% 一致, 仅剩下 10% 不一样

安装

$ sudo npm i project-pages-manage -gd

安装好后会生成主命令proj

使用

页面管理

目前所有命令请在项目的根目录下执行, 否则对 app.json 的操作将无效

  1. 创建页面或目录

基本命令: proj createproj c

$ proj c pagename

在当前路径下创建pagename目录, 并使用默认模版 pages

$ proj c pagename -t normal

在当前路径下创建pagename目录, 并使用模版 normal

当在不同的模版路径下出现同名的模版时, 会提示选择, 并列出模版完整路径

  1. 删除页面或目录

基本命令: proj deleteproj d

$ proj d pagename
  1. 重置页面或目录

基本命令: proj resetproj r

$ proj r pagename

在当前路径下将已经存在的页面或目录pagename以默认模版pages进行重置

$ proj r pagename -t module

在当前路径下将已经存在的页面或目录pagename以模版module进行重置

当在不同的模版路径下出现同名的模版时, 会提示选择, 并列出模版完整路径

模版管理

模版主命令为: proj templateproj t

add 添加模版目录 (将指定模版目录添加至自定义模版路径中 读取模版时将以当前命令执行目录为准查找)

$ proj t add modulename
$ proj t add modulefolder/modulename

add 添加全局自定义模版 (以当前目录为准将指定目录作为模版添加至全局自定义模版)

$ proj t add modulename -g
$ proj t add modulefolder/modulename -g

rm 删除模版配制 (仅删除自定义模版配制路径)

$ proj t rm modulename
$ proj t rm modulefolder/modulename

rm 删除模版配制及本地对应的模版文件

$ proj t rm modulename -d
$ proj t rm modulefolder/modulename -d

rm 删除全局中的自定义模版

$ proj t rm modulename -g
$ proj t rm modulefolder/modulename -g

ls 显示所有的模版配制路径

$ proj t ls

模版文件规则

customModule
    ├─ pages
    |   ├─ somefiles
    |   ├─ somefiles
    |   ├─ ...
    ├─ config.yml
    ├─ script.js
  • customModule

    • 模版名称
  • pages (必需)

    • 目录名称固定
    • 里面存放的是创建模版时需要复制的所有文件
  • config.yml (可选) 当前模版的一些配制信息

    • 内置配制 rename: true
      • 表示以当前模版创建页面后是否将页面内的所有文件名全改成与页面名称一致 (主要针对小程序的目录结构)
  • script.js (可选) 在创建模版时的事件监听

    • 目前仅支持两个监听 onBefore & onAfter
    • 两监听返回的参数一致
      • cmd: 当前命令名称
      • option.modulePath: 当前模版的完整路径
      • option.targetPath: 根据模版创建页面时的目标位置完整路径
      • option.config: 当前模版的配置信息
    • onBefore 中只有 return false; 会中止页面的操作行为
    • onBefore 中如果存在异步行为请使用 await 操作, 否则页面的创建不会等待异步的操作结果

示例:

exports.onBefore = async (cmd, { modulePath, targetPath, config }) => {}

// 返回false会中止命令的执行
exports.onBefore = async (cmd, { modulePath, targetPath, config }) => false

exports.onAfter  = async (cmd, { modulePath, targetPath, config }) => {}

修改默认配制项

基本命令: proj set config key=value

目前config仅有一个配制项允许修改module=pages

- module: 在创建页面时的默认模版


更新历史

v1.2.0

  • 创建页面时增加对分包的配置项操作
  • 创建页面时增加小程序组件模版 proj c pagename -t component

v1.1.0

  • Improve 在复制全局模版时添加 excludes, 比如 node_modules .DS_Store 文件无论如何都是不需要复制的
  • Improve 添加模版时记录执行命令时的完整路径. 创建页面查找模版时增加一种查找方式
    • 指定目录 A 为本地模版目录, 且里面有模版 A/temp1 A/temp2 ...
    • 在目录 B 中创建页面并指定应用模版为 temp1
      • 现有机制会从 全局默认模版目录全局自定义模版目录 本地B目录 中去查找模版 temp1
      • 对于实际操作而言这明显不符合需求
      • 因此记录了 A 目录, 在查找模版时也会从 A 目录中去查找

v1.0.4

  • fix markdown 部分文字错误