Skip to content
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
5 changes: 5 additions & 0 deletions .changeset/dep-hygiene-colors-async.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"oc": patch
---

Replace unmaintained `colors` with `picocolors` via a central color helper, and remove unused `async` / `@types/async` dependencies.
22 changes: 2 additions & 20 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions packages/oc/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
"devDependencies": {
"@biomejs/biome": "^2.5.0",
"@types/accept-language-parser": "^1.5.8",
"@types/async": "^3.2.25",
"@types/bun": "^1.3.14",
"@types/cookie-parser": "^1.4.10",
"@types/cross-spawn": "^6.0.6",
Expand Down Expand Up @@ -74,11 +73,9 @@
"@rdevis/turbo-stream": "^2.4.1",
"@types/lodash.isequal": "^4.5.8",
"accept-language-parser": "^1.5.0",
"async": "^3.2.6",
"basic-auth-connect": "^1.1.0",
"builtin-modules": "^3.3.0",
"chokidar": "^4.0.3",
"colors": "^1.4.0",
"cookie-parser": "^1.4.7",
"cross-spawn": "^7.0.6",
"dependency-graph": "^1.0.0",
Expand Down Expand Up @@ -109,6 +106,7 @@
"oc-template-jade-compiler": "^7.5.0",
"open": "^10.2.0",
"parse-author": "^2.0.0",
"picocolors": "^1.1.1",
"read": "^1.0.7",
"require-package-name": "^2.0.1",
"response-time": "^2.3.4",
Expand Down
3 changes: 1 addition & 2 deletions packages/oc/src/cli/facade/dev.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import path from 'node:path';
import { promisify } from 'node:util';
import colors from 'colors/safe';
import getPortCb from 'getport';
import livereload from 'livereload';
import { fromPromise } from 'universalify';

import * as oc from '../../index';
import strings from '../../resources/index';
import colors from '../../utils/colors';
import getMockedPlugins from '../domain/get-mocked-plugins';
import handleDependencies from '../domain/handle-dependencies';
import type { Local } from '../domain/local';
Expand Down
2 changes: 1 addition & 1 deletion packages/oc/src/cli/facade/publish.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import path from 'node:path';
import { promisify } from 'node:util';
import colors from 'colors/safe';
import fs from 'fs-extra';
import readCb from 'read';
import { fromPromise } from 'universalify';
import strings from '../../resources/index';
import type { Component } from '../../types';
import colors from '../../utils/colors';
import handleDependencies from '../domain/handle-dependencies';
import type { Local } from '../domain/local';
import type { RegistryCli } from '../domain/registry';
Expand Down
2 changes: 1 addition & 1 deletion packages/oc/src/cli/facade/validate.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import path from 'node:path';
import colors from 'colors/safe';
import fs from 'fs-extra';
import { fromPromise } from 'universalify';
import strings from '../../resources/index';
import type { Component } from '../../types';
import colors from '../../utils/colors';
import handleDependencies from '../domain/handle-dependencies';
import type { Local } from '../domain/local';
import type { RegistryCli } from '../domain/registry';
Expand Down
14 changes: 2 additions & 12 deletions packages/oc/src/cli/logger.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,6 @@
import colors from 'colors/safe';
import colors from '../utils/colors';

type Color =
| 'black'
| 'red'
| 'green'
| 'yellow'
| 'blue'
| 'magenta'
| 'cyan'
| 'white'
| 'gray'
| 'grey';
type Color = keyof typeof colors;

const logFns = {
writeLn: console.log,
Expand Down
2 changes: 1 addition & 1 deletion packages/oc/src/registry/app-start.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import path from 'node:path';
import colors from 'colors/safe';
import fs from 'fs-extra';
import type { Config } from '../types';
import colors from '../utils/colors';
import type { Repository } from './domain/repository';

const packageInfo = fs.readJsonSync(
Expand Down
3 changes: 1 addition & 2 deletions packages/oc/src/registry/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import type http from 'node:http';
import colors from 'colors/safe';

import type { Plugin } from '../types';
import colors from '../utils/colors';
import appStart from './app-start';
import eventsHandler from './domain/events-handler';
import type {
Expand Down
2 changes: 1 addition & 1 deletion packages/oc/src/resources/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { green, yellow } from 'colors/safe';
import { green, yellow } from '../utils/colors';

// Kind of long multi-string messages and functions

Expand Down
29 changes: 29 additions & 0 deletions packages/oc/src/utils/colors.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import pc from 'picocolors';

const colors = {
black: pc.black,
red: pc.red,
green: pc.green,
yellow: pc.yellow,
blue: pc.blue,
magenta: pc.magenta,
cyan: pc.cyan,
white: pc.white,
gray: pc.gray,
grey: pc.gray
};

export const {
black,
red,
green,
yellow,
blue,
magenta,
cyan,
white,
gray,
grey
} = colors;

export default colors;
55 changes: 30 additions & 25 deletions packages/oc/tasks/mochaTest.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
const async = require('async');
const fs = require('fs-extra');
const glob = require('glob');
const log = require('./logger');
const Mocha = require('mocha');
const minimist = require('minimist');
const oc = require('../dist');
const path = require('node:path');
const { promisify } = require('node:util');

const mocha = new Mocha({ timeout: 20000 });
const argv = minimist(process.argv.slice(2), { boolean: 'silent' });
Expand All @@ -24,32 +24,37 @@ const componentsToPackage = fs
.readdirSync(componentsFixturesPath)
.filter((x) => x !== 'handlebars3-component');

const packageComponent = (componentName, done) =>
oc.cli.package(
{
componentPath: path.join(componentsFixturesPath, componentName),
compress: false
},
(err) => done(err)
);

const addTestSuite = (dir, done) =>
glob(path.join(__dirname, '..', dir), (err, files) => {
for (const file of files) {
mocha.addFile(file);
}
done();
const packageComponent = (componentName) =>
new Promise((resolve, reject) => {
oc.cli.package(
{
componentPath: path.join(componentsFixturesPath, componentName),
compress: false
},
(err) => (err ? reject(err) : resolve())
);
});

async.eachSeries(componentsToPackage, packageComponent, (err) => {
if (err) {
const globAsync = promisify(glob);

const addTestSuite = async (dir) => {
const files = await globAsync(path.join(__dirname, '..', dir));
for (const file of files) {
mocha.addFile(file);
}
};

(async () => {
try {
for (const componentName of componentsToPackage) {
await packageComponent(componentName);
}
log.complete('Test components packaged');

await Promise.all(testDirs.map(addTestSuite));
mocha.run((err) => process.on('exit', () => process.exit(err)));
} catch (err) {
log.error(`Error during test components packaging: ${err}`);
process.exit(1);
} else {
log.complete('Test components packaged');
}

async.each(testDirs, addTestSuite, () =>
mocha.run((err) => process.on('exit', () => process.exit(err)))
);
});
})();
2 changes: 1 addition & 1 deletion packages/oc/test/unit/cli-facade-publish.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const colors = require('colors/safe');
const colors = require('../../dist/utils/colors').default;
const expect = require('chai').expect;
const injectr = require('injectr');
const path = require('node:path');
Expand Down
Loading