Code Monkey home page Code Monkey logo

meta-project's Introduction

Build Status

meta-project

project plugin for meta

Usage

  Usage: meta project [<options>] <command>


  Commands:

    create      create and initialize a new child repository
    import      import an existing child repository via git clone
    migrate     migrate from a monorepo to a metarepo
    help <cmd>  display help for <cmd>

  Options:

    -h, --help  output usage information

Creating a new project

To create a new project, use meta project create <folder> <repo url>

meta project create new-dir [email protected]/org/repo

Import an existing project

To import an existing project, use meta project import <folder> [<repo url>]

meta project import projects/example [email protected]/your-org/example

To import existing project which is already checked out at <folder>, <repo-url> can be omitted

meta project import projects/example

Migrate a Monorepo to a metarepo and keep your git history intact.

'meta project migrate' helps you move from a monorepo to a meta repo by moving directories from your existing repo into separate child repos, with git history intact. These are then referenced in your '.meta' file and cloned, making the operation transparent to your codebase.

For example, given the following monorepo structure:

- monorepo-base
  - project-a
  - project-b
  - project-c

Create git repos for project-a, project-b, and project-c, then run:

cd monorepo-base
meta init
meta project migrate project-a [email protected]/yourorg/project-a
meta project migrate project-b [email protected]/yourorg/project-b
meta project migrate project-c [email protected]/yourorg/project-c

This will keep the git history of each subproject in tact, using some git magic:

How it works

A) Migrate will first create a copy of your project in a temporary directory and replace the remote 'origin' with the provided

B) It will split the history from and push to the provided : https://help.github.com/en/articles/splitting-a-subfolder-out-into-a-new-repository

C) Next is removed from your monorepo, and then cloned back into the same location.

In the eyes of the monorepo, the only thing that has changed is the .meta file, however, now also has it's own distinct history.

Migration Phase

If you need the monorepos structure to stay in tact for any extended duration, such as supporting legacy CI systems, you can stop here.

While in this 'migration' phase, you need to commit to the child directory's git history as well as the monorepo's git history. These commits can literally be made twice by cd-ing around or both can be made at once using 'meta git commit'.

Finishing the Migration

When the monorepo no longer needs to be maintained you can simply add the migrated project to your '.gitignore'.

This will cause changes to only be tracked in the child repo, rather than both, such as during the migration phase.

meta-project's People

Contributors

aleclarson avatar gakada avatar mateodelnorte avatar patrickleet avatar renovate-bot avatar renovate[bot] avatar valdestron avatar zebolino avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

meta-project's Issues

expected `add` to clone the sub project.

I expected add to clone the sub project.
Instead it creates an empty .git repo and sets the remote without setting the upstream of master to origin/master nor does it get the latest from origin/master. This makes adding a project slightly less intuitive.

Action Required: Fix Renovate Configuration

There is an error with this repository's Renovate configuration that needs to be fixed. As a precaution, Renovate will stop PRs until it is resolved.

File: .github/renovate.json
Error type: The renovate configuration file contains some invalid settings
Message: Invalid regExp for packageRules[0].packagePatterns: ^meta-,find-file-recursively-up,get-meta-file,loop,symlink-meta-dependencies``

create uses git remote remove origin but if no origin exists

๐Ÿ› Bug Report

git remote remove origin throws fatal error if origin doesn't exist and meta create uses it to initialized the child repositories and hence the child repo don't have a remote added to them. The current fix is removing the folders and running meta git update so that everything clones properly

Action required: Greenkeeper could not be activated ๐Ÿšจ

๐Ÿšจ You need to enable Continuous Integration on Greenkeeper branches of this repository. ๐Ÿšจ

To enable Greenkeeper, you need to make sure that a commit status is reported on all branches. This is required by Greenkeeper because it uses your CI build statuses to figure out when to notify you about breaking changes.

Since we didnโ€™t receive a CI status on the greenkeeper/initial branch, itโ€™s possible that you donโ€™t have CI set up yet. We recommend using Travis CI, but Greenkeeper will work with every other CI service as well.

If you have already set up a CI for this repository, you might need to check how itโ€™s configured. Make sure it is set to run on all new branches. If you donโ€™t want it to run on absolutely every branch, you can whitelist branches starting with greenkeeper/.

Once you have installed and configured CI on this repository correctly, youโ€™ll need to re-trigger Greenkeeperโ€™s initial pull request. To do this, please click the 'fix repo' button on account.greenkeeper.io.

"create" should infer git url when unspecified

๐Ÿš€ Feature Proposal

The create command should try to infer the origin remote from a project if it already exists in the local filesystem.

Motivation

I manually moved some repos into a metarepo today, and I would've preferred not to manually track down the git urls to satisfy meta project create.

nested behavior

when calling meta project add ... if the project I'm adding is a meta repo, it should also behave the same as if I'd called meta git clone ....

Projects cannot be outside the meta repo

๐Ÿค“ Question

Are there any special reason for not importing repositories outside the actual repository?

meta-project-import:32-37

const metaPath = getMetaFile.getFileLocation();
const dest = path.relative(path.dirname(metaPath), path.resolve(destArg));
if (dest[0] === '.') {
    console.error(`๐Ÿ’ฅ Projects cannot be outside the meta repo: ${cyan(dest)}`); // prettier-ignore
    process.exit(1);
}

'.meta' in project name is resulting in wrong path resolution

If your meta folder is named smth. like 'abc.meta' adding a new project will cause this error:

