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

import-index-generator

v0.2.2

Published

Autogenerate a JS modules which exports all the modules present on a directory

Downloads

165

Readme

Import Index Generator

Simple tool which read the content of a directory (without reading the content of its subdirectories) and generates an JS2015 Javascript file which import all those files and has a default export with an array which contains for each file its name and what it exports, because they are assumed to be Javascript module files.

Considerations

This tool has been developed with NodeJS v7 and we don't think to add support for previous versions.

Install

With NPM npm install import-index-generator

With Yarn yarn add import-index-generator

Docs

The tool will show their own help command if your run it without any argument.

If you don't have installed it globally (it's preferable not to so, for the reasons mentioned on yarn docs comemnt), then run ./node_modules/.bin/iigen

You will get the same below message

iigen [-r] [src-dir-path] [output] [list-extensions]

Get the list of the file just contained in the passed source directory path and
generates "index" files which exports a list of objects with the file name
(just the name with the extension but without the path) and the exported stuff.

The [-r] flag indicates to recur the source directory to list all the files on
it and its sub directories. It's optional, hence, by default, the tool doesn't
recur the directory. The flag can be set in any position, it isn't stricly
necessary to appear in the same position written in this help message.

The [ouput] parameter is optional an it's the file path used to write the
generated "index" file, otherwise a temporary file is generated.

The third parameter [list-extensions] is optional and only can be provided if
the [output] parameters is provided; it's a list of file extensions, comma
separated (with no spaces) which are considered to be Javascript modules, js by
default.

The command print out to the stdout the path to the autogenerated "index" file.

Example:
if the list of files in "my-src/components/" directory is
 - module.js
 - auth.vue
 - ignoreme

executing: iigen my-src/components components-index.js js,vue

The command will output in the stdout 'components-index.js' and will generate
such file with the next content:

import * as i0 from './my-src/components/auth.vue'
import * as i1 from './my-src/components/module.js'
export default [{ filename: 'auth.vue', exported: i0 }, { filename: 'module.js', exported: i1 }]


NOTE the tool doens't check the content of the files, so they are assumed to be
wel formatted Javascript modules

Development

Install dependencies npm install or yarn install (recommended).

lint

All the JS code is linted using standard

npm run lint or yarn run lint

Test

npm test or yarn test

License

The MIT License (MIT) Copyright (c) 2017 cycloid.io Read the LICENSE file for more information.