Skip to content
This repository has been archived by the owner on Dec 19, 2022. It is now read-only.

2.5.6 #42

Merged
merged 3 commits into from
Oct 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions code/msync/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = {
extends: './node_modules/@platform/ts.libs/lint.js',
rules: {},
};
16 changes: 8 additions & 8 deletions code/msync/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "msync",
"version": "2.5.5",
"version": "2.5.6",
"description": "Easily manage building and syncing multiple node-modules in a flexibly defined workspace.",
"main": "./lib/index",
"types": "./lib/index.d.ts",
Expand All @@ -15,18 +15,18 @@
"prepare": "ts prepare"
},
"dependencies": {
"@platform/fs": "0.5.5",
"@platform/log": "0.1.7",
"@platform/npm": "0.2.51",
"@platform/exec": "0.2.45",
"@platform/util.value": "0.7.3",
"@platform/exec": "0.2.63",
"@platform/fs": "0.5.24",
"@platform/log": "0.1.31",
"@platform/npm": "0.3.14",
"@platform/util.value": "0.8.1",
"command-interface": "4.2.1",
"rsync": "0.6.1",
"toposort": "2.0.2"
},
"devDependencies": {
"@platform/test": "0.1.2",
"@platform/ts": "3.7.12",
"@platform/test": "0.1.16",
"@platform/ts": "4.0.2",
"@types/rsync": "0.4.30"
},
"files": [
Expand Down
5 changes: 3 additions & 2 deletions code/msync/src/cli.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { log } from './common';
import chalk from 'chalk';
import * as chalk from 'chalk';
import command from 'command-interface';

import { log } from './common';

log.info(chalk.bgMagenta.black(' MSYNC '));
command(`${__dirname}/**/*.cmd.js`);
16 changes: 8 additions & 8 deletions code/msync/src/cmds/audit.cmd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ export const args = {};
/**
* CLI command.
*/
export async function cmd(args?: { params: string[]; options: {} }) {
await audit({});
export async function cmd(args?: { params: string[] }) {
await audit();
}

export async function audit(options: {} = {}) {
export async function audit() {
// Retrieve settings.
const settings = await loadSettings({ npm: true, spinner: true });
if (!settings) {
Expand Down Expand Up @@ -92,11 +92,11 @@ function printAudit(results: IAuditResult[]) {
const builder = log.table({ head, border: false });

results
.filter(audit => !audit.ok)
.forEach(audit => {
.filter((audit) => !audit.ok)
.forEach((audit) => {
const bullet = audit.ok ? log.green('✔') : log.red('✖');
const output = Object.keys(audit.vulnerabilities)
.map(key => ({ key: key as Level, value: audit.vulnerabilities[key] }))
.map((key) => ({ key: key as Level, value: audit.vulnerabilities[key] }))
.reduce((acc, next) => {
const text =
next.value > 0 ? log.gray(`${next.key}: ${levelColor(next.key)(next.value)}`) : '';
Expand Down Expand Up @@ -145,7 +145,7 @@ async function runAudits(modules: IModule[], options: IListrOptions) {
: [];

const issues = Object.keys(vulnerabilities)
.map(key => ({ key, value: vulnerabilities[key] }))
.map((key) => ({ key, value: vulnerabilities[key] }))
.reduce((acc, next) => (next.value > 0 ? acc + next.value : acc), 0);

// Clean up.
Expand All @@ -166,7 +166,7 @@ async function runAudits(modules: IModule[], options: IListrOptions) {
},
};
};
const tasks = modules.map(pkg => task(pkg));
const tasks = modules.map((pkg) => task(pkg));
const runner = listr(tasks, options);
try {
await runner.run();
Expand Down
18 changes: 9 additions & 9 deletions code/msync/src/cmds/build.cmd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ export async function build(
return;
}
const modules = settings.modules
.filter(pkg => filterUtil.includeIgnored(pkg, includeIgnored))
.filter(pkg => pkg.isTypeScript);
.filter((pkg) => filterUtil.includeIgnored(pkg, includeIgnored))
.filter((pkg) => pkg.isTypeScript);

if (watch) {
return buildWatch(modules, includeIgnored, verbose);
Expand All @@ -78,7 +78,7 @@ const tscCommand = async (pkg: IModule) => {
*/
export async function buildOnce(modules: IModule[]) {
const startedAt = new Date();
const tasks = modules.map(pkg => {
const tasks = modules.map((pkg) => {
return {
title: `${log.magenta(pkg.name)} ${log.gray('=> sync')}`,
task: async () => {
Expand Down Expand Up @@ -126,7 +126,7 @@ export async function buildWatch(modules: IModule[], includeIgnored: boolean, ve
log.clear();
const items = Object.keys(state)
.sort()
.map(key => ({ key, value: state[key] }));
.map((key) => ({ key, value: state[key] }));

// Print build summary.
items.forEach(({ key, value }) => {
Expand All @@ -140,7 +140,7 @@ export async function buildWatch(modules: IModule[], includeIgnored: boolean, ve
if (verbose && errors.length > 0) {
log.info();
errors.forEach(({ key, value }) => {
value.errors.forEach(error => {
value.errors.forEach((error) => {
log
.table()
.add([log.yellow(key), formatError(error)])
Expand All @@ -150,11 +150,11 @@ export async function buildWatch(modules: IModule[], includeIgnored: boolean, ve
}
});

modules.forEach(async pkg => {
modules.forEach(async (pkg) => {
const tsc = await tscCommand(pkg);
const cmd = `cd ${pkg.dir} && ${tsc} --watch`;

exec.cmd.run(cmd).output$.subscribe(e => {
exec.cmd.run(cmd).output$.subscribe((e) => {
let text = e.text;
const isBuilding =
text.includes('Starting compilation in watch') ||
Expand Down Expand Up @@ -239,7 +239,7 @@ export async function buildWatch(modules: IModule[], includeIgnored: boolean, ve
const formatError = (error: string) => {
const MAX = 80;
const lines = [] as string[];
error.split('\n').forEach(line => {
error.split('\n').forEach((line) => {
line = line.length <= MAX ? line : splitLines(line);
lines.push(line);
});
Expand All @@ -250,7 +250,7 @@ const splitLines = (line: string) => {
const MAX = 80;
const words = [] as string[];
let count = 0;
line.split('').forEach(word => {
line.split('').forEach((word) => {
count += word.length;
if (count > MAX) {
word = `${word}\n`;
Expand Down
8 changes: 4 additions & 4 deletions code/msync/src/cmds/bump.cmd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export async function bump(options: IOptions = {}) {
log.warn.yellow(constants.CONFIG_NOT_FOUND_ERROR);
return;
}
const modules = settings.modules.filter(pkg => filter.includeIgnored(pkg, includeIgnored));
const modules = settings.modules.filter((pkg) => filter.includeIgnored(pkg, includeIgnored));

// Prompt for the module to bump.
const module = await promptForModule(modules);
Expand Down Expand Up @@ -126,7 +126,7 @@ async function bumpModule(options: {
}

// Log output.
const head = ['update', 'module', 'version', 'dependants'].map(title => log.gray(title));
const head = ['update', 'module', 'version', 'dependants'].map((title) => log.gray(title));
const table = options.table || log.table({ head, border: false });

const logPkgUpdate = (args: { release: ReleaseType; pkg: IModule; version: string }) => {
Expand Down Expand Up @@ -187,7 +187,7 @@ ${log.info(logPkgUpdate({ release, pkg, version }))}
}

async function promptForModule(modules: IModule[]) {
const choices = modules.map(pkg => ({ name: pkg.name, value: pkg.name }));
const choices = modules.map((pkg) => ({ name: pkg.name, value: pkg.name }));
const res = (await inquirer.prompt({
type: 'list',
name: 'name',
Expand All @@ -196,7 +196,7 @@ async function promptForModule(modules: IModule[]) {
pageSize: 30,
})) as { name: string };
const name = res.name;
return modules.find(pkg => pkg.name === name);
return modules.find((pkg) => pkg.name === name);
}

async function promptForReleaseType(version: string) {
Expand Down
20 changes: 10 additions & 10 deletions code/msync/src/cmds/delete.cmd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,34 +52,34 @@ export async function cmd(args?: {

// Retrieve the list of module directories.
const modules = settings.modules
.filter(pkg => filter.includeIgnored(pkg, includeIgnored))
.map(m => m.dir);
.filter((pkg) => filter.includeIgnored(pkg, includeIgnored))
.map((m) => m.dir);

// Delete each
switch (response.type) {
case 'yarn.lock':
await deleteAfterPrompt(modules.map(dir => `${dir}/yarn.lock`));
await deleteAfterPrompt(modules.map((dir) => `${dir}/yarn.lock`));
break;

case 'package-lock.json':
await deleteAfterPrompt(modules.map(dir => `${dir}/package-lock.json`));
await deleteAfterPrompt(modules.map((dir) => `${dir}/package-lock.json`));
break;

case '.tslint.json.OLD':
await deleteAfterPrompt(modules.map(dir => `${dir}/.tslint.json.OLD`));
await deleteAfterPrompt(modules.map((dir) => `${dir}/.tslint.json.OLD`));
break;

case 'logs (error)':
await deleteAfterPrompt(
flatten([
modules.map(dir => `${dir}/yarn-error.log`),
modules.map(dir => `${dir}/npm-debug.log`),
modules.map((dir) => `${dir}/yarn-error.log`),
modules.map((dir) => `${dir}/npm-debug.log`),
]),
);
break;

case 'node_modules':
await deleteAfterPrompt(modules.map(dir => `${dir}/node_modules`));
await deleteAfterPrompt(modules.map((dir) => `${dir}/node_modules`));
break;

default:
Expand All @@ -103,7 +103,7 @@ async function deleteAfterPrompt(paths: string[]) {

// List files.
log.info.cyan(`\nDelete files:`);
paths.forEach(path => {
paths.forEach((path) => {
log.info(` ${toDisplayPath(path)}`);
});
log.info();
Expand Down Expand Up @@ -141,7 +141,7 @@ function toDisplayPath(path: string) {
}

async function deleteFiles(paths: string[]) {
const tasks = paths.map(path => {
const tasks = paths.map((path) => {
return {
title: `${log.cyan('Delete')} ${toDisplayPath(path)}`,
task: async () => tryDelete(path, { retry: 3 }),
Expand Down
22 changes: 11 additions & 11 deletions code/msync/src/cmds/ls.cmd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export async function ls(options: IListOptions = {}) {
return;
}

const modules = settings.modules.filter(pkg => filter.includeIgnored(pkg, includeIgnored));
const modules = settings.modules.filter((pkg) => filter.includeIgnored(pkg, includeIgnored));

if (formatting) {
// Pretty formatting.
Expand All @@ -88,7 +88,7 @@ export async function ls(options: IListOptions = {}) {
} else {
// No formatting.
log.info();
modules.forEach(pkg => log.info(pkg.name));
modules.forEach((pkg) => log.info(pkg.name));
log.info();
}

Expand All @@ -112,9 +112,9 @@ export function printTable(modules: IModule[], options: IListOptions = {}) {

const listDependences = (pkg: IModule, modules: IModule[]) =>
pkg.dependencies
.filter(dep => (showAllDependencies ? true : dep.isLocal))
.filter(dep => (dep.package ? filter.includeIgnored(dep.package, includeIgnored) : true))
.map(dep => {
.filter((dep) => (showAllDependencies ? true : dep.isLocal))
.filter((dep) => (dep.package ? filter.includeIgnored(dep.package, includeIgnored) : true))
.map((dep) => {
const isIgnored = dep.package && dep.package.isIgnored;
// const bullet = isIgnored ? log.gray('-') : log.magenta('-');
const name = isIgnored
Expand All @@ -131,8 +131,8 @@ export function printTable(modules: IModule[], options: IListOptions = {}) {
return log.yellow('dependant');
}
return dependants
.filter(pkg => filter.includeIgnored(pkg, includeIgnored))
.map(pkg => {
.filter((pkg) => filter.includeIgnored(pkg, includeIgnored))
.map((pkg) => {
const name = pkg.isIgnored ? log.gray(pkg.name) : formatModuleName(pkg.name);
return `${name} ${log.gray(pkg.version)}`;
})
Expand Down Expand Up @@ -212,13 +212,13 @@ export function printTable(modules: IModule[], options: IListOptions = {}) {
addColumn(column.dependencies, dependencies !== 'none');
addColumn(column.dependants, showDependants);
addColumn(column.path, showPath);
(columns || []).forEach(col => addColumn(col));
(columns || []).forEach((col) => addColumn(col));

const head = cols.map(col => log.gray(col.head));
const head = cols.map((col) => log.gray(col.head));
const builder = log.table({ head, border: false });
modules.forEach(pkg => {
modules.forEach((pkg) => {
const row = [] as string[];
cols.forEach(col => row.push(`${col.render(pkg)} `));
cols.forEach((col) => row.push(`${col.render(pkg)} `));
builder.add(row);
});
builder.log();
Expand Down
Loading