adding abc.pro1 to .gitignore at /home/user/dev/src/abc.gitignore/.meta
/home/user/dev/src/abc.gitignore/.meta does not exists. Creating it now.
fs.js:122
    throw err;
    ^

Error: ENOENT: no such file or directory, open '/home/user/dev/src/abc.gitignore/.meta'
    at Object.openSync (fs.js:448:3)
    at module.exports (/home/user/.npm/lib/node_modules/meta/node_modules/meta-project/lib/addToGitIgnore.js:12:23)
    at find (/home/user/.npm/lib/node_modules/meta/node_modules/meta-project/bin/meta-project-add:66:9)
    at findIn (/home/user/.npm/lib/node_modules/meta/node_modules/find-file-recursively-up/index.js:18:14)
    at module.exports (/home/user/.npm/lib/node_modules/meta/node_modules/find-file-recursively-up/index.js:28:10)
    at exec (/home/user/.npm/lib/node_modules/meta/node_modules/meta-project/bin/meta-project-add:60:7)
    at module.exports (/home/user/.npm/lib/node_modules/meta/node_modules/meta-exec/index.js:56:18)
    at exec (/home/user/.npm/lib/node_modules/meta/node_modules/meta-project/bin/meta-project-add:51:5)
    at module.exports (/home/user/.npm/lib/node_modules/meta/node_modules/meta-exec/index.js:56:18)
    at mkdirp (/home/user/.npm/lib/node_modules/meta/node_modules/meta-project/bin/meta-project-add:44:3)

/home/user/dev/src/abc.meta/.meta -> /home/user/dev/src/abc.gitignore/.meta does not exists

Maybe thats the place to check:
addToGitIgnore(metafilePath.replace('.meta', '.gitignore'), destFolder);

Incorrect path in .gitignore after meta project create

๐Ÿ› Bug Report

Incorrect path in .gitignore after meta project create for Windows 10
meta version 2.2.10
meta-project version 2.2.9
git version 2.24.0.windows.2

To Reproduce

  1. init git and meta

meta init
git init

  1. add project with subfolder (Windows 10)

meta project create packae/project1 [email protected]:project1.git

  1. see .gitignore file (added directory looks like /packae\project1/)
  2. try to add files to git

git add ./

result:
error: 'packae/project1/' does not have a commit checked out
fatal: adding files failed

Expected behavior

git command should success.

note: If I change path in .gitignore from "/packae\project1/" to "/packae/project1/" git command works correctly.

missing remove

This plugin appears incomplete, I expected a meta project remove <file-path> to exist, but it either doesn't or it is not documented.

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Rate-Limited

These updates are currently rate-limited. Click on a checkbox below to force their creation now.

  • chore(deps): update dependency pretty-quick to v4
  • fix(deps): update dependency commander to v12
  • fix(deps): update dependency rimraf to v6
  • ๐Ÿ” Create all rate-limited PRs at once ๐Ÿ”

Edited/Blocked

These updates have been manually edited so Renovate will no longer make changes. To discard all commits and start over, click on a checkbox.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Ignored or Blocked

These are blocked by an existing closed PR and will not be recreated unless you click a checkbox below.

Detected dependencies

npm
package.json
  • chalk 3.0.0
  • commander 2.20.3
  • get-meta-file 1.3.6
  • loop 3.3.6
  • meta-exec 1.4.4
  • mkdirp 0.5.5
  • rimraf 2.7.1
  • tildify ^2.0.0
  • @commitlint/cli 12.1.4
  • @commitlint/config-conventional 12.1.4
  • commitizen 4.2.4
  • cz-conventional-changelog 3.3.0
  • husky 6.0.0
  • jest 26.6.3
  • prettier 2.3.1
  • pretty-quick 3.1.0
travis
.travis.yml
  • node 10
  • node 12

  • Check this box to trigger a request for Renovate to run again on this repository

"meta project import" should support custom branches

๐Ÿš€ Feature Proposal

The projects object in .meta should support custom git branches.

Motivation

The master branch isn't always appropriate.

Example

meta project import foo https://github.com/aleclarson/foo.git -b not-master

The .meta config could look like this:

{
  "projects": {
    "foo": {
      "url": "https://github.com/aleclarson/foo.git",
      "branch": "not-master"
    }
  }
}

`import` modifies `.gitignore` even with faulty input params

๐Ÿ› Bug Report

When I run the meta project import command, I often forget to add both dest and repoURL params. Instead I just add one param (usually the repo URL). Meta then proceeds to modify the .gitignore file, then tries to clone the repo but fails, hence not modifying the .meta file. The .gitignore file now contains the git URL, which is not correct.

To Reproduce

Example:

> meta project import [email protected]:eddex/some-repo.git
{ repoUrl: undefined, dest: '[email protected]:eddex\\some-repo.git' }

~\work\meta-repo:
fatal: repository 'undefined' does not exist
~\work\meta-repo: command 'git clone  undefined [email protected]:eddex\some-repo.git' exited with error: Error: Command failed: git clone  undefined [email protected]:eddex\some-repo.git
Appending to ~\work\meta-repo\.gitignore
Updating "projects" in ~\work\meta-repo\.meta

โœ“ Project imported: [email protected]:eddex\some-repo.git

The only modified file after this command is the .gitignore, meta adds the dest param (which in this case is the git URL):

+/[email protected]:eddex\some-repo.git/

Expected behavior

If only one param is detected (one of them is null/undefined), the command should be aborted and no files should be modified.

Alternatively, it would be great to allow only passing the repoURL and automatically parsing the repo name from it.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.