Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

packer-cli

Package Overview
Dependencies
Maintainers
1
Versions
72
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

packer-cli

Full-fledged CLI tool to generate and package library Node modules compliant with Browser and NodeJS. Packer CLI support all modern style, unit test and script transpiler tools.

  • 2.0.9
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3
decreased by-72.73%
Maintainers
1
Weekly downloads
 
Created
Source

Packer CLI travis build license npm version

Full-fledged CLI tool to generate and package library Node modules compliant with Browser and NodeJS. Packer CLI support all modern style, unit test and script transpiler tools.

This project is inspired by Angular CLI

Features

NPM YARN Travis CI Stylus Style Lint Rollup Postcss Mocha LESS Istanbul Handlebars Gulp ES Lint Babel SPDX TS Lint Jasmine Karma SASS Typescript

  • Managed build configuration
  • Encapsulated build process
  • Both NPM and Yarn support
  • Travis CI
  • Typescript and Babel based code transpilation
  • TS Lint based Typescript code analysis
  • ES Lint based Javascript code analysis
  • Style lint based style sheet code analysis
  • Precompiled handlebars templating
  • Support SCSS, SASS, LESS and Stylus and vanilla CSS
  • Post CSS based image inline and auto prefixing
  • Karma unit test runner
  • Jasmine and Mocha unit test frameworks
  • Rollup and Gulp based build process
  • FESM5, FESM2015 and UMD build output
  • Emmit type definitions for typescript projects
  • Ready to publish as Node module
  • Inline and bundle styles
  • Theme packaging
  • Source import path replace
  • Exclude external peer dependencies in bundle
  • Bundle peer dependencies
  • Ignore imports
  • Copy static assets to build dir
  • Library summary banner generation
  • Library dependency license extraction
  • Node CLI project support

Usage

You can simply run the following command in a preferred directory to generate a new project using Packer CLI,

npx packer-cli generate my-library

or

npm install packer-cli -g && packer generate my-library

Then CLI will query questions associated to custom project generation,

# Description about the library
Give us a small description about the library (optional)? Client complient node module

# Name of the library author
Author's name (optional)? Yohan Gomez

# Name of the library author.
Author's email address (optional)? yohan.gz@gmail.com

# Web home page of the library. This must be a valid URL.
Library homepage link (optional)? http://www.my-project.com

# Use typescript transpiler if yes.
Do you want to use typescript? (Y/n) Yes

# Support CSS bundling if yes.  
Do you want style sheet support? (Y/n) Yes

# Style proprocessor to be used. Select none if not required.
What's the style pre processor you want to use?
- scss
- sass
- less
- stylus
- none

# Inline bundle style sheets within bundled script files.
Do you want to inline bundle styles within script? (Y/n) Yes

# Target build process to support browser compliant bundling if yes
Are you building a browser compliant library? Yes

# This options will generate a NodeJS CLI tool project.
Are you building a node CLI project? No

# You can chose from the browser compliant flat bundel formats options list.
What's the build bundle format you want to use? umd
- umd
- amd
- iife
- system

# Custom AMD id can be provided if flat bundle format is UMD or AMD.
What's the AMD id you want to use? (optional) my-lib

# Library namespace will be used when exposing the libray via global scope.
What's the library namespace you want to use? my.lib

# You can chose either Jasmine or Mocha unit test framework.
Which unit test framework do you want to use?
- Jasmine
- Mocha

# Library copyright year will be included in license file.
What is the library copyright year (optional)? 2018

# License type which suould be used.
What's the license you want to use? MIT License
- MIT License
- Apache 2 License
- Mozilla Public License 2.0
- BSD 2-Clause (FreeBSD) License
- BSD 3-Clause (NewBSD) License
- Internet Systems Consortium (ISC) License
- GNU LGPL 3.0 License
- GNU GPL 3.0 License
- Unlicense
- No License

# Use yarn package manager instaid of NPM CLI if true.
Do you want to use yarn as package manager? (Y/n) Yes

Once project is generated and dependencies are installed, you can use the following CLI commands:

# Run project on watch mode
npm run watch

# Production build
npm run build

# Run Style and script lint tasks
npm run lint

# Run style lint task
npm run lint:style

# Run script lint task
npm run lint:script

# Run unit test suite on development envrionemnt watch mode
npm run test

# Run unit test suite on continues integration environment mode
npm run test:ci

# Bump package version and push updated package config
npm version major|monor|patch

# Build project and publish to NPM
npm run release

Generated Project Structure

