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

asset-assistant

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

asset-assistant

**Asset assistant** is a tool for coordinating non-js files across multiple projects. The intended use for copying .css and media files from a project in the *'node_modules'* directory into the projects public html directory.

  • 0.0.10
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

Introduction

Asset assistant is a tool for coordinating non-js files across multiple projects. The intended use for copying .css and media files from a project in the 'node_modules' directory into the projects public html directory.

Versions

The 0.0.* versions are for building up the repository and may have changes in the command specification.

Prerequisites

These programs are intended to be used with the npm package manager. As such they make use of the package.json file and the node_modules directory. All file selections use the Glob package.

Programs

assets

Copy all asset files from source directories and source packages to a specified build directory.

  • The term assets refers to the assets parameter in package.json.
  • The term dependencies refers to the dependencies parameter in package.json.
  1. Require: target project, default root project.
  2. Retrieve assets parameter, if not found, terminate.
  • If this is a top level project it will continue normally without attempting to copy any local files. This is put in place so that dependencies with assets can easily be installed without defining assets in the root.
  1. Copy all files from assets.src into assets.build.
  • assets.src is an array of strings which are interpreted as globs.
  • assets.build is a string which is the root destination of the copy. The copy will preserve the directory structure.
  1. For each project p in dependencies, perform task with target = p.

inline

Add <script> and <link> tags to an html file based upon directory contents.

Quick Start

  1. Install asset manager into a project with npm i asset-manager.
  2. Add "build-assets": "assets -v" to your package.json scripts.
  3. Add assets parameter to package.json. (see ex. 1 below).
  4. The src parameter dictates the sources to always copy. Defaults to empty.
  5. The local-src parameter dictates the sources to copy only if this is the. Defaults to empty.
  6. The dest parameter dictates the target directory, defaults to build/.
  7. The flat parameter when true copies files without the directory structure, defaults to false. root project.
  8. The up parameter defines how many src directories to omit on copy. Defaults to 1 which is the project name directory. This Typically is not modified.
  9. Use npm run build-assets

The typical use case is to copy 'asset' files, such as .css, images, sound, etc. , from a package directory to a directory the deployed application has access to. The root package does not require the 'assets' field, and when ommited will only look in packages for 'asset' files.

The asset command accepts the following flags

  • -v : Verbose, print out packages looked at and files copied.
  • -d : Debug, print out more information.
  • --clean : remove the directory specified by "dest" in the paackage.json assets field. (Default '/build').
  • --fileset=parameter : only copy the local files specified in this parameter ( in the assets parameter).

example 1

In the package.json file (unrequired fields omitted).

"dependencies": {
  "Collection": "file:../Collection",
  "Context": "file:../Context",
  "asset-assistant": "file:D:/project-local/assets",
  "jquery": "^3.3.1",
  "nidget": "file:../Nidget"
},
"scripts": {
  "build-assets": "assets",
  "build-remote": "assets --fileset=local-src",
  "inject-header": "inject src/* src/css/* index.html"
},
"assets": {
  "src": [
    "src/assets/**/*",
    "src/css/dialog.css"
  ],
  "local-src": [
    "src/*.html"
  ]
}

The script 'build-assets' will recursively copy all files in the src/assets directory into the build/src/assets directory. It will also copy 'dialog.css' into the build/css directory. It will then look for the "assets" parameter in the package.json of all dependencies (Collection, Context, etc), if found it will copy files specified by their 'src' parameters and recursively look in their dependencies for more assets. If not found then the recursive search will not follow that branch.

The script 'build-remote' will copy all html files from src/html to build/html, and will not recursive search.

The script 'inject-header' will add a <script> or <link> element into 'index.html' for each .js and .css file found. The paths will be relative to the location of 'index.html'.

Development

Development is setup as a NetBeans project. These are reminders to how the project is setup and is not needed to run it.

  1. Clone repository: git clone git@git.sharcnet.ca:edward/asset-assistant.git.
  2. Install dependencies with npm install in the project root directory.
  3. Publish with npm publish.

Files

The package.json bin parameter specifies where to find command line tools.

  • src/assets.js main entry for asset command line tool as setup in the package.json bin paramater.
  • src/inject.js main entry for css injection command line tool as setup in the package.json bin paramater.
  • src/AbstractAssets Collectes common flags for the CleanAssets and LoadAssets classes.

Keywords

FAQs

Package last updated on 01 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