-
-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cebae99
commit b51a2c9
Showing
9 changed files
with
184 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/usr/bin/env node | ||
|
||
import 'nodent-runtime'; | ||
import program from 'commander'; | ||
import * as log from './lib/log'; | ||
import copyValues from './copy-values'; | ||
import { DEFAULT_PACKAGES, DEFAULT_SOURCE } from './constants'; | ||
|
||
program | ||
.option('-p, --packages <glob>', `location of packages. defaults to ${DEFAULT_PACKAGES}`) | ||
.option('-s, --source <glob>', `location of source. defaults to ${DEFAULT_SOURCE}`) | ||
.parse(process.argv); | ||
|
||
const { args = [], packages = DEFAULT_PACKAGES, source = DEFAULT_SOURCE } = program; | ||
|
||
copyValues({ | ||
keys: args, | ||
packagesPattern: packages, | ||
sourcePattern: source | ||
}).catch(err => { | ||
log.bug('uncaught error in copyValues', err); | ||
process.exit(1); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/usr/bin/env node | ||
|
||
import 'nodent-runtime'; | ||
import program from 'commander'; | ||
import * as log from './lib/log'; | ||
import syncVersions from './sync-versions'; | ||
import { DEFAULT_PACKAGES } from './constants'; | ||
|
||
program | ||
.option('-p, --packages <glob>', `location of packages. defaults to ${DEFAULT_PACKAGES}`) | ||
.parse(process.argv); | ||
|
||
const { packages = DEFAULT_PACKAGES } = program; | ||
|
||
syncVersions({ | ||
packagesPattern: packages | ||
}).catch(err => { | ||
log.bug('uncaught error in syncVersions', err); | ||
process.exit(1); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export const DEFAULT_PACKAGES = './packages/*/package.json'; | ||
export const DEFAULT_SOURCE = './package.json'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import path from 'path'; | ||
import chalk from 'chalk'; | ||
import { get, set } from 'lodash'; | ||
import getFiles from './lib/get-files'; | ||
|
||
const getPackage = location => ({ location, json: require(location) }); | ||
const formatValue = value => JSON.stringify(value); | ||
|
||
export default async ({ keys, packagesPattern, sourcePattern }) => { | ||
const [source] = (await getFiles(sourcePattern)).map(getPackage); | ||
const packages = (await getFiles(packagesPattern)).map(getPackage); | ||
|
||
packages.forEach(pkg => { | ||
console.log(chalk.grey.underline(path.relative(process.cwd(), pkg.location))); | ||
keys.forEach(key => { | ||
const value = get(source.json, key); | ||
const previousValue = formatValue(get(pkg.json, key)); | ||
set(pkg.json, key, value); | ||
const nextValue = formatValue(value); | ||
if (previousValue === nextValue) { | ||
console.log(`${key}: ${chalk.green('✓ unchanged')}`); | ||
} else { | ||
console.log(`${key}: ${chalk.red(previousValue)} → ${chalk.green(nextValue)}`); | ||
} | ||
}); | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters