Skip to content

Commit ed77233

Browse files
Added monorepo-merge Tool Scaffolding
This contains the basic framework for our new `monorepo-merge` command. The goal will be for this command to handle the heavy lifting for merging repositories with full history. It will (ideally) bring any plugin or package into the repository in a ready-to-use state.
1 parent 5af5be5 commit ed77233

File tree

13 files changed

+1961
-11228
lines changed

13 files changed

+1961
-11228
lines changed

pnpm-lock.yaml

+1,817-11,228
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pnpm-workspace.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
packages:
22
- 'packages/js/**'
33
- 'plugins/**'
4+
- 'tools/monorepo-merge'

tools/monorepo-merge/.eslintignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/dist

tools/monorepo-merge/.eslintrc

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"parser": "@typescript-eslint/parser",
3+
"ignorePatterns": [ "dist/", "node_modules/" ],
4+
"plugins": [ "@typescript-eslint/eslint-plugin" ],
5+
"extends": [ "plugin:@wordpress/eslint-plugin/recommended-with-formatting" ],
6+
"rules": {
7+
"no-unused-vars": "off"
8+
}
9+
}

tools/monorepo-merge/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/oclif.manifest.json

tools/monorepo-merge/bin/dev

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/usr/bin/env node
2+
3+
const oclif = require('@oclif/core')
4+
5+
const path = require('path')
6+
const project = path.join(__dirname, '..', 'tsconfig.json')
7+
8+
// In dev mode -> use ts-node and dev plugins
9+
process.env.NODE_ENV = 'development'
10+
11+
require('ts-node').register({project})
12+
13+
// In dev mode, always show stack traces
14+
oclif.settings.debug = true;
15+
16+
// Start the CLI
17+
oclif.run().then(oclif.flush).catch(oclif.Errors.handle)

tools/monorepo-merge/bin/dev.cmd

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
@echo off
2+
3+
node "%~dp0\dev" %*

tools/monorepo-merge/bin/run

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/usr/bin/env node
2+
3+
const oclif = require('@oclif/core')
4+
5+
oclif.run().then(require('@oclif/core/flush')).catch(require('@oclif/core/handle'))

tools/monorepo-merge/bin/run.cmd

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
@echo off
2+
3+
node "%~dp0\run" %*

tools/monorepo-merge/package.json

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
{
2+
"name": "monorepo-merge",
3+
"version": "0.0.0",
4+
"description": "A tool for merging repositories into the WooCommerce Monorepo.",
5+
"author": "Automattic",
6+
"bin": {
7+
"monorepo-merge": "./bin/run"
8+
},
9+
"homepage": "https://github.com/woocommerce/woocommerce",
10+
"license": "GPLv2",
11+
"main": "dist/index.js",
12+
"repository": "woocommerce/woocommerce",
13+
"files": [
14+
"/bin",
15+
"/dist",
16+
"/npm-shrinkwrap.json",
17+
"/oclif.manifest.json"
18+
],
19+
"dependencies": {
20+
"@oclif/core": "^1",
21+
"@oclif/plugin-help": "^5",
22+
"@oclif/plugin-plugins": "^2.0.1"
23+
},
24+
"devDependencies": {
25+
"@types/node": "^16.9.4",
26+
"eslint": "^7.32.0",
27+
"globby": "^11",
28+
"oclif": "^2",
29+
"shx": "^0.3.3",
30+
"ts-node": "^10.2.1",
31+
"tslib": "^2.3.1",
32+
"typescript": "^4.4.3"
33+
},
34+
"oclif": {
35+
"bin": "monorepo-merge",
36+
"dirname": "monorepo-merge",
37+
"commands": "./dist/commands",
38+
"plugins": [
39+
"@oclif/plugin-help",
40+
"@oclif/plugin-plugins"
41+
],
42+
"topicSeparator": " ",
43+
"topics": {
44+
"merge": {
45+
"description": "Merges other repositories into the monorepo."
46+
}
47+
}
48+
},
49+
"scripts": {
50+
"build": "shx rm -rf dist && tsc -b",
51+
"lint": "eslint . --ext .ts --config .eslintrc",
52+
"postpack": "shx rm -f oclif.manifest.json",
53+
"posttest": "pnpm lint",
54+
"prepack": "pnpm build && oclif manifest"
55+
},
56+
"engines": {
57+
"node": ">=12.0.0"
58+
},
59+
"types": "dist/index.d.ts"
60+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/**
2+
* External dependencies
3+
*/
4+
import { Command } from '@oclif/core';
5+
6+
export default class Merge extends Command {
7+
static description =
8+
'Merges another repository into this one with history.';
9+
10+
static args = [
11+
{
12+
name: 'source',
13+
description: 'The GitHub repository we are merging from.',
14+
required: true,
15+
},
16+
{
17+
name: 'destination',
18+
description:
19+
'The local destination for the repository to be merged at.',
20+
required: true,
21+
},
22+
];
23+
24+
async run(): Promise< void > {
25+
const { args } = await this.parse( Merge );
26+
27+
this.log( 'It has begun' );
28+
}
29+
}

tools/monorepo-merge/src/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { run } from '@oclif/core';

tools/monorepo-merge/tsconfig.json

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"compilerOptions": {
3+
"declaration": true,
4+
"importHelpers": true,
5+
"module": "commonjs",
6+
"outDir": "dist",
7+
"rootDir": "src",
8+
"strict": true,
9+
"target": "es2019"
10+
},
11+
"include": [
12+
"src/**/*"
13+
]
14+
}

0 commit comments

Comments
 (0)