Skip to content

Commit

Permalink
v0.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
guigrpa committed Feb 9, 2017
0 parents commit 9b450b6
Show file tree
Hide file tree
Showing 19 changed files with 3,827 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .babelrc
@@ -0,0 +1,3 @@
{
"presets": ["es2015", "stage-2", "react"],
}
51 changes: 51 additions & 0 deletions .eslintrc.yaml
@@ -0,0 +1,51 @@
parser: babel-eslint
extends: airbnb
rules:
eqeqeq: ['error', 'allow-null']
no-unused-expressions:
- error
- allowShortCircuit: true
no-use-before-define: off
no-multi-spaces: off
no-nested-ternary: off
no-cond-assign: ['error', 'except-parens']
no-underscore-dangle: off
comma-dangle:
- error
- arrays: always-multiline
objects: always-multiline
imports: always-multiline
exports: always-multiline
functions: ignore
no-plusplus:
- error
- allowForLoopAfterthoughts: true
no-continue: off
no-await-in-loop: off
key-spacing:
- warn
- beforeColon: false
afterColon: true
mode: 'minimum'
object-property-newline: off
class-methods-use-this: off
arrow-parens: ['error', 'always']
react/sort-comp: off
react/jsx-first-prop-new-line: off
react/jsx-indent: off
react/jsx-indent-props: off
react/jsx-closing-bracket-location: off
react/jsx-filename-extension: off
react/forbid-prop-types: off
react/prop-types: off
react/require-extension: off
react/require-default-props: off
import/no-extraneous-dependencies:
- error
- devDependencies: true
peerDependencies: true
optionalDependencies: false
import/prefer-default-export: off
jsx-a11y/no-static-element-interactions: off
globals:
chrome: false
25 changes: 25 additions & 0 deletions .gitignore
@@ -0,0 +1,25 @@
# GIT-NPM common
# --------------
# All projects
logs
*.log
npm-debug.log*
pids
*.pid
*.seed
node_modules
/coverage
/.nyc_output
/.nyc_tmp
*.sublime-project
*.sublime-workspace

# Project-specific


# GIT-specific
# ------------
# All projects
lib

# Project-specific
32 changes: 32 additions & 0 deletions .npmignore
@@ -0,0 +1,32 @@
# GIT-NPM common
# --------------
# All projects
logs
*.log
npm-debug.log*
pids
*.pid
*.seed
node_modules
/coverage
/.nyc_output
/.nyc_tmp
*.sublime-project
*.sublime-workspace

# Project-specific


# NPM-specific
# ------------
# All projects
/src
/tools
/test
/package.coffee
/ROADMAP.md
/.travis.yml
/.npmignore

# Project-specific
/docs
5 changes: 5 additions & 0 deletions CHANGELOG.md
@@ -0,0 +1,5 @@
# Changelog

## 0.1.0 (Feb. 9, 2017)

* First public release.
21 changes: 21 additions & 0 deletions LICENSE
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2017- Guillermo Grau Panea

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
55 changes: 55 additions & 0 deletions README.md
@@ -0,0 +1,55 @@
# oao [![npm version](https://img.shields.io/npm/v/oao.svg)](https://www.npmjs.com/package/oao)

An opinionated monorepo management tool

**Note that this is pretty much in an _alpha_ stage**

## Why?

* Works with **yarn**, hence **fast**
* Simple to use
* Helps with monorepo workflows: installing all dependencies, validating version numbers, etc.
* Prevents some typical errors (publishing from a non-master branch or with uncommitted changes)


## Installation

Add `oao` to your development dependencies:

```sh
$ yarn add oao --dev
```

## Usage

To see all CLI options, run `node_modules/.bin/oao --help`:

```
Usage: oao [options] [command]
Commands:
bootstrap Install external dependencies and create internal links
prepublish Prepare for a release: validate version numbers, copy READMEs and package.json attributes
publish Publish those packages that have higher versions than those in the registry
all <command> Run a given command on all packages
Options:
-h, --help output usage information
-V, --version output the version number
```

## [Changelog](https://github.com/guigrpa/oao/blob/master/CHANGELOG.md)


## License (MIT)

