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

Commit

Permalink
deps(boost): Update to v3. (#150)
Browse files Browse the repository at this point in the history
* Update deps.

* Fix some issues.

* Update optimal.

* Build fixes.

* Update core tests.

* Fix driver tests.

* Fix for windows.

* Fix for windows.

* Update and fix.

* Polish.
  • Loading branch information
milesj committed Nov 13, 2021
1 parent c895811 commit ba10988
Show file tree
Hide file tree
Showing 43 changed files with 604 additions and 281 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"@types/semver": "^7.3.9",
"conventional-changelog-beemo": "^2.1.0",
"lerna": "^4.0.0",
"packemon": "^1.7.0",
"packemon": "^1.7.1",
"ts-node": "^10.4.0",
"typescript": "^4.4.4",
"webpack": "^5.63.0"
Expand Down
6 changes: 3 additions & 3 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@
"access": "public"
},
"dependencies": {
"@boost/cli": "^2.11.2",
"@boost/common": "^2.8.2",
"@boost/pipeline": "^2.2.8",
"@boost/cli": "^3.0.1",
"@boost/common": "^3.1.0",
"@boost/pipeline": "^3.2.0",
"debug": "^4.3.2",
"ink": "^3.2.0",
"react": "^17.0.2"
Expand Down
6 changes: 3 additions & 3 deletions packages/cli/src/commands/RunDriver.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Blueprint, DriverContextOptions, DriverContextParams, Predicates } from '@beemo/core';
import { Blueprint, DriverContextOptions, DriverContextParams, Schemas } from '@beemo/core';
import { Arg, Argv, Config } from '@boost/cli';
import { tool } from '../setup';
import { BaseRunCommand } from './BaseRunCommand';
Expand Down Expand Up @@ -29,9 +29,9 @@ export class RunDriver extends BaseRunCommand<DriverContextOptions, [], RunDrive
return this.renderDriver(pipeline);
}

override blueprint({ array, string }: Predicates): Blueprint<RunDriverConfig> {
override blueprint({ array, string }: Schemas): Blueprint<RunDriverConfig> {
return {
parallelArgv: array(array(string())),
parallelArgv: array().of(array().of(string())),
};
}
}
17 changes: 12 additions & 5 deletions packages/cli/src/createDriverCommand.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* eslint-disable max-classes-per-file */

