-
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.
feat: 新增changelog,lint,release,clean指令
- Loading branch information
Showing
33 changed files
with
2,013 additions
and
114 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
lib | ||
dist | ||
node_modules | ||
*.md | ||
LICENSE |
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 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,16 @@ | ||
import { mkdirSync, readdirSync, statSync, copyFileSync } from 'fs' | ||
import { resolve } from 'path' | ||
|
||
export function copyDir(srcDir: string, destDir: string) { | ||
mkdirSync(destDir, { recursive: true }) | ||
for (const file of readdirSync(srcDir)) { | ||
const srcFile = resolve(srcDir, file) | ||
const destFile = resolve(destDir, file) | ||
const stat = statSync(srcFile) | ||
if (stat.isDirectory()) { | ||
copyDir(srcFile, destFile) | ||
} else { | ||
copyFileSync(srcFile, destFile) | ||
} | ||
} | ||
} |
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,17 @@ | ||
import { existsSync, readdirSync, lstatSync, rmdirSync, unlinkSync } from 'fs' | ||
import { resolve } from 'path' | ||
|
||
export function emptyDir(dir: string) { | ||
if (!existsSync(dir)) { | ||
return | ||
} | ||
for (const file of readdirSync(dir)) { | ||
const abs = resolve(dir, file) | ||
if (lstatSync(abs).isDirectory()) { | ||
emptyDir(abs) | ||
rmdirSync(abs) | ||
} else { | ||
unlinkSync(abs) | ||
} | ||
} | ||
} |
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,2 +1,6 @@ | ||
export * from './getFileMeta' | ||
export * from './lookUpFile' | ||
export * from './removeDirOrFile' | ||
export * from './writeFile' | ||
export * from './emptyDir' | ||
export * from './copyDir' |
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,5 @@ | ||
import { rimraf } from '../rimraf' | ||
|
||
export function removeDirOrFile(dirOrFile: string[]) { | ||
return Promise.all(dirOrFile.map(async (p) => await rimraf(p))) | ||
} |
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,10 @@ | ||
import { existsSync, mkdirSync, writeFileSync } from 'fs' | ||
import { dirname } from 'path' | ||
|
||
export function writeFile(filename: string, content: string | Uint8Array) { | ||
const dir = dirname(filename) | ||
if (!existsSync(dir)) { | ||
mkdirSync(dir, { recursive: true }) | ||
} | ||
writeFileSync(filename, content) | ||
} |
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 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,12 @@ | ||
// ;['shared', 'core', 'cli'] | ||
// ['cli','core','shared','preset'] --> ['shared', 'core', 'cli', 'preset'] | ||
|
||
export function orderBy(target: string[], by: string[]) { | ||
if (by.length < 1) return target | ||
const indexMap = by | ||
.map((by) => target.findIndex((val) => val === by)) | ||
.filter((v) => v > -1) | ||
const pre = indexMap.map((i) => target[i]) | ||
const post = target.filter((_, i) => !indexMap.includes(i)) | ||
return [...pre, ...post] | ||
} |
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,13 @@ | ||
import remove from 'rimraf' | ||
|
||
export function rimraf( | ||
path: string, | ||
options: remove.Options = {} | ||
): Promise<void> { | ||
return new Promise((resolve, reject) => { | ||
remove(path, options, (err) => { | ||
if (err) reject(err) | ||
resolve() | ||
}) | ||
}) | ||
} |
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,33 @@ | ||
import execa from 'execa' | ||
import { Spinner } from '../spinner' | ||
import { Logger } from '../logger' | ||
|
||
export type IRunCmdMessage = { | ||
start: string | ||
succeed: string | ||
failed: string | ||
} | ||
|
||
const logger = new Logger(`xus:shared:runCmd`) | ||
|
||
export function runCmd( | ||
cmd: string, | ||
args: string[], | ||
message: IRunCmdMessage, | ||
options?: execa.Options | ||
): Promise<boolean> { | ||
const spinner = new Spinner() | ||
spinner.start(message.start) | ||
return new Promise((resolve, reject) => { | ||
execa(cmd, args, options) | ||
.then(() => { | ||
spinner.succeed(message.succeed) | ||
resolve(true) | ||
}) | ||
.catch((err) => { | ||
spinner.failed(message.failed) | ||
logger.error(err) | ||
reject(false) | ||
}) | ||
}) | ||
} |
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 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 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 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,3 @@ | ||
# `create` | ||
|
||
> TODO: description |
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,31 @@ | ||
{ | ||
"name": "@xus/preset-cmd-create", | ||
"version": "0.1.2", | ||
"description": "xus cli cmd create", | ||
"main": "dist/index.js", | ||
"typings": "dist/index.d.ts", | ||
"keywords": [ | ||
"cli", | ||
"create" | ||
], | ||
"author": "guo.xu <xuguo@outlook.it>", | ||
"homepage": "https://github.com/xus-code/bundle-tools/tree/master/packages/cli#readme", | ||
"license": "MIT", | ||
"files": [ | ||
"dist" | ||
], | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/xus-code/bundle-tools.git" | ||
}, | ||
"scripts": { | ||
"dev:create": "tsc --watch", | ||
"build:create": "tsc" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/xus-code/bundle-tools/issues" | ||
}, | ||
"dependencies": { | ||
"@xus/cli": "^0.1.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,17 @@ | ||
import { createPlugin } from '@xus/cli' | ||
|
||
export default createPlugin({ | ||
name: 'cmd:create', | ||
apply(api) { | ||
api.registerCommand( | ||
'create', | ||
{ | ||
desc: 'create template project', | ||
usage: 'xus create [dir]' | ||
}, | ||
() => { | ||
// | ||
} | ||
) | ||
} | ||
}) |
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,7 @@ | ||
import { defineConfig } from '@xus/cli' | ||
|
||
export default defineConfig({ | ||
libBuild: { | ||
targets: ['esm', 'cjs', 'browser'] | ||
} | ||
}) |
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,8 @@ | ||
{ | ||
"compilerOptions": { | ||
"outDir": "./dist" | ||
}, | ||
"extends": "../../tsconfig.json", | ||
"include": ["./src/**/*"], | ||
"exclude": ["./src/template/**/*"] | ||
} |
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 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,6 +1,11 @@ | ||
import presetBuiltIn from './preset' | ||
export default presetBuiltIn | ||
|
||
// types | ||
export type { ILintConfig } from './plugin/config/lint' | ||
export type { IChangelogConfig } from './plugin/config/changelog' | ||
export type { IReleaseConfig } from './plugin/config/release' | ||
|
||
// export | ||
export * from '@xus/plugin-build-lib' | ||
export * from '@xus/plugin-cmd-lib' |
Oops, something went wrong.