.
├── /.rpt2_cache/               # TypeScript build cache directory
├── /.tmp/                      # Watch build tempary artifact directory
├── /demo/                      # Demo source content (applicable if serve mode is enabled in config)
│   ├── /build/                 # Build demo page and assets
│   └── /watch/                 # Watch demo page and assets
├── /src/                       # Library source of the project
├── /node_modules/              # Node modules directory
├── /dist/                      # Compiled distribution artifacts directory (Generated by build task).
│   ├── /bundles                # Directory containing bundled artifacts (umd, amd, iife, system).
│   ├── /fesm5                  # Directory coniaining FESM5 artifact.
│   ├── /fesm2015               # Directory coniaining FESM2015 artifact.
│   ├── /styles                 # Directory containing compiled style sheets.
│   ├── /LICENSE                # Project license agreement file.
│   ├── /package.json           # Package.json file with publish artifact specific configuration.
│   └── /README.md              # Package documentation markup file.
├── .banner.hbs                 # Bundle banner template.
├── .editorconfig               # Define and maintain consistent coding styles between different editors and IDEs.
├── .eslintrc.yml               # ES Lint configuration.
├── .gitignore                  # Contains files to be ignored when pushing to git.
├── .packerrc.json              # This file contains library build configuration options.
├── .stylelintrc.json           # Style lint configuration.
├── .travis.yml                 # Travis CI configuration file.
├── karma.conf.js               # This file contains karma unit test runner configuration.
├── LICENSE                     # License agreement file
├── package.json                # NPM configuration and medata.
├── README.md                   # Project documentation markup file.
├── tsconfig.es5.json           # This file contains ES5 typescript compiler options and configuration.
├── tsconfig.es2015.json        # This file contains ES2015 typescript compiler options and configuration.
├── tsconfig.json               # This file contains base typescript compiler options and configuration.
└── tslint.json                 # TS Lint rules for the project.

Build Configuration

Build configuration can be updated after project generation via .packerrc.json.

{
  "namespace": "my.lib",
  "entry": "index.ts",
  "source": "src",
  "dist": {
    "outDir": "dist",
    "stylesDir": "styles",
    "generateFESM5": true,
    "generateFESM2015": true,
    "generateMin": true
  },
  "typescript": true,
  "cliProject": false,
  "styleSupport": true,
  "stylePreprocessor": "scss",
  "watch": {
    "scriptDir": ".tmp",
    "helperDir": "demo/helper",
    "demoDir": "demo/watch",
    "serve": true,
    "port": 4000,
    "open": true
  },
  "copy": [
    "README.md",
    "LICENSE"
  ],
  "flatGlobals": {},
  "esmExternals": [
    "handlebars/runtime"
  ],
  "pathReplacePatterns": [
    {
      "test": "./config/base-config",
      "replace": "./config/replace-config"
    }
  ],
  "ignore": [],
  "assetPaths": [
    "src/assets"
  ],
  "testFramework": "jasmine",
  "bundle": {
    "amd": {
      "define": "",
      "id": "myLib"
    },
    "format": "umd",
    "imageInlineLimit": 1000000,
    "inlineStyle": false
  },
  "license": {
    "banner": true,
    "thirdParty": {
      "includePrivate": false,
      "fileName": "dependencies.txt"
    }
  }
}
ConfigTypeDefinition
namespacestringapplication namespace to be used
entrystringentry typescript file
sourcestringsource directory
dist.outDirstringbuild artifact output directory
dist.stylesDirstringbuild associated stylesheet output directory within out dir
generateFESM5booleanGenerate flat ESM5 module build artifacts
generateFESM2015booleanGenerate flat ESM2015 module build artifacts
generateMinbooleanGenerate flat bundle build minified artifact
typescriptbooleanSet true if library source is in Typescript
stylePreprocessorstringStyle preprocessor can be "scss", "sass", "stylus", "less"
cliProjectbooleanAppend node environment hash bang for CLI projects if true
styleSupportbooleanSupport style preprocessing and linting
watchobjectwatch mode configuration object
watch.scriptDirstringwatch build temp directory
watch.helperDirstringwatch build helper library directory
watch.demoDirstringwatch demo page dir
watch.portnumberwatch server port
watch.servebooleanServe project via browser on watch mode
watch.openbooleanopen browser automatically
copyarray of stringsList of files paths to copy on build.
flatGlobalsobjectflat bundle build global dependencies. Listed will not be treated as externals.
esmExternalsarray of stringESM build external dependencies
pathReplacePatternsarray of objectsImport path replace pattern collection
pathReplacePatterns.teststringPath to find
pathReplacePatterns.replacestringPath to replace
ignorearray of stringsImport paths to ignore with noop implementation
assetPathsarray of stringsList of paths which contains static assets referenced in style sheets
testFrameworkstring"Jasmine" and "Karma" framework options are available
imageInlineLimitnumberInline image if image size is less than specified limit
bundleobjectBuild bundle associated configuration
bundle.amdobjectAMD flat bundle configuration
bundle.amd.definestringAMD flat bundle define function name
bundle.amd.idstringAMD flat bundle module identifier name
bundle.formatstring"umd", "amd", "iife" and "system" flat bundle options are available
bundle.imageInlineLimitnumberSize limit in bytes to inline compile images
bundle.inlineStylebooleanInline bundle styles withing JS code if true
licenseobjectBundle license configuration
license.bannerbooleanInclude inline header banner passed via .banner.hbs template

Contributions

Feel free to open an issue or create a PR

Keywords

FAQs

Package last updated on 19 Oct 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc