1.2.22082411 • Published 2 years ago

proactive-gulp-pack v1.2.22082411

Weekly downloads
164
License
MIT
Repository
-
Last release
2 years ago

Gulp tasks for packaging both npm and NuGet packages controlled by package.json (and other files)

Usage

Standalone

If this is the only thing you need in gulp then create your gulpfile.js like this:

require("proactive-gulp-pack")();

This will add a 'default' task so you can build the configured packages using

gulp

Gulp project

If you're using Gulp for other things then the recommended way to include packaging is

const gulp = require("gulp"),
      ... // Other requires

require("proactive-gulp-pack")(gulp);

This will add a 'pack:all' task so you can build the configured packages using

gulp pack:all

or by setting "pack:all" as a dependency of any other gulp task.

Advanced

If you need to specify options to the packaging then use the following in the gulpfile.js:

const gulp = require("gulp"),
      ... // Other requires

require("proactive-gulp-pack")(gulp, {
      // Your options
      ...
});

As above you need to invoke 'pack:all' "manually".

Options supported are: ||| |-|-| | additionalNpmFiles | An array of file globs to include in the npm package | |||

Configuration

Package.json

This is of cause the main configuration for your npm package (if any), but should also be used as main configuration of NuGet packages.

The version number in package.json is the one which is:

  • Used to name build
  • Tagged in git (master and release builds only)
  • Automatically incremented to next minor version when released

Should of cause include "proactive-gulp-pack" in devDependencies.

npm content

By default the following is included in the npm package:

[
      "./README.md",
      `./dist/${npmMainJs}`,
      `./dist/${npmMainJs}.map`,
      `./dist/${npmMainJs.replace(/.js$/, ".d.ts")}`,
      "./style/**/*.less",
      "./tests/*Mocks.d.ts",
      "./tests/*Mocks.js",
      "./typings.json ",
]

where npmMainJs is the javascript file specified as main in package.json.

If you need more then you can add and additionalNpmFiles to options

NoNpm

To prevent building a npm package add NoNpm to the keywords array.

*nuspec.json

To build a NuGet package add a *nuspec.json file in any folder (Except below .\Tests).

The content should be an object with two properties (of which one is optional): ||| |-|-| | options | Parameters as specified for gulp-nuget-pack. All except id optional (see below) | | files(optional) | An array of file specifications (see below) | |||

options

NameDescriptiondefault value
idId (and filename of NuGetPackage)required
versionThe versionversion from package.json
titleDisplayed nameid
authorsAuthors of packageauthor from package.json
ownersOwners of packageProActive A/S
descriptionLong description of package.Can't be specifiedContent of description.md (in nuspec.json folder)Content of README.md (in root folder)
summaryShort description of packagedescription from package.json
releaseNotesDescription of changes in release Can't be specifiedContent of releasenotes.md (in nuspec.json folder)
languageLocale Id for package such as en-us
projectUrlUrl for home page of package
iconUrlUrl for icon for package
licenseUrlLink to license the package is under
requireLicenseAcceptanceMust license be accepted on installfalse
copyrightCopyright detailsProActive A/S
dependenciesArray of packages of which this package is dependend each specified as an object with id and version (range) (see below)
tagsSpace delimited list of keyword for packagekeywords from package.json
excludesArray of globs to exclude from package
outputDirPath where package will be generatedCan't be specified./dist
baseDirPath relative to which files are specifiedroot

dependencies

Dependencies can be specified like this:

{
      "options": {
            ...
            "dependencies": [
                  {"id": "dependency1", "version": "1.0"},
                  {"id": "dependency2", "version": "(1.0,)"},
                  {"id": "dependency3", "version": "(1.0,2.0)"},
            ],
            ...
      }
}

files

List of files to include and where to place them like this (which is the default):

{
      "options": {
            ...
      },
      "files": [
            {
                  "dest": "/content/",
                  "src": "nuspec.json folder/content/*"
            },
            {
                  "dest": "/deployment/",
                  "src": "nuspec.json folder/deployment/*"
            },
            {
                  "dest": "/tools/",
                  "src": "nuspec.json folder/tools/*"
            },
      ]
}

Build and Test

Build using

npm run build gulp

Test using

npm run test

Lint using

npm run lint

Do all of above using

npm start

Debugging

If build fails then you can debug this using the self configuration in Code

If a test fail then you can debug this using the corresponding configuration in Code

In both cases source maps are set up to point to src\index.ts.