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

@dao-style/vue-cli-plugin-shared-utils

v0.1.0

Published

封装了一些用于写文件的操作

Downloads

22

Readme

Intro

封装了一些用于写文件的操作

mainInit

用于检测是否存在 plugin,如果不存在,则确定为未初始化的环境,进行 entryFile 的覆盖行为

const mainInit = require("@dao-style/vue-cli-plugin-shared-utils/lib/mainInit");
mainInit(api) // api => generator api

mainImportInit

合并 mainInit 的功能

/**
 * 在 main.[t|j]s 中进行注入,如果不存,则创建并注入
 * @param {api} api
 * @param {string} importFrom: import xxx from '\<importFrom\>';
 * @param {string} defaultImport: import \<defaultImport\> from '\<importFrom\>';
 * @param {string[]} importList: import \<defaultImport\>, { ...\<importList\> } from '\<importFrom\>';
 * @param {string} usedName: app.use
 */

如 plugin 初始化的时候会自动调用该方法,进行创建注入,在 entryFile 中写入 import 与 app.use 的行为

const mainImportInit = require("@dao-style/vue-cli-plugin-shared-utils/lib/mainImportInit");
mainImportInit(api, './plugins', 'pluginInstall', [], 'pluginInstall') // api => generator api

pluginInit

用于检测是否存在 plugin,如果不存在,则确定为未初始化的环境,进行 plugins 目录的创建与启动 mainImportInit

const pluginInit = require("@dao-style/vue-cli-plugin-shared-utils/lib/pluginInit");
pluginInit(api) // api => generator api

pluginImportInit

合并 pluginInit 的行为,用于在 plugins/index 中写入 import 与 export 并在 installl function 中对 plugin 进行安装行为,因此作为方法接受的参数列表如下:

/**
 * 在 plugins/index 中进行注入,如果不存,则创建并注入
 * @param {api} api
 * @param {string} importFrom: import xxx from '\<importFrom\>';
 * @param {string} defaultImport: import \<defaultImport\> from '\<importFrom\>';
 * @param {string[]} importList: import \<defaultImport\>, { ...\<importList\> } from '\<importFrom\>';
 */
const pluginImportInit = require("@dao-style/vue-cli-plugin-shared-utils/lib/pluginImportInit");
pluginImportInit(api, './vue-i18n', 'i18nInstall', ['loadLanguageAsync']) // api => generator api

如上面进行书写会在 plugins/index 进行以下修改

import i18nInstall, { loadLanguageAsync } from './vue-i18n';

// 原本就有
export default function install(app) {
  ...
  app.use(i18nInstall);
// 原本就有
}

// 原本就有
export {
  ...,
  loadLanguageAsync,
// 原本就有
}

utils

生成一条 import 语句 genImport

生成一条具名导出的表达式 genNamedExport

判断某个 目录/文件 是否存在 isTargetExist

检测 src/plugins 目录是否存在 checkPluginExist