Copyright (c) [Guillermo Grau Panea](https://github.com/guigrpa) 2017-

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
54 changes: 54 additions & 0 deletions package.json
@@ -0,0 +1,54 @@
{
"name": "oao",
"version": "0.1.0",
"description": "An opinionated monorepo management tool",
"bin": {
"oao": "lib/index.js"
},
"scripts": {
"build": "yarn run lint && yarn run compile && yarn run xxl",
"lint": "eslint src",
"compile": "rm -rf lib && babel src -d lib"
},
"repository": {
"type": "git",
"url": "https://github.com/guigrpa/mono-repo.git"
},
"keywords": [
"monorepo",
"lerna",
"mono-repo"
],
"author": "Guillermo Grau Panea",
"license": "MIT",
"bugs": {
"url": "https://github.com/guigrpa/mono-repo/issues"
},
"homepage": "https://github.com/guigrpa/mono-repo#readme",
"dependencies": {
"commander": "2.9.0",
"globby": "6.1.0",
"inquirer": "3.0.1",
"semver": "5.3.0",
"shelljs": "0.7.6",
"split": "1.0.0",
"storyboard": "^2.0.0",
"timm": "^1.2.3"
},
"devDependencies": {
"babel-cli": "6.22.2",
"babel-core": "6.22.1",
"babel-eslint": "7.1.1",
"babel-polyfill": "6.22.0",
"babel-preset-es2015": "6.22.0",
"babel-preset-react": "6.22.0",
"babel-preset-stage-2": "6.22.0",
"eslint": "3.15.0",
"eslint-config-airbnb": "14.1.0",
"eslint-plugin-flowtype": "2.30.0",
"eslint-plugin-import": "2.2.0",
"eslint-plugin-jsx-a11y": "4.0.0",
"eslint-plugin-react": "6.9.0",
"xxl": "^1.0.1"
}
}
68 changes: 68 additions & 0 deletions src/bootstrap.js
@@ -0,0 +1,68 @@
import { omit, set as timmSet } from 'timm';
import { mainStory, chalk } from './utils/storyboard';
import readAllSpecs, { ROOT_PACKAGE } from './utils/readAllSpecs';
import writeSpecs from './utils/writeSpecs';
import { exec } from './utils/helpers';

const DEP_TYPES = ['dependencies', 'devDependencies', 'peerDependencies', 'optionalDependencies'];

const run = async () => {
const allSpecs = await readAllSpecs();
const pkgNames = Object.keys(allSpecs);

// Pass 1: register each package with yarn, and install external deps
for (let i = 0; i < pkgNames.length; i++) {
const pkgName = pkgNames[i];
if (pkgName === ROOT_PACKAGE) continue;
const { pkgPath, specPath, specs: prevSpecs } = allSpecs[pkgName];
mainStory.info(`${chalk.bold('PASS 1:')} processing ${chalk.cyan.bold(pkgName)}...`);

// Link
mainStory.info(' - Registering...');
await exec('yarn link', {
cwd: pkgPath,
logLevel: 'trace',
errorLogLevel: 'info',
});

// Rewrite package.json without own packages, install, and revert changes
try {
let nextSpecs = prevSpecs;
DEP_TYPES.forEach((type) => {
const prevDeps = nextSpecs[type];
if (prevDeps == null) return;
const nextDeps = omit(prevDeps, pkgNames);
nextSpecs = timmSet(nextSpecs, type, nextDeps);
});
if (nextSpecs !== prevSpecs) writeSpecs(specPath, nextSpecs);
mainStory.info(' - Installing external dependencies...');
await exec('yarn install', { cwd: pkgPath, logLevel: 'trace' });
} finally {
if (prevSpecs != null) writeSpecs(specPath, prevSpecs);
}
}

// Pass 2: link internal deps
for (let i = 0; i < pkgNames.length; i++) {
const pkgName = pkgNames[i];
if (pkgName === ROOT_PACKAGE) continue;
const { pkgPath, specs } = allSpecs[pkgName];
mainStory.info(
`${chalk.bold('PASS 2:')} installing internal deps for ${chalk.cyan.bold(pkgName)}...`);
for (let k = 0; k < pkgNames.length; k++) {
const depName = pkgNames[k];
if (depName === pkgName) continue;
for (let m = 0; m < DEP_TYPES.length; m++) {
const deps = specs[DEP_TYPES[m]];
if (deps == null) continue;
if (deps[depName]) {
mainStory.info(` - Linking to ${chalk.cyan.bold(depName)}...`);
await exec(`yarn link ${depName}`, { cwd: pkgPath, logLevel: 'trace' });
break;
}
}
}
}
};

export default run;
11 changes: 11 additions & 0 deletions src/forEach.js
@@ -0,0 +1,11 @@
import listPaths from './utils/listPaths';
import { exec } from './utils/helpers';

const run = async (cmd) => {
const pkgPaths = await listPaths();
for (let i = 0; i < pkgPaths.length; i += 1) {
await exec(cmd, { cwd: pkgPaths[i] });
}
};

export default run;
30 changes: 30 additions & 0 deletions src/index.js
@@ -0,0 +1,30 @@
#!/usr/bin/env node
import 'babel-polyfill';
import program from 'commander';
import bootstrap from './bootstrap';
import prepublish from './prepublish';
import publish from './publish';
import forEach from './forEach';

const pkg = require('../package.json');

program.version(pkg.version);

program.command('bootstrap')
.description('Install external dependencies and create internal links')
.action(() => bootstrap());

program.command('prepublish')
.description('Prepare for a release: validate version numbers, copy READMEs and package.json attributes')
.action(() => prepublish());

program.command('publish')
.description('Publish those packages that have higher versions than those in the registry')
.action(() => publish());

program.command('all <command>')
.description('Run a given command on all packages')
.action((command) => { forEach(command); });

program.parse(process.argv);

0 comments on commit 9b450b6

Please sign in to comment.