Licence
MIT
Version
0.0.50
Deps
24
Size
958 kB
Vulns
0
Weekly
0
packtory
API Package for packtory
This package provides an API for the packtory tool, enabling programmatic usage. It exposes the following functions:
buildAndPublishAll(config, options)– validates the configuration, builds every package, runs the enabled checks, and (optionally) publishes the results.resolveAndLinkAll(config)– performs the validation, resolve, link, and checks phases without publishing. This is useful for custom workflows and integration tests that only need the prepared bundles.diffAgainstLatestPublished(config)– validates and builds every package without publishing, then per package computes the file-level diff between the bundle the next publish would produce and the version currently taggedlateston the configured registry.planReleaseAgainstLatestPublished(config)– validates and builds every package without publishing, then returns per-package release state, release classification, planned versions, artifact file paths, changed artifact file paths, registry metadata includinggitHead, currentgitHead, bundled source file paths, and changelog source file paths.packPackage(config, options)– validates the configuration, runs the same resolve / link / checks pipeline asbuildAndPublishAll, and writes a single configured package to disk as a zip, tarball, or expanded folder. Useful when you need an artifact you control (Lambda zip, container build context, local inspection) instead of a registry publish.
Installation:
npm install packtoryUsage:
import { buildAndPublishAll, resolveAndLinkAll, planReleaseAgainstLatestPublished, packPackage } from 'packtory';
const config = {
/* your packtory configuration */
};
(async () => {
const publishOutcome = await buildAndPublishAll(config, { dryRun: true, stage: false });
console.log(publishOutcome.result);
const resolvedOutcome = await resolveAndLinkAll(config);
console.log(resolvedOutcome.result);
const releasePlanOutcome = await planReleaseAgainstLatestPublished(config);
console.log(releasePlanOutcome.result);
const packOutcome = await packPackage(config, {
packageName: 'image-resizer-cli',
format: 'zip',
outputPath: './dist/image-resizer-cli.zip',
version: '1.4.0',
vendorDependencies: true
});
console.log(packOutcome.result);
})();Parameters:
- config: The packtory configuration object.
registrySettingsis optional; it is only required to publish in non-dry-run mode. Pack, dry-run publish, release-diff and release analysis read registry metadata anonymously whenregistrySettings(or itsauth) is omitted. CallingbuildAndPublishAll(config, { dryRun: false })withoutauthfails fast with oneConfigErrorbefore any package is processed. - options: Per-function options object:
buildAndPublishAll:{ dryRun: boolean; stage: boolean; collectReport?: boolean }.resolveAndLinkAll: optional{ collectReport?: boolean }.packPackage:{ packageName, format, outputPath, version, vendorDependencies }.formatis'zip' | 'tar' | 'folder'.versionstamps the generated manifest (no automatic versioning is performed).vendorDependenciestoggles materializing the resolvednode_modulestree (including anybundleDependencies) into the artifact for self-contained deployments.
Return Values:
buildAndPublishAllreturns aPublishAllOutcomewhoseresultis either a list of successful publish results or a partial error if some packages failed. Each successful item includespublication, which is{ type: 'none' }for dry-runs / already-up-to-date packages,{ type: 'published' }for direct publishes, or{ type: 'staged', stageId }for npm staged publishing.- Stage mode is npm-only. The package must already exist on npm, and automatic versioning in stage mode must be able to list pending staged versions before choosing the next version. If publish auth uses npm OIDC/trusted publishing, provide token-based metadata auth for that lookup.
resolveAndLinkAllreturns aResolveAndLinkAllOutcomewhoseresultcarries the resolved package information or details about the failure (validation errors, check failures, or partial execution issues).diffAgainstLatestPublishedreturns aReleaseDiffAllOutcomewhoseresultcarries the per-package release diff list or a failure variant.planReleaseAgainstLatestPublishedreturns aReleasePlanOutcomewhoseresultcarries{ packages }or a failure variant. Each package plan includespreviousVersion,nextVersion,artifactState,releaseClassification,changed,previousGitHead,currentGitHead,latestRegistryMetadata,artifactFiles,changedArtifactFiles,sourceFiles, andchangelogSourceFiles.releaseClassificationmatches the release analysis categories, includingdependency-onlyfor generated manifest and SBOM dependency changes.sourceFilescontains bundled source paths.changelogSourceFilescontains repository-relative files for changelog attribution, using readable JavaScript source maps when present. Rootpackage.jsonis included when effectivemainPackageJsonfields affect the generated package manifest, andadditionalChangelogSourceFilescan add other package attribution paths.latestRegistryMetadataincludes the previous version, publish time, and previous registrygitHeadwhen available.packPackagereturns aPackOutcomewhoseresultisOk(undefined)on success or aPackFailure.PackFailureis a discriminated union covering configuration errors, check failures, partial resolve failures, and the pack-specific variantspackage-not-found,bundle-dependencies-unsupported(rejected whenvendorDependenciesisfalseand the target declaresbundleDependencies), andpeer-dependencies-unsatisfied(raised when a vendored dependency declares a peer that no other vendored package satisfies).
Note: Refer to the full documentation for additional details.