All Projects β†’ janbiasi β†’ monopacker

janbiasi / monopacker

Licence: MIT License
A tool for managing builds of monorepo frontend projects with eg. npm- or yarn workspaces, lerna or similar tools into a standalone application - no other tools needed.

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to monopacker

Ultra Runner
πŸƒβ›° Ultra fast monorepo script runner and build tool
Stars: ✭ 496 (+2817.65%)
Mutual labels:  lerna, monorepo, build-tool
lerna-terminal
Powerful cli ui for monorepos
Stars: ✭ 25 (+47.06%)
Mutual labels:  lerna, monorepo, monorepos
Pants
The Pantsbuild developer workflow system
Stars: ✭ 1,814 (+10570.59%)
Mutual labels:  monorepo, build-tool, monorepos
yarn-workspaces-example
Sample monorepo project using new Yarn feature called Workspaces
Stars: ✭ 39 (+129.41%)
Mutual labels:  lerna, monorepo
cra-monorepo-demo
Monorepo example using create-react-app and common component library structure with yarn workspaces
Stars: ✭ 37 (+117.65%)
Mutual labels:  lerna, monorepo
nx-extend
Nx Workspaces builders and tools
Stars: ✭ 67 (+294.12%)
Mutual labels:  monorepo, nx
monorepo-utils
A collection of utilities for monorepo/lerna. Tools for TypeScript project references etc..
Stars: ✭ 143 (+741.18%)
Mutual labels:  lerna, monorepo
react-ecommerce
E-commerce monorepo application using NextJs, React, React-native, Design-System and Graphql with Typescript
Stars: ✭ 136 (+700%)
Mutual labels:  lerna, monorepo
blog
blog posts & source code.
Stars: ✭ 44 (+158.82%)
Mutual labels:  lerna, monorepo
nrwl-nx-action
A GitHub Action to wrap Nrwl Nx commands in your workflows.
Stars: ✭ 163 (+858.82%)
Mutual labels:  monorepo, nx
vscode-monorepo-workspace
πŸ“¦βœ¨Manage monorepos with multi-root workspaces. Supports Lerna, Yarn, Pnpm, Rushjs and recursive package directories.
Stars: ✭ 93 (+447.06%)
Mutual labels:  lerna, monorepo
ng-mono-repo-starter
Angular Mono Repo Starter
Stars: ✭ 79 (+364.71%)
Mutual labels:  lerna, monorepo
shared-react-components-example
An example of a mono-repository of shared React components libraries!
Stars: ✭ 85 (+400%)
Mutual labels:  lerna, monorepo
awesome-nx
An awesome list that curates the best Nrwl Nx tools, tutorials, articles and more.
Stars: ✭ 45 (+164.71%)
Mutual labels:  monorepo, nx
git
git (and github) & monorepo / mono source tree command line tools, libraries & scripts
Stars: ✭ 16 (-5.88%)
Mutual labels:  monorepo, monorepos
lerna-sync
A package to synchronize distributed GitHub repos inside a Lerna monorepo.
Stars: ✭ 15 (-11.76%)
Mutual labels:  lerna, monorepo
eslint-import-resolver-lerna
Resolver for Lerna-based projects for eslint-plugin-import
Stars: ✭ 47 (+176.47%)
Mutual labels:  lerna, monorepo
lerna-cola
Superpowers for your Lerna monorepos.
Stars: ✭ 23 (+35.29%)
Mutual labels:  lerna, monorepos
Baumeister
πŸ‘· The aim of this project is to help you to build your things. From Bootstrap themes over static websites to single page applications.
Stars: ✭ 171 (+905.88%)
Mutual labels:  workflow, build-tool
N8n
Free and open fair-code licensed node based Workflow Automation Tool. Easily automate tasks across different services.
Stars: ✭ 19,252 (+113147.06%)
Mutual labels:  workflow, workflow-automation

Build Status npm version Commitizen friendly semantic-release


⚠️ Major revision in progress

The current version of monopacker is outdated but still in use in a couple of projects. As there were a lot of changes in architectural design of monorepos in the last 2 years I'll continue to refactor the whole monopacker toolset into a new major revision.


monopacker

A tool for managing builds of monorepo frontend projects with eg. lerna or similar tools. Developers who are working within monorepositories often have the problem that they need to deploy an application but don't want to deploy the whole repository. This is not possible by default, but there's monopacker - a tool for generating small bundles out of your monorepository applications which are straight deployable - with extras!

The process steps in depth
  1. Aggregate all dependencies of the target application
  2. Detect which dependencies come from NPM and which are located in the repo
  3. Clone the target (only needed files, customizable) to the new target
  4. Create an artificial package.json with installable dependencies from the project, including the needed production dependencies from the internal dependencies (eg. main app (A) requires B and B requires express so express will also be a dependency of the packed application, quite smart huh?)
  5. Install all possible dependencies from NPM
  6. Copy all needed submodules to the packed target to "fake" the installation
  7. Done! Your application is ready to deploy individually as it is.
But I need to <insert your requirement here> ...
  • Monopacker provides a flexible programmatical API
  • Monopacker provides also a CLI implementation
  • Monopacker supports a hook system where you are able to interact within every step of the packing process
  • Monopacker can be configured what to copy and what not
  • Monopacker supports internal caching for repetetive processes and large repos with circular references

Installation

npm install monopacker --save-dev --save-exact
# or with yarn
yarn add monopacker --dev

CLI API

Note: the CLI does not support hooks! If you want to inject side-effects please use the programmatic API

analyze

Option  Short Default Description
--root -r process.cwd() Set the root directory for the process
# Will output a JSON graph of the packable application
$ monopacker analyze packages/apps/main
$ monopacker a packages/apps/main

