Skip to content

Commit

Permalink
feat: add more (debug) output
Browse files Browse the repository at this point in the history
  • Loading branch information
ZauberNerd committed Feb 13, 2019
1 parent bbb44ff commit 165c191
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 1 deletion.
31 changes: 31 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const os = require('os');
const path = require('path');

const explorer = require('cosmiconfig')('canarist');
const debug = require('debug')('canarist');
const makeDir = require('make-dir');
const mergeOptions = require('merge-options');
const writePkg = require('write-pkg');
Expand Down Expand Up @@ -52,6 +53,14 @@ if (!config.target) {
makeDir.sync(config.target);
}

debug('config: %O', config);

console.log(
`[canarist] cloning ${config.repositories.length} repositories into ${
config.target
}`
);

const rootManifestPath = path.join(config.target, 'package.json');
const rootManifest = mergeOptions.call(
{ concatArrays: true },
Expand All @@ -64,6 +73,8 @@ const rootManifest = mergeOptions.call(
config.rootManifest
);

debug('root manifest: %O', rootManifest);

function printUsage() {
console.log(
'Usage: canarist options [<target>]',
Expand Down Expand Up @@ -101,6 +112,7 @@ function printUsage() {

function cloneRepository(repository, directory, branch) {
const command = `git clone ${repository} ${directory} --branch ${branch} --depth 1`;
debug(`command: %s`);
child_process.execSync(command, { stdio: 'inherit' });
}

Expand All @@ -123,16 +135,21 @@ config.repositories.forEach(({ repository, directory, branch }) => {
);
});

debug('detected workspaces: %O', rootManifest.workspaces);

normlizeWorkspaces(config.target, rootManifest.workspaces, true);

writePkg.sync(rootManifestPath, rootManifest);

child_process.spawnSync('yarn', { stdio: 'inherit', cwd: config.target });

const testResults = [];

config.repositories.forEach(({ directory, commands }) => {
commands.forEach((input) => {
const [command, ...args] = input.split(' ');
if (typeof command === 'string' && command !== '') {
console.log('[canarist] executing %s in %s', input, directory);
const { status } = child_process.spawnSync(command, args, {
cwd: path.join(config.target, directory),
stdio: 'inherit',
Expand All @@ -143,4 +160,18 @@ config.repositories.forEach(({ directory, commands }) => {
}
}
});

testResults.push([directory, process.exitCode]);
});

const failedTests = testResults.filter(([_, code]) => code !== 0);

console.log(
'[canarist] failed projects %d/%d',
failedTests.length,
testResults.length
);
console.log(
'[canarist] failed projects: %O',
failedTests.map(([project]) => project)
);
2 changes: 1 addition & 1 deletion normalize-workspaces.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const dependencyTypes = [

function logMismatch(type, file, name, versions, dependencies) {
console.error(
'ERROR! %s mismatch in (%s) the current version of "%s" (%s) does not satisfy range "%s"',
'[canarist] WARNING! %s mismatch in (%s) the current version of "%s" (%s) does not satisfy range "%s"',
type,
file,
name,
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
},
"dependencies": {
"cosmiconfig": "^5.0.7",
"debug": "^4.1.1",
"fast-glob": "^2.2.6",
"git-url-parse": "^11.1.2",
"make-dir": "^2.0.0",
Expand Down
7 changes: 7 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1033,6 +1033,13 @@ debug@^4.0.0, debug@^4.0.1:
dependencies:
ms "^2.1.1"

debug@^4.1.1:
version "4.1.1"
resolved "http://nexus3.dc.xing.com/repository/npm/debug/-/debug-4.1.1.tgz#3b72260255109c6b589cee050f1d516139664791"
integrity sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==
dependencies:
ms "^2.1.1"

debuglog@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/debuglog/-/debuglog-1.0.1.tgz#aa24ffb9ac3df9a2351837cfb2d279360cd78492"
Expand Down

0 comments on commit 165c191

Please sign in to comment.