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

generator-gyt-vue

v1.0.1

Published

带有一定基础代码的vuejs项目脚手架

Downloads

5

Readme

generator-vue

带有一定基础代码的vuejs项目脚手架

首先按照原始的方式去创建一个理想的项目结构(你意向的项目结构),把需要使用的基础代码全部包含在里面,然后再去封装一个全新的generator用于去生成我们这样一个理想的项目结构。

1.写好基本index.js(class和prompting方法)

2.把模板templates拿过来
有了模板过后需要把项目结构里面一些可能发生变化的地方通过模板引擎的方式去挖坑
(这里只定义了package.json的name)

3.添加writing方法,核心代码:

templates.forEach(item => {
  this.fs.copyTpl(
    this.templatePath(item), 
    this.destinationPath(item), 
    this.answer
  )
})

(尤其注意:copyTpl是this.fs里的方法。其次,是传递3个参数)

4.npm link作为本地链接
(如果是yarn安装依赖就yarn link)

5.找个空白目录,执行命令yo gyt-vue
(注意:反正就是前缀generator-后面的名称就是了,例如这里的gyt-vue)

6.发布Generator

Generator实际上就是npm模块,发布Generator即发布npm模块

echo node_modules > .gitignore   // 在创建项目之前呢,我们通过gitignore 去忽略一系列文件
git init                        // 初始化空仓库
git status                      // 查看本地仓库状态
git add .                       // 暂存文件
git commit                      // 创建提交

// 在github创建一个项目generator-gyt-vue

git remote add origin <复制的地址>
git push -u origin master       // 把本地master分支的代码推送到远端master分支

// 发布
npm publish                     // 也可以用yarn publish

发布的时候会提示输入版本号和密码等信息。

如果我们使用了国内镜像源,这里的发布就会出现问题,因为大部分国内的镜像,比如淘宝镜像都是只读镜像,我们要修改本地镜像配置或者发布的时候修改--registry=官方的镜像

yarn publish --registry=https://registry-yarnpkg.com  

这里将镜像发布到了npm 和 yarn, 因为yarn和npm是同步的。

有了这个模块,可以通过npm去全局安装,然后通过Yeoman去使用。

注意:如果需要这个generator在官方仓库列表中也会出现的话,可以为这个项目添加一个yeoman-generator的关键词,这个时候,Yeoman的官方就会发现这个项目。