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

Commit 8996d55

Browse files
authored
build: Switch to @beemo/dev for configs. (#131)
* Update babel/jest. * Update typescript. * Update prettier. * Update eslint. * Update eslint. * Fix test. * update deps. * Add jest dep. * Reduce code coverage. * Fix int test. * Dont fail. * Update deps. * More fixes.
1 parent ebdaaf2 commit 8996d55

File tree

123 files changed

+1179
-945
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

123 files changed

+1179
-945
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ jobs:
1111
strategy:
1212
matrix:
1313
os: [ubuntu-latest, windows-latest]
14-
node-version: [10, 12, 14]
15-
fail-fast: true
14+
node-version: [10, 12, 14, 16]
15+
fail-fast: false
1616
steps:
1717
- uses: actions/checkout@v2
1818
- uses: actions/setup-node@v2

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ mocha.opts
3636
prettier.config.js
3737
rollup.config.js
3838
webpack.config.js
39-
tsconfig.eslint.json
4039
*.tsbuildinfo
4140

4241
# Tests

package.json

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,21 +26,22 @@
2626
"task:args": "ts-node packages/local/src/bins/extractOptionList.ts"
2727
},
2828
"devDependencies": {
29-
"@types/eslint": "^7.2.9",
29+
"@types/eslint": "^7.2.10",
3030
"@types/fs-extra": "^9.0.11",
3131
"@types/is-glob": "^4.0.1",
32+
"@types/jest": "^26.0.23",
3233
"@types/lodash": "^4.14.168",
33-
"@types/node": "^14.14.37",
34+
"@types/node": "^14.14.44",
3435
"@types/prettier": "^2.2.3",
35-
"@types/react": "^16.14.5",
36+
"@types/react": "^16.14.6",
3637
"@types/rimraf": "^3.0.0",
37-
"@types/semver": "^7.3.4",
38+
"@types/semver": "^7.3.5",
3839
"conventional-changelog-beemo": "^2.1.0",
3940
"lerna": "^4.0.0",
40-
"packemon": "^0.15.0",
41+
"packemon": "^0.15.1",
4142
"ts-node": "^9.1.1",
4243
"typescript": "^4.2.4",
43-
"webpack": "^5.32.0"
44+
"webpack": "^5.36.2"
4445
},
4546
"resolutions": {
4647
"chalk": "^4.0.0",
@@ -50,6 +51,10 @@
5051
"packages/*",
5152
"website"
5253
],
54+
"engines": {
55+
"node": ">=10.3.0",
56+
"npm": ">=6.1.0"
57+
},
5358
"funding": {
5459
"type": "ko-fi",
5560
"url": "https://ko-fi.com/milesjohnson"

packages/cli/src/bin.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import CreateConfig from './commands/CreateConfig';
2-
import RunDriver from './commands/RunDriver';
3-
import RunScript from './commands/RunScript';
4-
import Scaffold from './commands/Scaffold';
5-
import createDriverCommand from './createDriverCommand';
1+
import { CreateConfig } from './commands/CreateConfig';
2+
import { RunDriver } from './commands/RunDriver';
3+
import { RunScript } from './commands/RunScript';
4+
import { Scaffold } from './commands/Scaffold';
5+
import { createDriverCommand } from './createDriverCommand';
66
import { argv, parallelArgv, program, tool } from './setup';
77

88
async function run() {

packages/cli/src/commands/BaseRunCommand.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Arg, Command, GlobalOptions, PrimitiveType } from '@boost/cli';
22
import { tool } from '../setup';
33

4-
export default abstract class BaseRunCommand<
4+
export abstract class BaseRunCommand<
55
O extends object,
66
P extends PrimitiveType[],
77
C extends object = {}

packages/cli/src/commands/CreateConfig.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { tool } from '../setup';
66
allowVariadicParams: 'names',
77
category: 'core',
88
})
9-
export default class CreateConfig extends Command<GlobalOptions> {
9+
export class CreateConfig extends Command<GlobalOptions> {
1010
async run(...names: string[]) {
1111
const pipeline = tool.createConfigurePipeline(this.getArguments(), names);
1212

packages/cli/src/commands/RunDriver.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Blueprint, DriverContextOptions, DriverContextParams, Predicates } from '@beemo/core';
22
import { Arg, Argv, Config } from '@boost/cli';
33
import { tool } from '../setup';
4-
import BaseRunCommand from './BaseRunCommand';
4+
import { BaseRunCommand } from './BaseRunCommand';
55

66
export interface RunDriverConfig {
77
parallelArgv?: Argv[];
@@ -12,7 +12,7 @@ export interface RunDriverConfig {
1212
allowVariadicParams: true,
1313
category: 'core',
1414
})
15-
export default class RunDriver extends BaseRunCommand<DriverContextOptions, [], RunDriverConfig> {
15+
export class RunDriver extends BaseRunCommand<DriverContextOptions, [], RunDriverConfig> {
1616
@Arg.Params<DriverContextParams>({
1717
description: tool.msg('app:cliArgDriverName'),
1818
label: 'name',

packages/cli/src/commands/RunScript.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
import { ScriptContextOptions, ScriptContextParams } from '@beemo/core';
22
import { Arg, Config } from '@boost/cli';
33
import { tool } from '../setup';
4-
import BaseRunCommand from './BaseRunCommand';
4+
import { BaseRunCommand } from './BaseRunCommand';
55

66
@Config('run-script', tool.msg('app:cliCommandRunScript'), {
77
aliases: ['run'],
88
allowUnknownOptions: true,
99
allowVariadicParams: true,
1010
category: 'core',
1111
})
12-
export default class RunScript extends BaseRunCommand<ScriptContextOptions, ScriptContextParams> {
12+
export class RunScript extends BaseRunCommand<ScriptContextOptions, ScriptContextParams> {
1313
@Arg.Params<ScriptContextParams>({
1414
description: tool.msg('app:cliArgScriptName'),
1515
label: 'name',

packages/cli/src/commands/Scaffold.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { Arg, Command, Config, GlobalOptions } from '@boost/cli';
33
import { tool } from '../setup';
44

55
@Config('scaffold', tool.msg('app:cliCommandScaffold'), { category: 'core' })
6-
export default class Scaffold extends Command<
6+
export class Scaffold extends Command<
77
GlobalOptions & ScaffoldContextOptions,
88
ScaffoldContextParams
99
> {

packages/cli/src/createDriverCommand.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { Driver, DriverContextOptions } from '@beemo/core';
22
import { Argv, Config, GlobalOptions, ParserOptions } from '@boost/cli';
3-
import BaseRunCommand from './commands/BaseRunCommand';
3+
import { BaseRunCommand } from './commands/BaseRunCommand';
44
import { tool } from './setup';
55

6-
export default function createDriverCommand(
6+
export function createDriverCommand(
77
driver: Driver,
88
parallelArgv?: Argv[],
99
): BaseRunCommand<DriverContextOptions, []> {

packages/cli/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44
*/
55

66
// Export command to extend from
7+
export {};

packages/cli/src/parseSpecialArgv.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export interface ParsedArgv {
88
/**
99
* Extract parallel commands and options into separate argv lists.
1010
*/
11-
export default function parseSpecialArgv(argv: Argv): ParsedArgv {
11+
export function parseSpecialArgv(argv: Argv): ParsedArgv {
1212
const main: Argv = [];
1313
const parallel: Argv[] = [];
1414
let index = -1;

packages/cli/src/setup.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
/* eslint-disable import/no-extraneous-dependencies */
1+
/* eslint-disable import/no-extraneous-dependencies, @typescript-eslint/prefer-nullish-coalescing */
22

33
import debug from 'debug';
4-
import { Tool } from '@beemo/core';
5-
import corePackage from '@beemo/core/package.json';
4+
import { PackageStructure, Tool } from '@beemo/core';
65
import { applyStyle, Program } from '@boost/cli';
7-
import parseSpecialArgv from './parseSpecialArgv';
6+
import { parseSpecialArgv } from './parseSpecialArgv';
87

98
const brandName = process.env.BEEMO_BRAND_NAME || 'Beemo';
109
const binName = process.env.BEEMO_BRAND_BINARY || 'beemo';
@@ -14,7 +13,6 @@ process.env.BOOSTJS_DEBUG_NAMESPACE = binName;
1413

1514
// Instrument our CLI for require() performance
1615
if (process.env.TIMING) {
17-
// eslint-disable-next-line global-require
1816
require('time-require');
1917

2018
// Boost doesn't enable the debugger early enough,
@@ -30,7 +28,7 @@ export const tool = new Tool({
3028
projectName: binName,
3129
});
3230

33-
const version = String(corePackage.version);
31+
const { version } = require('@beemo/core/package.json') as PackageStructure;
3432

3533
const footer = applyStyle(
3634
[tool.msg('app:cliEpilogue', { manualURL }), tool.msg('app:poweredBy', { version })].join('\n'),

packages/cli/tests/brandedBinary.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#!/usr/bin/env node
2-
/* eslint-disable */
2+
/* eslint-disable node/shebang */
33

44
process.env.BEEMO_BRAND_NAME = 'BMO';
55
process.env.BEEMO_BRAND_BINARY = 'bmo';
6-
process.env.BEEMO_CONFIG_MODULE = '@milesj/build-tool-config';
6+
process.env.BEEMO_CONFIG_MODULE = '@beemo/dev';
77
process.env.BEEMO_MANUAL_URL = 'https://bmo.dev';
88

99
require('../lib/bin');

packages/cli/tests/parseSpecialArgv.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import parseSpecialArgv from '../src/parseSpecialArgv';
1+
import { parseSpecialArgv } from '../src/parseSpecialArgv';
22

33
describe('parseSpecialArgv()', () => {
44
it('passes args through', () => {

packages/core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
"execa": "^5.0.0",
5555
"fast-glob": "^3.2.5",
5656
"fs-extra": "^9.1.0",
57-
"hygen": "^6.0.4",
57+
"hygen": "^6.1.0",
5858
"is-glob": "^4.0.1",
5959
"lodash": "^4.17.21",
6060
"micromatch": "^4.0.4"

packages/core/src/Config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Blueprint, Predicates } from '@boost/common';
22
import { Configuration, createPluginsPredicate, mergePlugins } from '@boost/config';
33
import { ConfigFile } from './types';
44

5-
export default class Config extends Configuration<ConfigFile> {
5+
export class Config extends Configuration<ConfigFile> {
66
blueprint(predicates: Predicates, onConstruction: boolean): Blueprint<ConfigFile> {
77
const { bool, number, object, shape, string } = predicates;
88
const moduleSchema = string(process.env.BEEMO_CONFIG_MODULE);

packages/core/src/Driver.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ import {
1212
STRATEGY_REFERENCE,
1313
STRATEGY_TEMPLATE,
1414
} from './constants';
15-
import ConfigContext from './contexts/ConfigContext';
16-
import DriverContext from './contexts/DriverContext';
17-
import isClassInstance from './helpers/isClassInstance';
15+
import { ConfigContext } from './contexts/ConfigContext';
16+
import { DriverContext } from './contexts/DriverContext';
17+
import { isClassInstance } from './helpers/isClassInstance';
1818
import {
1919
Argv,
2020
BeemoTool,
@@ -30,7 +30,7 @@ import {
3030
Execution,
3131
} from './types';
3232

33-
export default abstract class Driver<
33+
export abstract class Driver<
3434
Config extends object = {},
3535
Options extends DriverOptions = DriverOptions
3636
>
@@ -117,7 +117,8 @@ export default abstract class Driver<
117117
*/
118118
doMerge(prevValue: unknown, nextValue: unknown): unknown {
119119
if (Array.isArray(prevValue) && Array.isArray(nextValue)) {
120-
return Array.from(new Set(prevValue.concat(nextValue)));
120+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
121+
return [...new Set([...prevValue, ...nextValue])] as unknown;
121122
}
122123

123124
return undefined;
@@ -154,7 +155,7 @@ export default abstract class Driver<
154155
* Return a list of user defined arguments.
155156
*/
156157
getArgs(): Argv {
157-
return Array.isArray(this.options.args) ? this.options.args : [];
158+
return (Array.isArray(this.options.args) ? this.options.args : []) as Argv;
158159
}
159160

160161
/**

packages/core/src/Script.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ import { Arguments, ParserOptions } from '@boost/args';
33
import { Blueprint, Predicates } from '@boost/common';
44
import { ConcurrentEvent } from '@boost/event';
55
import { Plugin } from '@boost/plugin';
6-
import ScriptContext from './contexts/ScriptContext';
7-
import isClassInstance from './helpers/isClassInstance';
6+
import { ScriptContext } from './contexts/ScriptContext';
7+
import { isClassInstance } from './helpers/isClassInstance';
88
import { Argv, BeemoTool, Scriptable } from './types';
99

10-
export default abstract class Script<O extends object = {}, Options extends object = {}>
10+
export abstract class Script<O extends object = {}, Options extends object = {}>
1111
extends Plugin<BeemoTool, Options>
1212
implements Scriptable<O> {
1313
// Set within a life-cycle

packages/core/src/Tool.ts

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,20 @@ import { color } from '@boost/internal';
2020
import { WaterfallPipeline } from '@boost/pipeline';
2121
import { Registry } from '@boost/plugin';
2222
import { createTranslator, Translator } from '@boost/translate';
23-
import Config from './Config';
23+
import { Config } from './Config';
2424
import { KEBAB_PATTERN } from './constants';
25-
import ConfigContext from './contexts/ConfigContext';
26-
import Context from './contexts/Context';
27-
import DriverContext from './contexts/DriverContext';
28-
import ScaffoldContext from './contexts/ScaffoldContext';
29-
import ScriptContext from './contexts/ScriptContext';
30-
import Driver from './Driver';
31-
import CleanupConfigsRoutine from './routines/CleanupConfigsRoutine';
32-
import ResolveConfigsRoutine from './routines/ResolveConfigsRoutine';
33-
import RunDriverRoutine from './routines/RunDriverRoutine';
34-
import RunScriptRoutine from './routines/RunScriptRoutine';
35-
import ScaffoldRoutine from './routines/ScaffoldRoutine';
36-
import Script from './Script';
25+
import { ConfigContext } from './contexts/ConfigContext';
26+
import { Context } from './contexts/Context';
27+
import { DriverContext } from './contexts/DriverContext';
28+
import { ScaffoldContext } from './contexts/ScaffoldContext';
29+
import { ScriptContext } from './contexts/ScriptContext';
30+
import { Driver } from './Driver';
31+
import { CleanupConfigsRoutine } from './routines/CleanupConfigsRoutine';
32+
import { ResolveConfigsRoutine } from './routines/ResolveConfigsRoutine';
33+
import { RunDriverRoutine } from './routines/RunDriverRoutine';
34+
import { RunScriptRoutine } from './routines/RunScriptRoutine';
35+
import { ScaffoldRoutine } from './routines/ScaffoldRoutine';
36+
import { Script } from './Script';
3737
import { Argv, BootstrapFile, ConfigFile } from './types';
3838

3939
export interface ToolOptions {
@@ -43,7 +43,7 @@ export interface ToolOptions {
4343
resourcePaths?: string[];
4444
}
4545

46-
export default class Tool extends Contract<ToolOptions> {
46+
export class Tool extends Contract<ToolOptions> {
4747
config!: ConfigFile;
4848

4949
context?: Context;
@@ -83,8 +83,7 @@ export default class Tool extends Contract<ToolOptions> {
8383
this.cwd = Path.create(this.options.cwd);
8484

8585
this.debug = createDebugger('core');
86-
// eslint-disable-next-line global-require
87-
this.debug('Using beemo v%s', require('../package.json').version);
86+
this.debug('Using beemo v%s', (require('../package.json') as PackageStructure).version);
8887

8988
this.msg = createTranslator(
9089
['app', 'common', 'errors'],
@@ -157,7 +156,7 @@ export default class Tool extends Contract<ToolOptions> {
157156
return this;
158157
}
159158

160-
const bootstrap = bootstrapModule?.bootstrap || bootstrapModule?.default || bootstrapModule;
159+
const bootstrap = bootstrapModule?.bootstrap ?? bootstrapModule?.default ?? bootstrapModule;
161160
const isFunction = typeof bootstrap === 'function';
162161

163162
this.debug.invariant(isFunction, 'Executing bootstrap function', 'Found', 'Not found');

packages/core/src/contexts/ConfigContext.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import Driver from '../Driver';
2-
import Context from './Context';
1+
import { Driver } from '../Driver';
2+
import { Context } from './Context';
33

4-
export default class ConfigContext<O extends object = {}> extends Context<O, string[]> {
4+
export class ConfigContext<O extends object = {}> extends Context<O, string[]> {
55
// List of drivers involved in the current pipeline
66
drivers: Set<Driver> = new Set();
77

packages/core/src/contexts/Context.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export interface ConfigPath {
1010
path: Path;
1111
}
1212

13-
export default class Context<
13+
export class Context<
1414
O extends object = {},
1515
P extends PrimitiveType[] = PrimitiveType[]
1616
> extends BaseContext {
@@ -61,10 +61,11 @@ export default class Context<
6161
addOption(arg: string, defaultValue: PrimitiveType = true, useEquals: boolean = false): this {
6262
let option = arg;
6363
let value = defaultValue;
64+
let equals = useEquals;
6465

6566
if (option.includes('=')) {
6667
[option, value] = option.split('=');
67-
useEquals = true;
68+
equals = true;
6869
}
6970

7071
let name = trim(option, '-');
@@ -85,7 +86,7 @@ export default class Context<
8586

8687
if (typeof value === 'boolean' || !value) {
8788
this.argv.push(option);
88-
} else if (useEquals) {
89+
} else if (equals) {
8990
this.argv.push(`${option}=${value}`);
9091
} else {
9192
this.argv.push(option, String(value));
@@ -147,8 +148,7 @@ export default class Context<
147148
* or null if not found.
148149
*/
149150
getRiskyOption(name: string, raw: boolean = false): PrimitiveType | null {
150-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
151-
let opt: any = this.getOption(name as keyof O);
151+
let opt = (this.getOption(name as keyof O) as unknown) as PrimitiveType;
152152

153153
if (opt !== null) {
154154
return opt;

0 commit comments

Comments
 (0)