pack

Option  Short Default Description
--root -r process.cwd() Set the root directory for the process
--copy -c **,!package.json Globs for what to copy initiall to the target, comma separated
--noCache -nc false Disable all caching mechanisms
--adapter -a lerna Select a certain adapter for processing, we only support lerna atm.
# Will pack the application from `packages/apps/main` to `packed`
$ monopacker pack packages/apps/main
$ monopacker p packages/apps/main
# Will pack the application from `packages/apps/main` to `deploy/main-app`
$ monopacker pack packages/apps/main deploy/main-app
# Will pack a remote application from `packages/apps/main` to `deploy/main-app`
$ monopacker pack packages/apps/main deploy/main-app --root ../another-app
$ monopacker pack packages/apps/main deploy/main-app -r ../another-app
# Will not copy anything initially
$ monopacker pack packages/apps/main --copy !**
$ monopacker pack packages/apps/main -c !**
# Force use the lerna strategy
$ monopacker pack packages/apps/main --adapter lerna
$ monopacker pack packages/apps/main -a lerna
# Without caching
$ monopacker pack packages/apps/main --noCache
$ monopacker pack packages/apps/main -nc
# Complex example
$ monopacker pack packages/main packed/main --root ./test/fixtures/basic/ --noCache --copy src,dist -a lerna

Programmatic API

Options

interface IPackerOptions {
	/**
	 * Source to pack (root is cwd)
	 */
	source: string;
	/**
	 * Target for the packed app (root is cwd)
	 */
	target: string;
	/**
	 * Monorepository type, at the moment only lerna support.
	 * Default: auto-detected
	 */
	type?: 'lerna' | 'nx';
	/**
	 * Enable or disable the cache, default is true (enabled)
	 */
	cache?: boolean;
	/**
	 * Working directory, can be changed, default: process.cwd()
	 */
	cwd?: string;
	/**
	 * Expressions to match package names which are internally defined (optional)
	 * Can be used for eg. rewriting globally available modules such as 'react-scripts'
	 * to provide a custom implementation for.
	 */
	internals?: string[];
	/**
	 * The adapter for the analytics process, default: lerna
	 */
	adapter?: IAdapterConstructable;
	/**
	 * Optional copy settings, defaults to `['**', '!package.json', ...]`
	 */
    copy?: string[];
    /**
     * Enable the debug mode, defaults to false
     */
    debug?: boolean;
	/**
	 * Define opt-in hooks for certain steps
	 */
	hooks?: Partial<{
		[HookPhase.INIT]: Array<(packer: Packer) => Promise<any>>;
		[HookPhase.PREANALYZE]: Array<(packer: Packer) => Promise<any>>;
		[HookPhase.POSTANALYZE]: Array<
			(
				packer: Packer,
				information: {
					analytics: IAnalytics;
					generateAnalyticsFile: boolean;
					fromCache: boolean;
				}
			) => Promise<any>
		>;
		[HookPhase.PRECOPY]: Array<(packer: Packer) => Promise<any>>;
		[HookPhase.POSTCOPY]: Array<(packer: Packer, copiedFiles: string[]) => Promise<any>>;
		[HookPhase.PRELINK]: Array<(packer: Packer, entries: ILernaPackageListEntry[]) => Promise<any>>;
		[HookPhase.POSTLINK]: Array<(packer: Packer, entries: ILernaPackageListEntry[]) => Promise<any>>;
		[HookPhase.PREINSTALL]: Array<(packer: Packer, artificalPkg: ArtificalPackage) => Promise<any>>;
		[HookPhase.POSTINSTALL]: Array<(packer: Packer, artificalPkg: ArtificalPackage) => Promise<any>>;
		[HookPhase.PACKED]: Array<
			(
				packer: Packer,
				resume: {
					analytics: IAnalytics;
					artificalPackage: ArtificalPackage;
					copiedFiles: string[];
				}
			) => Promise<any>
		>;
	}>;
}

Debugging

import { Packer } from 'monopacker';

new Packer({
    source: 'packages/apps/my-app',
    target: 'packed/my-app',
    debug: true // uses the helper `useDebugHooks`
});

Multi taping

import { Packer, Taper, HookPhase } from 'monopacker';

const packer = new Packer({
    source: 'packages/apps/my-app',
    target: 'packed/my-app',
});

packer.subscribe(
    new Taper(HookPhase, {
        // add some other hooks here which will be run before the target hooks
        // can be used to separate taping logic conditionally.
        init: [async () => console.log('Hello from subscription:init!')]
    })
);

await packer.pack();

Simple example

import { Packer } from 'monopacker';

new Packer({
    source: 'packages/apps/my-app',
    target: 'packed/my-app',
}).pack();

Advanced example

import { resolve } from 'path';
import * as rimraf from 'rimraf';
import * as execa from 'execa';
import { Packer } from 'monopacker';

(async () => {
    new Packer({
        cwd: resolve(__dirname, 'my-repo-is-nested'),
        source: 'packages/apps/my-app',
        target: 'packed/my-app',
        copy: [
            '!.cache',
            '!lcov-report',
            '!.gitignore',
            '!tsconfig.json',
            '!README.md',
            '!junit.xml',
            '!jest.config.js'
        ],
        hooks: {
            init: [
                async () => {
                    await execa('npm', ['run', 'build']);
                },
            ],
            precopy: [
                async packer => {
                    // create a production build before copying things
                    await packer.runInSourceDir('npm', ['run', 'build', '--production']);
                }
            ]
        }
    });

    await packer.pack();

    console.log('done!');
})();q
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].