import { Driver, DriverContextOptions } from '@beemo/core';
import { Argv, Config, GlobalOptions, ParserOptions } from '@boost/cli';
import { BaseRunCommand } from './commands/BaseRunCommand';
Expand Down Expand Up @@ -43,11 +45,16 @@ export function createDriverCommand(

// Register sub-commands for the driver
driver.commands.forEach(({ path: subpath, config, runner }) => {
command.register<{}, []>(
`${path}:${subpath}`,
{ ...config, category: 'driver' },
(options, params, rest) => runner(tool, options, params, rest),
);
@Config(`${path}:${subpath}`, config.description, { ...config, category: 'driver' })
class DriverSubCommand extends BaseRunCommand<{}, [], {}> {
async run() {
const args = this.getArguments();

return runner(tool, args.options, args.params, args.rest);
}
}

command.register(new DriverSubCommand());
});

return command;
Expand Down
26 changes: 13 additions & 13 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,18 @@
"access": "public"
},
"dependencies": {
"@boost/args": "^2.3.4",
"@boost/common": "^2.8.2",
"@boost/config": "^2.5.2",
"@boost/debug": "^2.2.8",
"@boost/event": "^2.3.3",
"@boost/internal": "^2.2.3",
"@boost/log": "^2.2.8",
"@boost/module": "^2.0.0",
"@boost/pipeline": "^2.2.8",
"@boost/plugin": "^2.4.2",
"@boost/terminal": "^2.2.3",
"@boost/translate": "^2.2.8",
"@boost/args": "^3.0.0",
"@boost/common": "^3.1.0",
"@boost/config": "^3.0.2",
"@boost/debug": "^3.0.1",
"@boost/event": "^3.0.0",
"@boost/internal": "^3.0.0",
"@boost/log": "^3.0.1",
"@boost/module": "^3.0.1",
"@boost/pipeline": "^3.2.0",
"@boost/plugin": "^3.0.2",
"@boost/terminal": "^3.0.0",
"@boost/translate": "^3.0.1",
"execa": "^5.1.1",
"fast-glob": "^3.2.7",
"fs-extra": "^10.0.0",
Expand All @@ -62,7 +62,7 @@
"micromatch": "^4.0.4"
},
"devDependencies": {
"@boost/test-utils": "^2.3.2",
"@boost/test-utils": "^3.0.0",
"@types/micromatch": "^4.0.2"
},
"funding": {
Expand Down
29 changes: 14 additions & 15 deletions packages/core/src/Config.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { Blueprint, Predicates } from '@boost/common';
import { Configuration, createPluginsPredicate, mergePlugins } from '@boost/config';
// import { STRATEGY_BUFFER, STRATEGY_NONE, STRATEGY_PIPE, STRATEGY_STREAM } from './constants';
import { Blueprint, Schemas } from '@boost/common';
import { Configuration, createPluginsSchema, mergePlugins } from '@boost/config';
import { STRATEGY_BUFFER, STRATEGY_NONE, STRATEGY_PIPE, STRATEGY_STREAM } from './constants';
import { ConfigExecuteStrategy, ConfigFile } from './types';

export class Config extends Configuration<ConfigFile> {
blueprint(predicates: Predicates, onConstruction: boolean): Blueprint<ConfigFile> {
const { bool, number, object, shape, string } = predicates;
blueprint(schemas: Schemas, onConstruction: boolean): Blueprint<ConfigFile> {
const { bool, number, object, shape, string } = schemas;
const moduleSchema = string(process.env.BEEMO_CONFIG_MODULE);

return {
Expand All @@ -14,21 +14,20 @@ export class Config extends Configuration<ConfigFile> {
parallel: bool(true),
}),
debug: bool(),
drivers: createPluginsPredicate(predicates),
drivers: createPluginsSchema(schemas),
execute: shape({
concurrency: number(3).gt(0),
graph: bool(true),
// Optimal requires a fix upstream. Does not support empty strings!
output: string<ConfigExecuteStrategy>() /* .oneOf<ConfigExecuteStrategy>([
'',
STRATEGY_BUFFER,
STRATEGY_PIPE,
STRATEGY_STREAM,
STRATEGY_NONE,
]), */,
output: string().oneOf<ConfigExecuteStrategy>([
'',
STRATEGY_BUFFER,
STRATEGY_PIPE,
STRATEGY_STREAM,
STRATEGY_NONE,
]),
}),
module: onConstruction ? moduleSchema : moduleSchema.required().notEmpty(),
scripts: createPluginsPredicate(predicates),
scripts: createPluginsSchema(schemas),
settings: object(),
};
}
Expand Down
23 changes: 12 additions & 11 deletions packages/core/src/Driver.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import execa from 'execa';
import mergeWith from 'lodash/mergeWith';
import { PrimitiveType } from '@boost/args';
import { Blueprint, isObject, optimal, Path, Predicates, predicates, toArray } from '@boost/common';
import { isObject, Path, toArray } from '@boost/common';
import { Blueprint, optimal, Schemas, schemas } from '@boost/common/optimal';
import { ConcurrentEvent, Event } from '@boost/event';
import { Plugin } from '@boost/plugin';
import {
Expand Down Expand Up @@ -92,9 +93,9 @@ export abstract class Driver<
}
}

blueprint({ array, object, string, bool }: Predicates): Blueprint<DriverOptions> {
blueprint({ array, object, string, bool }: Schemas): Blueprint<DriverOptions> {
return {
args: array(string()),
args: array().of(string()),
configStrategy: string(STRATEGY_NATIVE).oneOf<DriverConfigStrategy>([
STRATEGY_NATIVE,
STRATEGY_CREATE,
Expand All @@ -103,8 +104,8 @@ export abstract class Driver<
STRATEGY_COPY,
STRATEGY_NONE,
]),
dependencies: array(string()),
env: object(string()),
dependencies: array().of(string()),
env: object().of(string()),
expandGlobs: bool(true),
outputStrategy: string(STRATEGY_BUFFER).oneOf<DriverOutputStrategy>([
STRATEGY_BUFFER,
Expand Down Expand Up @@ -252,15 +253,14 @@ export abstract class Driver<
* Set metadata about the binary/executable in which this driver wraps.
*/
setMetadata(metadata: Partial<DriverMetadata>): this {
const { array, bool, string, object, shape } = predicates;
const { array, bool, string, object, shape } = schemas;

this.metadata = optimal(
metadata,
{
bin: string()
.match(/^[a-z]{1}[a-zA-Z0-9-]+$/u)
.required(),
commandOptions: object(
commandOptions: object().of(
shape({
description: string().required(),
type: string().oneOf<'boolean' | 'number' | 'string'>(['string', 'number', 'boolean']),
Expand All @@ -272,21 +272,22 @@ export abstract class Driver<
STRATEGY_CREATE,
STRATEGY_REFERENCE,
STRATEGY_COPY,
STRATEGY_TEMPLATE,
]),
dependencies: array(string()),
dependencies: array().of(string()),
description: string(),
filterOptions: bool(true),
helpOption: string('--help'),
title: string().required(),
useConfigOption: bool(),
versionOption: string('--version'),
watchOptions: array(string()),
watchOptions: array().of(string()),
workspaceStrategy: string(STRATEGY_REFERENCE).oneOf([STRATEGY_REFERENCE, STRATEGY_COPY]),
},
{
name: this.constructor.name,
},
);
).validate(metadata);

return this;
}
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/Script.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import execa, { Options as ExecaOptions } from 'execa';
import { Arguments, ParserOptions } from '@boost/args';
import { Blueprint, Predicates } from '@boost/common';
import { Blueprint, Schemas } from '@boost/common';
import { ConcurrentEvent } from '@boost/event';
import { Plugin } from '@boost/plugin';
import { ScriptContext } from './contexts/ScriptContext';
Expand Down Expand Up @@ -32,7 +32,7 @@ export abstract class Script<O extends object = {}, Options extends object = {}>
}
}

blueprint(preds: Predicates): Blueprint<object> {
blueprint(schemas: Schemas): Blueprint<object> {
return {};
}

Expand Down
14 changes: 7 additions & 7 deletions packages/core/src/Tool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import {
Path,
PathResolver,
PortablePath,
Predicates,
Project,
Schemas,
} from '@boost/common';
import { createDebugger, Debugger } from '@boost/debug';
import { Event } from '@boost/event';
Expand Down Expand Up @@ -110,12 +110,12 @@ export class Tool extends Contract<ToolOptions> {
this.configManager = new Config(this.options.projectName, this.resolveForPnP);
}

blueprint({ array, instance, string, union }: Predicates): Blueprint<ToolOptions> {
blueprint({ array, instance, string, union }: Schemas): Blueprint<ToolOptions> {
return {
argv: array(string()),
cwd: union([instance(Path).notNullable(), string().notEmpty()], process.cwd()),
argv: array().of(string()),
cwd: union(process.cwd()).of([instance().of(Path).notNullable(), string().notEmpty()]),
projectName: string('beemo').camelCase().notEmpty(),
resourcePaths: array(string().notEmpty()),
resourcePaths: array().of(string().notEmpty()),
};
}

Expand Down Expand Up @@ -155,7 +155,7 @@ export class Tool extends Contract<ToolOptions> {
resolver.lookupNodeModule(module);
}

const { resolvedPath } = resolver.resolve();
const { resolvedPath } = await resolver.resolve();

bootstrapModule = requireModule(resolvedPath);
} catch {
Expand Down Expand Up @@ -278,7 +278,7 @@ export class Tool extends Contract<ToolOptions> {

this.debug('Running with %s v%s driver', driverName, version);

return new WaterfallPipeline(context, driverName)
return new WaterfallPipeline<typeof context, unknown>(context, driverName)
.pipe(
new ResolveConfigsRoutine('config', this.msg('app:configGenerate'), {
tool: this,
Expand Down
13 changes: 10 additions & 3 deletions packages/core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,14 @@
* @license https://opensource.org/licenses/MIT
*/

import { Blueprint, PackageStructure, Path, PortablePath, Predicates } from '@boost/common';
import {
Blueprint,
PackageStructure,
Path,
PortablePath,
Schemas,
VirtualPath,
} from '@boost/common';

export * from './constants';
export * from './contexts/ConfigContext';
Expand All @@ -16,5 +23,5 @@ export * from './Script';
export * from './Tool';
export * from './types';

export { Path };
export type { Blueprint, PackageStructure, PortablePath, Predicates };
export { Path, VirtualPath };
export type { Blueprint, PackageStructure, PortablePath, Schemas };
4 changes: 2 additions & 2 deletions packages/core/src/routines/CleanupConfigsRoutine.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
/* eslint-disable @typescript-eslint/member-ordering */

import fs from 'fs-extra';
import { Bind, Blueprint, Predicates } from '@boost/common';
import { Bind, Blueprint, Schemas } from '@boost/common';
import { color } from '@boost/internal';
import { Routine } from '@boost/pipeline';
import { DriverContext } from '../contexts/DriverContext';
import type { Tool } from '../Tool';
import { RoutineOptions } from '../types';

export class CleanupConfigsRoutine extends Routine<unknown, unknown, RoutineOptions> {
blueprint({ instance }: Predicates): Blueprint<RoutineOptions> {
blueprint({ instance }: Schemas): Blueprint<RoutineOptions> {
return {
tool: instance<Tool>().required().notNullable(),
};
Expand Down
Loading

0 comments on commit ba10988

Please sign in to comment.