-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
69 changed files
with
1,221 additions
and
1,121 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
packages/plugin-cmd-lib/README.md → packages/cli-types/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
# `cli` | ||
# `@xus/cli-types` | ||
|
||
> TODO: description | ||
## Usage | ||
|
||
``` | ||
const cli = require('cli'); | ||
const cliUtils = require('@xus/cli-types'); | ||
// TODO: DEMONSTRATE API | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
{ | ||
"name": "@xus/cli-types", | ||
"version": "0.1.0", | ||
"description": "cli utils", | ||
"main": "./dist/index.js", | ||
"types": "./dist/index.d.ts", | ||
"keywords": [ | ||
"utils" | ||
], | ||
"author": "guo.xu <xuguo@outlook.it>", | ||
"homepage": "https://github.com/xus-code/bundle-tools/tree/master/packages/cli-utils#readme", | ||
"license": "MIT", | ||
"files": [ | ||
"dist" | ||
], | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/xus-code/cli.git" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/xus-code/cli/issues" | ||
}, | ||
"scripts": { | ||
"build:types": "tsc" | ||
}, | ||
"dependencies": { | ||
"@xus/cli-shared": "^0.1.4", | ||
"@xus/core": "^0.1.5", | ||
"@xus/rollup-chain": "^0.2.6", | ||
"esbuild": "^0.9.2", | ||
"webpack-chain": "^6.5.1" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import webpackChain from 'webpack-chain' | ||
// empty | ||
import { IPlugin, IPreset, IConfig } from './types' | ||
|
||
type IReturnArg<T extends any> = (args: T) => T | ||
|
||
type PartialDeep<T extends Record<string, any>> = { | ||
[K in keyof T]?: T[K] extends Record<string, unknown> | ||
? PartialDeep<T[K]> | ||
: T[K] | ||
} | ||
|
||
export const defineConfig: IReturnArg<PartialDeep<IConfig>> = (config) => config | ||
|
||
export const createPlugin: IReturnArg<IPlugin> = (plugin) => plugin | ||
|
||
export const createPreset: IReturnArg<IPreset> = (preset) => preset | ||
|
||
// types | ||
export * from './types' | ||
|
||
export type { IArgs, IRawArgs, ICommand } from '@xus/core' | ||
|
||
export type { IRollupChain, IRollupChainConfig } from '@xus/rollup-chain' | ||
|
||
export type IWebpackChain = webpackChain |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
import { | ||
IPlugin as IPluginBase, | ||
IFastHookRegister, | ||
IArgs, | ||
IRawArgs, | ||
IPluginAPI as IPluginAPIBase, | ||
IPathManager, | ||
IConfigManager, | ||
IEnvManager, | ||
IPluginManager, | ||
IProjectConfig | ||
} from '@xus/core' | ||
import type { IBabelRegister, IRunCmdMessage } from '@xus/cli-shared' | ||
// preset api | ||
import type { IRollupChain, IRollupChainConfig } from '@xus/rollup-chain' | ||
import webpackChain from 'webpack-chain' | ||
import { TransformOptions } from 'esbuild' | ||
|
||
// Hooks Types | ||
// type IEvent = any | ||
// type ISerial = any | ||
// type IParallel = any | ||
// type IAdd = any | ||
|
||
// IPluginAPI | ||
type noopFn = () => any | ||
|
||
export interface IPluginAPI extends IPluginAPIBase { | ||
// service api | ||
BabelRegister: IBabelRegister | ||
// service lifycycle | ||
onSetuped: (config: IConfig) => void | ||
onRunCmd: noopFn | ||
getCmdArgs: () => { args: IArgs; rawArgs: IRawArgs } | ||
modifyProjectConfig: (config: IConfig) => void | ||
|
||
// path manager | ||
cwd: IPathManager['cwd'] | ||
cwdPkg: IPathManager['cwdPkg'] | ||
userConfigPath: IPathManager['userConfigPath'] | ||
getPathBasedOnCtx: IPathManager['getPathBasedOnCtx'] | ||
getLernaPkgs: IPathManager['getLernaPkgs'] | ||
|
||
// env manager | ||
mode: IEnvManager['mode'] | ||
babelEnv: IEnvManager['babelEnv'] | ||
getEnv: IEnvManager['getEnv'] | ||
setEnv: IEnvManager['setEnv'] | ||
getCliEnv: IEnvManager['getCliEnv'] | ||
setCliEnv: IEnvManager['setCliEnv'] | ||
|
||
// config manager | ||
projectConfig: IConfig | ||
cwdPkgJson: IConfigManager['cwdPkgJson'] | ||
loadConfig: IConfigManager['loadConfig'] | ||
|
||
// plugin manager | ||
skipPlugin: IPluginManager['skipPlugin'] | ||
|
||
// rollup | ||
modifyRollupConfig: IFastHookRegister<(rc: IRollupChain) => IRollupChain> | ||
getRollupConfig: () => Promise<IRollupChainConfig> | ||
// webpack | ||
modifyWebpackConfig: IFastHookRegister<(wc: webpackChain) => webpackChain> | ||
getWebpackConfig: () => Promise<any> | ||
} | ||
|
||
// IConfig | ||
export interface IConfig extends IProjectConfig { | ||
libBuild: { | ||
libName: string | ||
// transform: 'esbuild' | 'babel' | ||
minify: false | 'esbuild' | 'terser' | ||
target: 'esnext' | TransformOptions['target'] | ||
formats: ('esm' | 'cjs' | 'iife' | 'umd')[] | ||
rollTypes: boolean | ||
sourcemap: boolean | ||
alwaysEmptyDistDir: boolean | ||
|
||
// lerna mode | ||
pkgsOrder: string[] | ||
|
||
// insider | ||
rollupChain: (rc: IRollupChain) => IRollupChain | ||
} | ||
lint: { | ||
eslint: | ||
| boolean | ||
| { | ||
include?: string | ||
ext?: string[] | ||
} | ||
stylelint: | ||
| boolean | ||
| { | ||
include?: string[] | ||
} | ||
} | ||
changelog: { | ||
filename: string | ||
mainTemplate: string | ||
headerPartial: string | ||
commitPartial: string | ||
} | ||
release: { | ||
// before hooks for run lint test build... | ||
beforeRelease: { | ||
bin: string | ||
args: string[] | ||
message: IRunCmdMessage | ||
}[] | ||
// in lenra mode to ensure pkg publish order | ||
order: string[] | ||
branch: string | ||
} | ||
} | ||
|
||
// IPlugin | ||
export type IPlugin = IPluginBase<(api: IPluginAPI) => void> | ||
|
||
// IPreset | ||
export interface IPreset { | ||
plugins: IPlugin[] | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,5 @@ | ||
export * from '@xus/cli-shared' | ||
export { CliService, HookTypes } from '@xus/core' | ||
// compose plugin with core | ||
export * from './exports' | ||
// plugins | ||
export * from '@xus/preset-built-in' | ||
|
||
// types | ||
export type { | ||
IArgs, | ||
IRawArgs, | ||
ICommand, | ||
IHook, | ||
IFastHookRegister | ||
} from '@xus/core' | ||
export * from '@xus/cli-types' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.